mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Add file_
parameter to function parse_requirements
, implement a try-except block in function parse_requirements
This commit is contained in:
parent
0886898d8d
commit
3d87f21392
@ -222,12 +222,16 @@ def get_name_without_alias(name):
|
|||||||
def join(f):
|
def join(f):
|
||||||
return os.path.join(os.path.dirname(__file__), f)
|
return os.path.join(os.path.dirname(__file__), f)
|
||||||
|
|
||||||
def parse_requirements():
|
def parse_requirements(file_):
|
||||||
modules = []
|
modules = []
|
||||||
delim = ["<", ">", "=", "!", "~"] # https://www.python.org/dev/peps/pep-0508/#complete-grammar
|
delim = ["<", ">", "=", "!", "~"] # https://www.python.org/dev/peps/pep-0508/#complete-grammar
|
||||||
|
|
||||||
with open("requirements.txt", "r") as f:
|
try:
|
||||||
data = [x.strip() for x in f.readlines() if x != "\n"]
|
with open(file_, "r") as f:
|
||||||
|
data = [x.strip() for x in f.readlines() if x != "\n"]
|
||||||
|
except OSError as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
parameters = [x for x in data if x.startswith("-")]
|
parameters = [x for x in data if x.startswith("-")]
|
||||||
data = [x for x in data if x[0].isalpha()]
|
data = [x for x in data if x[0].isalpha()]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user