mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:17:09 +00:00
Make bin script compatible with Python 3.6
This commit is contained in:
@@ -12,6 +12,18 @@ surveys should be under $HOME/etc/surveys/*.yaml. In both cases,
|
|||||||
$HOME is the home directory of the user running this script.
|
$HOME is the home directory of the user running this script.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def is_relative_to(it, other):
|
||||||
|
"""
|
||||||
|
is_relative_to() is not present version Python 3.9, so we
|
||||||
|
need this kludge to get Dougal to run on OpenSUSE 15.4
|
||||||
|
"""
|
||||||
|
|
||||||
|
if "is_relative_to" in dir(it):
|
||||||
|
return it.is_relative_to(other)
|
||||||
|
|
||||||
|
return str(it.absolute()).startswith(str(other.absolute()))
|
||||||
|
|
||||||
|
|
||||||
prefix = os.environ.get("DOUGAL_ROOT", os.environ.get("HOME", ".")+"/software")
|
prefix = os.environ.get("DOUGAL_ROOT", os.environ.get("HOME", ".")+"/software")
|
||||||
|
|
||||||
DOUGAL_ROOT = os.environ.get("DOUGAL_ROOT", os.environ.get("HOME", ".")+"/software")
|
DOUGAL_ROOT = os.environ.get("DOUGAL_ROOT", os.environ.get("HOME", ".")+"/software")
|
||||||
@@ -142,7 +154,7 @@ def untranslate_path (file):
|
|||||||
|
|
||||||
if filepath.is_absolute():
|
if filepath.is_absolute():
|
||||||
if type(import_paths) == str:
|
if type(import_paths) == str:
|
||||||
if filepath.is_relative_to(import_paths):
|
if is_relative_to(filepath, import_paths):
|
||||||
physical_root = pathlib.Path("/")
|
physical_root = pathlib.Path("/")
|
||||||
physical_prefix = pathlib.Path(import_paths)
|
physical_prefix = pathlib.Path(import_paths)
|
||||||
return str(root.joinpath(filepath.relative_to(physical_prefix)))
|
return str(root.joinpath(filepath.relative_to(physical_prefix)))
|
||||||
@@ -152,7 +164,7 @@ def untranslate_path (file):
|
|||||||
for key, value in import_paths.items():
|
for key, value in import_paths.items():
|
||||||
value = dougal_root.joinpath(value)
|
value = dougal_root.joinpath(value)
|
||||||
physical_prefix = pathlib.Path(value)
|
physical_prefix = pathlib.Path(value)
|
||||||
if filepath.is_relative_to(physical_prefix):
|
if is_relative_to(filepath, physical_prefix):
|
||||||
logical_prefix = physical_root.joinpath(pathlib.Path(key)).resolve()
|
logical_prefix = physical_root.joinpath(pathlib.Path(key)).resolve()
|
||||||
return str(logical_prefix.joinpath(filepath.relative_to(physical_prefix)))
|
return str(logical_prefix.joinpath(filepath.relative_to(physical_prefix)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user