Skip to content

Instantly share code, notes, and snippets.

@boegel
Created November 21, 2012 09:55
Show Gist options
  • Save boegel/4124055 to your computer and use it in GitHub Desktop.
Save boegel/4124055 to your computer and use it in GitHub Desktop.
diff --git a/easybuild/main.py b/easybuild/main.py
index 8b41b18..28ac11e 100644
--- a/easybuild/main.py
+++ b/easybuild/main.py
@@ -248,7 +248,7 @@ def parse_options():
return options, paths, log, logfile, hn, parser
-def main(options):
+def main(options, orig_paths, log, logfile, hn, parser):
"""
Main function:
@arg options: a tuple: (options, paths, logger, logfile, hn) as defined in parse_options
@@ -264,7 +264,6 @@ def main(options):
"Exiting.\n")
sys.exit(1)
- options, orig_paths, log, logfile, hn, parser = options
# show version
if options.version:
print_msg("This is EasyBuild %s" % VERBOSE_VERSION, log)
@@ -1451,7 +1450,7 @@ def print_tree(classes, classNames, detailed, depth=0):
if __name__ == "__main__":
try:
- main(parse_options())
+ main(*parse_options())
except EasyBuildError, e:
sys.stderr.write('ERROR: %s\n' % e.msg)
sys.exit(1)
@itkovian
Copy link

You've just moved the issue. Passing *parse_options() is fugly, but now I better see where it's coming from.

@boegel
Copy link
Author

boegel commented Nov 21, 2012

-        main(parse_options())
+        options, orig_paths, log, logfile, hn, parser = parse_options()
+        main(options, orig_paths, log, logfile, hn, parser)

Better like this? Same thing, way more variables, I like the *parse_options() 'hack' better.

@itkovian
Copy link

This is cleaner. Not sure what the JIT will make of it though. Here, one can see that parse_options() returns a tuple, and you are not moving that under the hood into main. Everything is more explicit. YMMV.

@boegel
Copy link
Author

boegel commented Nov 21, 2012

OK, let's go for the latter then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment