[27721] in Source-Commits
locker-support commit: Fix bug in athdir command-line parsing
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Thu Feb 20 09:16:49 2014
Date: Thu, 20 Feb 2014 09:16:42 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201402201416.s1KEGguC017318@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/locker-support/commit/6f4fe7b7691e05e77dbc7d243b5eae8091651662
commit 6f4fe7b7691e05e77dbc7d243b5eae8091651662
Author: Jonathan Reed <jdreed@mit.edu>
Date: Fri Feb 14 16:43:27 2014 -0500
Fix bug in athdir command-line parsing
- A bug prevented athdir from supporting the single-positional-argument
variation of the first invocation mode (with "type" defaulting to
"bin").
- Replace list comprehension and contains with any() per achernya's
suggestion
- Add comments documenting the two invocation modes.
athdir | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/athdir b/athdir
index 5aa1fea..2d3a34b 100755
--- a/athdir
+++ b/athdir
@@ -55,8 +55,13 @@ parser.add_option("--debug", dest="debug", action="store_true",
if len(sys.argv) < 2:
sys.exit(parser.get_usage())
-if len(sys.argv) == 3 and (True not in [ x.startswith('-') for x in sys.argv]):
- a = athdir.Athdir(sys.argv[1], sys.argv[2])
+# athdir can be invoked one of two ways.
+# a) athdir path [type=bin]
+# b) athdir [bunch of options with no position arguments]
+
+# This is the first invocation. There's probably a better way.
+if len(sys.argv) <= 3 and not any(x.startswith('-') for x in sys.argv):
+ a = athdir.Athdir(sys.argv[1], sys.argv[2] if len(sys.argv) == 3 else 'bin')
print ''.join(a.get_paths())
sys.exit(0)