def extract_dependencies(file_path):
"""
Parse the file contents and return the list of dependencies.
"""
with open(file_path) as fh:
file_contents = fh.read()
match = re.search(r"""^\s+dependencies [^\[]+
\[
([^\]]*)
\]""",
file_contents,
flags=re.VERBOSE | re.MULTILINE)
if not match:
return []
deps = match.group(1).strip()
if not deps:
return []
match_iter = re.finditer(r"""\(
'([^']+)'
,\s*
'([^_][^']+)'
\)""",
deps,
flags=re.VERBOSE)
return [(match.group(1), match.group(2)) for match in match_iter]
评论列表
文章目录