mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
fix(pipreqs.py): remove ''' and """ comments before going through imports
This commit is contained in:
parent
a4a40efe26
commit
1ee081454b
@ -53,8 +53,11 @@ def get_all_imports(path, encoding=None):
|
||||
candidates += [os.path.splitext(fn)[0] for fn in files]
|
||||
for file_name in files:
|
||||
with open_func(os.path.join(root, file_name), "r", encoding=encoding) as f:
|
||||
contents = re.sub(re.compile("'''.+?'''", re.DOTALL), '', f.read())
|
||||
contents = re.sub(re.compile('""".+"""', re.DOTALL), "", contents)
|
||||
lines = contents.split("\n")
|
||||
lines = filter(
|
||||
filter_line, map(lambda l: l.partition("#")[0].strip(), f))
|
||||
filter_line, map(lambda l: l.partition("#")[0].strip(), lines))
|
||||
for line in lines:
|
||||
if "(" in line:
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user