text stringlengths 0 828 |
|---|
match = expr.search(line) |
if match: |
return Match(filename, lines, line_index=i, |
version=Version(match.group('v')), span=match.span('v')) |
return None" |
518,"def get_changed_files(include_staged=False): |
"""""" |
Returns a list of the files that changed in the Git repository. This is |
used to check if the files that are supposed to be upgraded have changed. |
If so, the upgrade will be prevented. |
"""""" |
process = subprocess.Popen(['git', 'status', '--porcelain'], |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
stdout, __ = process.communicate() |
if process.returncode != 0: |
raise ValueError(stdout) |
files = [] |
for line in stdout.decode().split('\n'): |
if not line or line.startswith('#'): continue |
assert line[2] == ' ' |
if not include_staged and line[1] == ' ': continue |
files.append(line[3:]) |
return files" |
519,"def _parse_doc(docs): |
"""""" |
Converts a well-formed docstring into documentation |
to be fed into argparse. |
See signature_parser for details. |
shorts: (-k for --keyword -k, or ""from"" for ""frm/from"") |
metavars: (FILE for --input=FILE) |
helps: (docs for --keyword: docs) |
description: the stuff before |
epilog: the stuff after |
"""""" |
name = ""(?:[a-zA-Z][a-zA-Z0-9-_]*)"" |
re_var = re.compile(r""^ *(%s)(?: */(%s))? *:(.*)$"" % (name, name)) |
re_opt = re.compile(r""^ *(?:(-[a-zA-Z0-9]),? +)?--(%s)(?: *=(%s))? *:(.*)$"" |
% (name, name)) |
shorts, metavars, helps, description, epilog = {}, {}, {}, """", """" |
if docs: |
for line in docs.split(""\n""): |
line = line.strip() |
# remove starting ':param' |
if line.startswith(':param'): |
line = line[len(':param'):] |
# skip ':rtype:' row |
if line.startswith(':rtype:'): |
continue |
if line.strip() == ""----"": |
break |
m = re_var.match(line) |
if m: |
if epilog: |
helps[prev] += epilog.strip() |
epilog = """" |
if m.group(2): |
shorts[m.group(1)] = m.group(2) |
helps[m.group(1)] = m.group(3).strip() |
prev = m.group(1) |
previndent = len(line) - len(line.lstrip()) |
continue |
m = re_opt.match(line) |
if m: |
if epilog: |
helps[prev] += epilog.strip() |
epilog = """" |
name = m.group(2).replace(""-"", ""_"") |
helps[name] = m.group(4) |
prev = name |
if m.group(1): |
shorts[name] = m.group(1) |
if m.group(3): |
metavars[name] = m.group(3) |
previndent = len(line) - len(line.lstrip()) |
continue |
if helps: |
if line.startswith("" "" * (previndent + 1)): |
helps[prev] += ""\n"" + line.strip() |
else: |
epilog += ""\n"" + line.strip() |
else: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.