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 11#!/usr/bin/python3
22import os
3- import sys
43import re
4+ import sys
55import urllib .request
66
77PACKAGE = sys .argv [1 ]
88MAX_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 ("," )
1010
1111# Load PyPI website for the package
1212fp = urllib .request .urlopen (f"https://pypi.org/simple/{ PACKAGE } /" )
1313html_string = fp .read ().decode ("utf8" )
1414fp .close ()
1515
1616# 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 ]
2020else :
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 ]
2323
2424unique_versions = list (dict .fromkeys (versions ))
2525
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