示例#1
0
  def tag_annotation(clazz, root_dir, tag_name):
    'Return the annotation for tag_name or raise an error it is not annotated.'
    check.check_string(root_dir)
    check.check_string(tag_name)

    if not clazz.tag_has_annotation(root_dir, tag_name):
      raise git_error('not an annotated tag: "{}"'.format(tag_name))
    rv = git_exe.call_git(root_dir, [ 'tag', '-n', '--format=%(subject)', tag_name ])
    return string_util.unquote(rv.stdout.strip())
示例#2
0
 def _parse_text(clazz, text, filename, delimiter):
     check.check_string(text)
     lines = text_line_parser.parse_lines(text,
                                          strip_comments=True,
                                          strip_text=True,
                                          remove_empties=True)
     result = {}
     for line in lines:
         kv = key_value.parse(line, delimiter=delimiter)
         result[kv.key] = string_util.unquote(kv.value)
     return result
示例#3
0
 def _parse_show_ref_one_line(clazz, s):
     s = string_util.unquote(s)
     f = re.findall(r'^\s*([0-9a-f]{40})\s+refs/tags/(.+)\s*$', s)
     if not f:
         return None
     if len(f) != 1:
         return None
     commit = f[0][0]
     name = f[0][1]
     peeled = False
     if name.endswith('^{}'):
         name = string_util.remove_tail(name, '^{}')
         peeled = True
     return git_tag(name, commit, git_commit_hash.shorten(commit), peeled)
示例#4
0
 def get_value(clazz, key):
   rv = git_exe.call_git(tempfile.gettempdir(), [ 'config', '--global', key ], raise_error = False)
   if rv.exit_code == 0:
     return string_util.unquote(rv.stdout.strip())
   else:
     return None
示例#5
0
 def parse_value(self, key, value):
     return string_util.unquote(value)
示例#6
0
 def unquote_strings(self):
     for i, kv in enumerate(self._values):
         if string_util.is_string(kv.value):
             self._values[i] = key_value(kv.key,
                                         string_util.unquote(kv.value))
示例#7
0
 def unquote(self):
     self._values = [string_util.unquote(s) for s in self._values]
示例#8
0
 def test_unquote(self):
     self.assertEqual('foo', string_util.unquote('\'foo\''))
     self.assertEqual('foo', string_util.unquote('\"foo\"'))
     self.assertEqual('\'foo\"', string_util.unquote('\'foo\"'))
     self.assertEqual('\'foo', string_util.unquote('\'foo'))
     self.assertEqual('foo\'', string_util.unquote('foo\''))
示例#9
0
文件: config.py 项目: reconstruir/bes
 def _value_for_get(self, value):
     if self._string_quote_char:
         return string_util.unquote(value)
     return value