@@ -65,21 +65,29 @@ def parse_version(self, version):
65
65
'''
66
66
67
67
data = self .get_version_from_string (version )
68
+ if data is None :
69
+ raise ValueError ('{} is not a valid version' .format (version ))
70
+
68
71
if data is not None and data ['ps_version' ] == self .NIGHTLY :
69
72
ps_version = self .NIGHTLY
70
73
else :
71
- # Initial PS version(can also be a branch like 9.0.x)
72
74
split_version = self .split_prestashop_version (version )
73
- if split_version is None or not (self .directory_path / split_version ['version' ]).exists ():
74
- raise ValueError ('{} is not a valid version' .format (version ))
75
- ps_version = split_version ['version' ]
75
+ if split_version is not None and split_version ['patch' ] == 'x' :
76
+ # Special case for branch versions (like 9.0.x)
77
+ ps_version = split_version ['version' ]
78
+ else :
79
+ # Other use case we get the parsed version (stripped from container details)
80
+ ps_version = data ['ps_version' ]
81
+
82
+ ps_version_path = self .directory_path / ps_version
83
+ if not ps_version_path .exists ():
84
+ raise ValueError ('{} directory not found for version {}' .format (ps_version_path , version ))
76
85
77
86
if data is None or data ['container_version' ] is None :
78
87
containers = ('fpm' , 'apache' ,)
79
88
else :
80
89
containers = (data ['container_version' ],)
81
90
82
- ps_version_path = self .directory_path / ps_version
83
91
result = {}
84
92
for php_version in data ['php_versions' ]:
85
93
for container in containers :
@@ -95,8 +103,8 @@ def get_version_from_string(self, version):
95
103
96
104
@param version: The version you want
97
105
@type version: str
98
- @return: A tuple containing ('PS_VERSION', 'BRANCH_VERSION', (PHP_VERSIONS), 'CONTAINER_TYPE', 'FLAVOR_VERSION ')
99
- or ('PS_VERSION', 'BRANCH_VERSION', 'PHP_VERSION', 'CONTAINER_TYPE', 'FLAVOR_VERSION ')
106
+ @return: A tuple containing ('PS_VERSION', 'BRANCH_VERSION', (PHP_VERSIONS), 'CONTAINER_TYPE', 'DISTRIBUTION ')
107
+ or ('PS_VERSION', 'BRANCH_VERSION', 'PHP_VERSION', 'CONTAINER_TYPE', 'DISTRIBUTION ')
100
108
@rtype: tuple
101
109
'''
102
110
matches = self .parse_version_from_string (version )
@@ -105,10 +113,10 @@ def get_version_from_string(self, version):
105
113
106
114
ps_version = matches .group ('version' )
107
115
108
- flavor_versions = None
109
- if matches .group ('flavor ' ):
110
- flavor_versions = matches .group ('flavor ' )
111
- ps_version = ps_version + '-' + flavor_versions
116
+ distribution = None
117
+ if matches .group ('distribution ' ):
118
+ distribution = matches .group ('distribution ' )
119
+ ps_version = ps_version + '-' + distribution
112
120
113
121
if matches .group ('php' ):
114
122
php_versions = (matches .group ('php' ),)
@@ -147,7 +155,7 @@ def get_version_from_string(self, version):
147
155
'branch_version' : branch_version ,
148
156
'php_versions' : php_versions ,
149
157
'container_version' : container_version ,
150
- 'flavor_versions ' : flavor_versions
158
+ 'distribution ' : distribution
151
159
}
152
160
153
161
def get_last_patch_from_version (self , version ):
@@ -186,19 +194,23 @@ def split_prestashop_version(self, version):
186
194
@return: Return None if no patch is found otherwise an int with the patch.
187
195
@rtpe: None|tuple
188
196
'''
189
- regex = r"^(?P<major>(1.)?[0-9]+)\.(?P<minor>[0-9]+)\.(?P<patch>[0-9x]+)(?P<prerelease>-(alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?"
197
+
198
+ regex = r"^(?P<major>(1.)?[0-9]+)\.(?P<minor>[0-9]+)\.(?P<patch>[0-9x]+)(?P<prerelease>-(alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?(?:-(?P<distribution>classic))?"
199
+
190
200
matches = re .search (regex , version )
191
201
192
202
if (matches and matches .group () and matches .group ('major' ) and matches .group ('major' ) and matches .group ('major' )):
193
203
# Remove the initial matched -
194
204
prerelease = matches .group ('prerelease' )[1 :] if matches .group ('prerelease' ) else None
205
+ distribution = matches .group ('distribution' ) if matches .group ('distribution' ) else None
195
206
196
207
return {
197
208
'version' : matches .group ('major' ) + '.' + matches .group ('minor' ) + '.' + matches .group ('patch' ),
198
209
'major' : matches .group ('major' ),
199
210
'minor' : matches .group ('minor' ),
200
211
'patch' : matches .group ('patch' ),
201
212
'prerelease' : prerelease ,
213
+ 'distribution' : distribution
202
214
}
203
215
return None
204
216
@@ -210,7 +222,7 @@ def parse_version_from_string(self, version):
210
222
@return: Return None if no position in the string matches the pattern otherwise a Match object.
211
223
@rtpe: None|Match
212
224
'''
213
- regex = r"^(?P<version>(?:[0-9]+\.){0,3}(?:[0-9]+|nightly|x)(?:-(?:alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?)(?:-(?P<flavor >classic))?(?:-(?P<php>\d+\.\d+))?(?:-(?P<container>fpm|apache))?$"
225
+ regex = r"^(?P<version>(?:[0-9]+\.){0,3}(?:[0-9]+|nightly|x)(?:-(?:alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?)(?:-(?P<distribution >classic))?(?:-(?P<php>\d+\.\d+))?(?:-(?P<container>fpm|apache))?$"
214
226
return re .search (regex , version )
215
227
216
228
def get_aliases (self ):
0 commit comments