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())
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
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)
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
def parse_value(self, key, value): return string_util.unquote(value)
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))
def unquote(self): self._values = [string_util.unquote(s) for s in self._values]
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\''))
def _value_for_get(self, value): if self._string_quote_char: return string_util.unquote(value) return value