mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-17 17:56:33 +00:00
Merge pull request #48 from grahampugh/dev-packaging
Allow for removal of distutils in a future python
This commit is contained in:
commit
69ee37ae4e
@ -42,14 +42,18 @@ except ImportError:
|
|||||||
from urlparse import urlsplit
|
from urlparse import urlsplit
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
try:
|
||||||
|
from packaging.version import Version
|
||||||
|
except ImportError:
|
||||||
|
from distutils.version import LooseVersion as Version
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import xattr
|
import xattr
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print(
|
print(
|
||||||
"This tool requires the Python xattr module. "
|
"This tool requires the Python xattr and packaging modules. "
|
||||||
"Perhaps run `pip install xattr` to install it."
|
"Perhaps run `pip install xattr packaging` to install them."
|
||||||
)
|
)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
@ -698,7 +702,7 @@ def os_installer_product_info(
|
|||||||
def get_latest_version(current_item, latest_item):
|
def get_latest_version(current_item, latest_item):
|
||||||
"""Compares versions between two values and returns the latest (highest) value"""
|
"""Compares versions between two values and returns the latest (highest) value"""
|
||||||
try:
|
try:
|
||||||
if LooseVersion(current_item) > LooseVersion(latest_item):
|
if Version(current_item) > Version(latest_item):
|
||||||
return current_item
|
return current_item
|
||||||
else:
|
else:
|
||||||
return latest_item
|
return latest_item
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user