2323public class PythonWheelDetails {
2424
2525 // PEP-0427
26- public static final String WHEEL_FILE_FORMAT = "(?<dist>.*?)-(?<version>.*?)(-(.*?))?-(?<pythonTag>.*?)-(?<abiTag>.*?)-(?<platformTag>.*?).whl" ;
27-
28- final File file ;
29- final String dist ;
30- final String version ;
31- final String pythonTag ;
32- final String abiTag ;
33- final String platformTag ;
34-
35- public PythonWheelDetails (File file , Matcher matcher ) {
36- this .file = file ;
37- this .dist = matcher .group ("dist" );
38- this .version = matcher .group ("version" );
39- this .pythonTag = matcher .group ("pythonTag" );
40- this .abiTag = matcher .group ("abiTag" );
41- this .platformTag = matcher .group ("platformTag" );
26+ private static final String WHEEL_FILE_FORMAT = "(?<dist>.+?)-(?<version>\\ d.*?)(-(\\ d.*?))?-(?<pythonTag>.+?)-(?<abiTag>.+?)-(?<platformTag>.+?).whl" ;
27+
28+ private static final Pattern WHEEL_PATTERN = Pattern .compile (WHEEL_FILE_FORMAT );
29+ private static final Pattern SNAPSHOT_PATTERN = Pattern .compile ("_(?<snapshot>[A-Z]+)$" );
30+
31+ private final File file ;
32+ private final String dist ;
33+ private final String version ;
34+ private final String pythonTag ;
35+ private final String abiTag ;
36+ private final String platformTag ;
37+
38+ private PythonWheelDetails (File wheelFile , Matcher matcher ) {
39+ file = wheelFile ;
40+ dist = matcher .group ("dist" );
41+ String matchedVersion = matcher .group ("version" );
42+ pythonTag = matcher .group ("pythonTag" );
43+ abiTag = matcher .group ("abiTag" );
44+ platformTag = matcher .group ("platformTag" );
45+
46+ Matcher snapshotMatcher = SNAPSHOT_PATTERN .matcher (matchedVersion );
47+ if (snapshotMatcher .find ()) {
48+ version = snapshotMatcher .replaceFirst ("-" + snapshotMatcher .group ("snapshot" ));
49+ } else {
50+ version = matchedVersion ;
51+ }
52+ }
53+
54+ public File getFile () {
55+ return file ;
4256 }
4357
4458 public String getDist () {
@@ -49,6 +63,18 @@ public String getVersion() {
4963 return version ;
5064 }
5165
66+ public String getPythonTag () {
67+ return pythonTag ;
68+ }
69+
70+ public String getAbiTag () {
71+ return abiTag ;
72+ }
73+
74+ public String getPlatformTag () {
75+ return platformTag ;
76+ }
77+
5278 @ Override
5379 public String toString () {
5480 return "PythonWheelDetails{"
@@ -61,9 +87,8 @@ public String toString() {
6187 + '}' ;
6288 }
6389
64- static public Optional <PythonWheelDetails > fromFile (File file ) {
65- Pattern wheelPattern = Pattern .compile (WHEEL_FILE_FORMAT );
66- Matcher matcher = wheelPattern .matcher (file .getName ());
90+ public static Optional <PythonWheelDetails > fromFile (File file ) {
91+ Matcher matcher = WHEEL_PATTERN .matcher (file .getName ());
6792 if (!matcher .matches ()) {
6893 return Optional .empty ();
6994 }
0 commit comments