Skip to content

Commit e80db2d

Browse files
committed
eat all arguments
1 parent 1a94b9a commit e80db2d

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

tools/tide.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_packages(url):
2424
exit(1)
2525

2626
if "A required part of this site couldn’t load" in response.text:
27-
print("Fastly is blocking us. Status code: 403")
27+
print(f"Fastly is blocking us for {url}. Status code: 403")
2828
exit(1)
2929

3030
# Parse the HTML content
@@ -97,16 +97,23 @@ def maybefloat(x):
9797

9898
if __name__ == "__main__":
9999
# URL of the webpage
100-
if sys.argv[1] == "--org":
101-
url = f"https://pypi.org/org/{sys.argv[2]}/"
102-
packages = get_packages(url)
103-
elif sys.argv[1] == "--user":
104-
url = f"https://pypi.org/user/{sys.argv[2]}/"
105-
packages = get_packages(url)
106-
elif sys.argv[1] == "--packages":
107-
packages = sys.argv[2:]
108-
else:
109-
print("Invalid argument. Please use either --org ORG or --user USER")
110-
exit(1)
111-
100+
args = sys.argv[1:]
101+
packages = []
102+
while args:
103+
if args[0] == "--org":
104+
url = f"https://pypi.org/org/{args[1]}/"
105+
packages += get_packages(url)
106+
args = args[2:]
107+
elif args[0] == "--user":
108+
url = f"https://pypi.org/user/{args[1]}/"
109+
packages += get_packages(url)
110+
args = args[2:]
111+
elif args[0] == "--packages":
112+
packages += args[1:]
113+
args = []
114+
else:
115+
print(
116+
"Invalid argument. Please use either --org ORG, --user USER or --packages PACKAGE1 PACKAGE2 ..."
117+
)
118+
exit(1)
112119
get_tidelift_data(packages)

0 commit comments

Comments
 (0)