File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python3
2
2
import os
3
- import sys
4
3
import re
4
+ import sys
5
5
import urllib .request
6
6
7
7
PACKAGE = sys .argv [1 ]
8
8
MAX_VERSIONS = sys .argv [2 ] if len (sys .argv ) > 2 else 10
9
- EXCLUDE_VERSIONS = os .environ .get ("EXCLUDE_VERSIONS" , "" ).split ("," )
9
+ EXCLUDE_VERSIONS = os .environ .get ("EXCLUDE_VERSIONS" , "" ).split ("," )
10
10
11
11
# Load PyPI website for the package
12
12
fp = urllib .request .urlopen (f"https://pypi.org/simple/{ PACKAGE } /" )
13
13
html_string = fp .read ().decode ("utf8" )
14
14
fp .close ()
15
15
16
16
# Pick a regex- either include prerelease versions or not
17
- if os .environ .get ("INCLUDE_PRERELEASE" , False ) == ' true' :
18
- version_regex = re .compile (r' -(\d+\.\d+\.\d+(a|b|rc)?\d?).+[\.whl|\.tar\.gz]' )
19
- versions = [x [0 ] for x in version_regex .findall (html_string ) if x [0 ] not in EXCLUDE_VERSIONS ]
17
+ if os .environ .get ("INCLUDE_PRERELEASE" , False ) == " true" :
18
+ version_regex = re .compile (r" -(\d+\.\d+\.\d+(a|b|rc)?\d?).+[\.whl|\.tar\.gz]" )
19
+ versions = [x [0 ] for x in version_regex .findall (html_string ) if x [0 ] not in EXCLUDE_VERSIONS ]
20
20
else :
21
- version_regex = re .compile (r' -(\d+\.\d+\.\d+). +[\.whl|\.tar\.gz]' )
22
- versions = [x for x in version_regex .findall (html_string ) if x not in EXCLUDE_VERSIONS ]
21
+ version_regex = re .compile (r" -(\d+\.\d+\.\d+)\.. +[\.whl|\.tar\.gz]" )
22
+ versions = [x for x in version_regex .findall (html_string ) if x not in EXCLUDE_VERSIONS ]
23
23
24
24
unique_versions = list (dict .fromkeys (versions ))
25
25
26
- for version in unique_versions [- (int (MAX_VERSIONS )):]:
27
- print (version )
26
+ for version in unique_versions [- (int (MAX_VERSIONS )) :]:
27
+ print (version )
You can’t perform that action at this time.
0 commit comments