Skip to content
Snippets Groups Projects
Unverified Commit 4da99aab authored by Ross Beyer's avatar Ross Beyer Committed by GitHub
Browse files

Convert input relative paths to absolute in isisVarInit.py (#4275)

* isisVarInit.py(fix): relative paths given to the command line arguments
will now be correctly resolved to their aboslute paths on input, ensuring
they will be written into the activation scripts that way.

* Added note to Changelog.
parent e3232cb7
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,7 @@ update the Unreleased link so that it compares against the latest release tag. ...@@ -45,6 +45,7 @@ update the Unreleased link so that it compares against the latest release tag.
- Fixed not being able to enable USECOORDLIST argument in mappt. [#4150](https://github.com/USGS-Astrogeology/ISIS3/issues/4150) - Fixed not being able to enable USECOORDLIST argument in mappt. [#4150](https://github.com/USGS-Astrogeology/ISIS3/issues/4150)
- Fixed history entry not being added to a cube when running spiceinit with web=true. [4040](https://github.com/USGS-Astrogeology/ISIS3/issues/4040) - Fixed history entry not being added to a cube when running spiceinit with web=true. [4040](https://github.com/USGS-Astrogeology/ISIS3/issues/4040)
- Updated wavelength and bandbin values in translation files for the TGO CaSSIS BandBin group. [4147](https://github.com/USGS-Astrogeology/ISIS3/issues/4147) - Updated wavelength and bandbin values in translation files for the TGO CaSSIS BandBin group. [4147](https://github.com/USGS-Astrogeology/ISIS3/issues/4147)
- Fixed relative paths not being properly converted to absolute paths in isisVarInit.py [4274](https://github.com/USGS-Astrogeology/ISIS3/issues/4274)
## [4.3.0] - 2020-10-02 ## [4.3.0] - 2020-10-02
......
...@@ -21,6 +21,26 @@ from pathlib import Path ...@@ -21,6 +21,26 @@ from pathlib import Path
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
class ResolveAction(argparse.Action):
"""A custom action that returns the absolute version of the provided
pathlib.Path argument.
"""
def __init__(self, option_strings, dest, type=None, **kwargs):
if issubclass(Path, type):
super(ResolveAction, self).__init__(
option_strings, dest, type=type, **kwargs
)
else:
raise TypeError(
f"The type= parameter of argument {dest} must be a "
f"class or subclass of pathlib.Path."
)
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values.resolve())
def mkdir(p: Path) -> str: def mkdir(p: Path) -> str:
"""Returns a string with a message about the creation or existance """Returns a string with a message about the creation or existance
of the path, *p*.""" of the path, *p*."""
...@@ -64,23 +84,26 @@ parser = argparse.ArgumentParser(description=__doc__) ...@@ -64,23 +84,26 @@ parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument( parser.add_argument(
"-d", "-d",
"--data-dir", "--data-dir",
default=os.environ["CONDA_PREFIX"] + "/data", default=Path(os.environ["CONDA_PREFIX"] + "/data"),
type=Path, type=Path,
action=ResolveAction,
help="ISIS Data Directory, default: %(default)s", help="ISIS Data Directory, default: %(default)s",
) )
parser.add_argument( parser.add_argument(
"-t", "-t",
"--test-dir", "--test-dir",
default=os.environ["CONDA_PREFIX"] + "/testData", default=Path(os.environ["CONDA_PREFIX"] + "/testData"),
type=Path, type=Path,
action=ResolveAction,
help="ISIS Test Data Directory, default: %(default)s", help="ISIS Test Data Directory, default: %(default)s",
) )
parser.add_argument( parser.add_argument(
"-a", "-a",
"--ale-dir", "--ale-dir",
default=os.environ["CONDA_PREFIX"] + "/aleData", default=Path(os.environ["CONDA_PREFIX"] + "/aleData"),
type=Path, type=Path,
action=ResolveAction,
help="ISIS Ale Data Directory, default: %(default)s", help="ISIS Ale Data Directory, default: %(default)s",
) )
args = parser.parse_args() args = parser.parse_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment