本文整理汇总了Python中gbp.git.repository.GitRepository.git_inout方法的典型用法代码示例。如果您正苦于以下问题:Python GitRepository.git_inout方法的具体用法?Python GitRepository.git_inout怎么用?Python GitRepository.git_inout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbp.git.repository.GitRepository
的用法示例。
在下文中一共展示了GitRepository.git_inout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read_git_mailinfo
# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import git_inout [as 别名]
def _read_git_mailinfo(self):
"""
Read patch information into a structured form
using I{git mailinfo}
"""
self.info = {}
self.long_desc = ''
body = tempfile.NamedTemporaryFile(prefix='gbp_')
# No patch yet, file name information only
if not os.path.exists(self.path):
return
# The patch description might contain UTF-8 while the actual patch is ascii.
# To unconfuse git-mailinfo stop at the patch separator
toparse = []
for line in open(self.path, 'rb'):
if line == b'---\n':
break
toparse.append(line)
input = b''.join(toparse)
if input.strip():
out, err, ret = GitRepository.git_inout(command='mailinfo',
args=['-k', body.name, '/dev/null'],
input=input,
extra_env=None,
cwd=None,
capture_stderr=True)
if ret != 0:
raise GbpError("Failed to read patch header of '%s': %s" %
(self.path, err))
else:
out = b''
# Header
for line in out.decode().split('\n'):
if ':' in line:
rfc_header, value = line.split(" ", 1)
header = rfc_header[:-1].lower()
self.info[header] = value.strip()
# Body
try:
self.long_desc = "".join([l.decode("utf-8", "backslashreplace") for l in body])
except (IOError, UnicodeDecodeError) as msg:
raise GbpError("Failed to read patch header of '%s': %s" %
(self.path, msg))
finally:
body.close()
if os.path.exists(body.name):
os.unlink(body.name)