mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
pylint changes
This commit is contained in:
parent
7beaf26068
commit
6ad6a90955
@ -2,7 +2,7 @@
|
|||||||
'''
|
'''
|
||||||
Package support for openSUSE via the zypper package manager
|
Package support for openSUSE via the zypper package manager
|
||||||
|
|
||||||
:depends: - ``zypp`` Python module. Install with ``zypper install python-zypp``
|
:depends: - ``rpm`` Python module. Install with ``zypper install rpm-python``
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Import python libs
|
# Import python libs
|
||||||
@ -11,10 +11,10 @@ import copy
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import rpm
|
|
||||||
|
|
||||||
# Import 3rd-party libs
|
# Import 3rd-party libs
|
||||||
# pylint: disable=import-error,redefined-builtin,no-name-in-module
|
# pylint: disable=import-error,redefined-builtin,no-name-in-module
|
||||||
|
import rpm
|
||||||
import salt.ext.six as six
|
import salt.ext.six as six
|
||||||
from salt.ext.six.moves import configparser
|
from salt.ext.six.moves import configparser
|
||||||
from salt.ext.six.moves.urllib.parse import urlparse as _urlparse
|
from salt.ext.six.moves.urllib.parse import urlparse as _urlparse
|
||||||
@ -288,7 +288,8 @@ def version(*names, **kwargs):
|
|||||||
'''
|
'''
|
||||||
return __salt__['pkg_resource.version'](*names, **kwargs) or {}
|
return __salt__['pkg_resource.version'](*names, **kwargs) or {}
|
||||||
|
|
||||||
def _stringToEVR(verstring):
|
|
||||||
|
def _string_to_evr(verstring):
|
||||||
'''
|
'''
|
||||||
Split the version string into epoch, version and release and
|
Split the version string into epoch, version and release and
|
||||||
return this as tuple.
|
return this as tuple.
|
||||||
@ -303,24 +304,25 @@ def _stringToEVR(verstring):
|
|||||||
'''
|
'''
|
||||||
if verstring in [None, '']:
|
if verstring in [None, '']:
|
||||||
return ('0', '', '')
|
return ('0', '', '')
|
||||||
i = verstring.find(':')
|
idx_e = verstring.find(':')
|
||||||
if i != -1:
|
if idx_e != -1:
|
||||||
try:
|
try:
|
||||||
epoch = str(long(verstring[:i]))
|
epoch = str(int(verstring[:idx_e]))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# look, garbage in the epoch field, how fun, kill it
|
# look, garbage in the epoch field, how fun, kill it
|
||||||
epoch = '0' # this is our fallback, deal
|
epoch = '0' # this is our fallback, deal
|
||||||
else:
|
else:
|
||||||
epoch = '0'
|
epoch = '0'
|
||||||
j = verstring.find('-')
|
idx_r = verstring.find('-')
|
||||||
if j != -1:
|
if idx_r != -1:
|
||||||
version = verstring[i + 1:j]
|
version = verstring[idx_e + 1:idx_r]
|
||||||
release = verstring[j + 1:]
|
release = verstring[idx_r + 1:]
|
||||||
else:
|
else:
|
||||||
version = verstring[i + 1:]
|
version = verstring[idx_e + 1:]
|
||||||
release = ''
|
release = ''
|
||||||
return (epoch, version, release)
|
return (epoch, version, release)
|
||||||
|
|
||||||
|
|
||||||
def version_cmp(ver1, ver2):
|
def version_cmp(ver1, ver2):
|
||||||
'''
|
'''
|
||||||
.. versionadded:: 2015.5.4
|
.. versionadded:: 2015.5.4
|
||||||
@ -337,8 +339,8 @@ def version_cmp(ver1, ver2):
|
|||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
cmp_result = rpm.labelCompare(
|
cmp_result = rpm.labelCompare(
|
||||||
_stringToEVR(ver1),
|
_string_to_evr(ver1),
|
||||||
_stringToEVR(ver2)
|
_string_to_evr(ver2)
|
||||||
)
|
)
|
||||||
if cmp_result not in (-1, 0, 1):
|
if cmp_result not in (-1, 0, 1):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
Loading…
Reference in New Issue
Block a user