mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add operator support for version wildcard
This commit is contained in:
parent
7fc33a3f82
commit
3900cf8e4e
@ -330,6 +330,8 @@ class Wildcard(object):
|
||||
:return: Query range
|
||||
'''
|
||||
|
||||
Z_OP = ['<', '<=', '=', '>=', '>']
|
||||
|
||||
def __init__(self, zypper):
|
||||
'''
|
||||
:type zypper: a reference to an instance of a _Zypper class.
|
||||
@ -338,6 +340,7 @@ class Wildcard(object):
|
||||
self.version = None
|
||||
self.zypper = zypper
|
||||
self._attr_solvable_version = 'edition'
|
||||
self._op = None
|
||||
|
||||
def __call__(self, pkg_name, pkg_version):
|
||||
'''
|
||||
@ -349,10 +352,10 @@ class Wildcard(object):
|
||||
'''
|
||||
if pkg_version:
|
||||
self.name = pkg_name
|
||||
self.version = pkg_version
|
||||
self._set_version(pkg_version) # Dissects possible operator
|
||||
versions = sorted([LooseVersion and LooseVersion(vrs) or vrs
|
||||
for vrs in self._get_scope_versions(self._get_available_versions())])
|
||||
return versions and '{0}'.format(versions[-1]) or None
|
||||
return versions and '{0}{1}'.format(self._op or '', versions[-1]) or None
|
||||
|
||||
def _get_available_versions(self):
|
||||
'''
|
||||
@ -378,6 +381,19 @@ class Wildcard(object):
|
||||
get_in_versions.append(p_version)
|
||||
return get_in_versions
|
||||
|
||||
def _set_version(self, version):
|
||||
'''
|
||||
Stash operator from the version, if any.
|
||||
|
||||
:return:
|
||||
'''
|
||||
if not version:
|
||||
return
|
||||
|
||||
exact_version = re.sub('[<>=]*', '', version)
|
||||
self._op = version.replace(exact_version, '') or None
|
||||
self.version = exact_version
|
||||
|
||||
|
||||
def _systemd_scope():
|
||||
return salt.utils.systemd.has_scope(__context__) \
|
||||
|
Loading…
Reference in New Issue
Block a user