diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-15 09:48:44 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-17 01:16:46 +0800 |
commit | 09bcd7b1a95764889cce11f7c80a767e97d6e548 (patch) | |
tree | 333c7128ee84210e9bb47117d1b7d2ea83bcadc3 /scripts/manifest.py | |
parent | 5ff4ae0264ec7da2653f7ca375c3ec9521520b93 (diff) | |
download | chandra-acis-analysis-09bcd7b1a95764889cce11f7c80a767e97d6e548.tar.bz2 |
manifest.py: Do not change when to find the manifest file.
Diffstat (limited to 'scripts/manifest.py')
-rwxr-xr-x | scripts/manifest.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/manifest.py b/scripts/manifest.py index bf05dac..c95b218 100755 --- a/scripts/manifest.py +++ b/scripts/manifest.py @@ -203,7 +203,7 @@ class Manifest: return parsed_values -def find_manifest(filename="manifest.yaml"): +def find_manifest(filename="manifest.yaml", startdir=os.getcwd()): """ Find the specified manifest file in current directory and the upper-level directories. @@ -223,7 +223,7 @@ def find_manifest(filename="manifest.yaml"): FileNotFoundError : Cannot found the specified manifest """ - dirname = os.getcwd() + dirname = startdir filepath = os.path.join(dirname, filename) while dirname != "/": if os.path.exists(filepath): @@ -347,10 +347,10 @@ def main(description="Manage the observation manifest (YAML format)", help="Manifest file (default: %s)" % default_file) parser.add_argument("-b", "--brief", dest="brief", action="store_true", help="Be brief") - parser.add_argument("-C", "--directory", dest="directory", - help="Change to the given directory at first") + parser.add_argument("-C", "--directory", dest="directory", default=".", + help="From where to find the manifest file") parser.add_argument("-s", "--separator", dest="separator", default=" ", - help="separator to join output list values " + + help="Separator to join output list values " + "(default: whitespace)") subparsers = parser.add_subparsers(dest="cmd_name", title="sub-commands", @@ -408,9 +408,8 @@ def main(description="Manage the observation manifest (YAML format)", if os.path.exists(args.file): manifest_file = args.file else: - if args.directory: - os.chdir(args.directory) - manifest_file = find_manifest(args.file) + manifest_file = find_manifest( + args.file, startdir=os.path.abspath(args.directory)) manifest = Manifest(manifest_file) |