-
-
Save qheuristics/56e9190ea388fe91f1768559be1b77aa to your computer and use it in GitHub Desktop.
Revisions
-
elmotec revised this gist
May 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def parse_command_line(argv): def main(): """Main program. Sets up logging and do some work.""" logging.basicConfig(stream=sys.stderr, level=logging.DEBUG, format='%(name)s (%(levelname)s): %(message)s') try: arguments = parse_command_line(sys.argv) # Do something with arguments. -
elmotec revised this gist
May 24, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,9 +29,8 @@ def parse_command_line(argv): parser.add_argument('-o', metavar="output", type=argparse.FileType('w'), default=sys.stdout, help="redirect output to a file") parser.add_argument('input', metavar="input", nargs='+', argparse.REMAINDER, help="input if any...") arguments = parser.parse_args(argv[1:]) # Sets log level to WARN going more verbose for each new -v. log.setLevel(max(3 - arguments.verbose_count, 0) * 10) -
elmotec revised this gist
Nov 16, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,6 +45,8 @@ def main(): try: arguments = parse_command_line(sys.argv) # Do something with arguments. except KeyboardInterrupt: log.error('Program interrupted!') finally: logging.shutdown() -
elmotec revised this gist
Nov 25, 2013 . 1 changed file with 8 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,8 @@ #!/usr/bin/env python # encoding: utf-8 """Minimal python commad line.""" import sys import argparse @@ -15,32 +14,32 @@ def parse_command_line(argv): """Parse command line argument. See -h option :param argv: arguments on the command line must include caller file name. """ formatter_class = argparse.RawDescriptionHelpFormatter parser = argparse.ArgumentParser(description=module, formatter_class=formatter_class) parser.add_argument("--version", action="version", version="%(prog)s {}".format(__version__)) parser.add_argument("-v", "--verbose", dest="verbose_count", action="count", default=0, help="increases log verbosity for each occurence.") parser.add_argument('-o', metavar="output", type=argparse.FileType('w'), default=sys.stdout, help="redirect output to a file") #parser.add_argument('input', metavar="input", ## nargs='+', # argparse.REMAINDER, #help="input if any...") arguments = parser.parse_args(argv[1:]) # Sets log level to WARN going more verbose for each new -v. log.setLevel(max(3 - arguments.verbose_count, 0) * 10) return arguments def main(): """Main program. Sets up logging and do some work.""" logging.basicConfig(stream=sys.stderr, level=logging.DEBUG, format='%(name)s (%(levelname)s): %(message)s')) try: @@ -49,7 +48,5 @@ def main(): finally: logging.shutdown() if __name__ == "__main__": sys.exit(main()) -
elmotec revised this gist
Jul 17, 2013 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,10 +17,9 @@ def parse_command_line(argv): """Parses command line argument. See -h option Arguments: argv: arguments on the command line must include caller file name. """ formatter_class = argparse.RawDescriptionHelpFormatter parser = argparse.ArgumentParser(description=module, formatter_class=formatter_class) -
elmotec revised this gist
Jul 17, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import logging module = sys.modules['__main__'].__file__ log = logging.getLogger(module) def parse_command_line(argv): @@ -41,7 +42,8 @@ def parse_command_line(argv): def main(): logging.basicConfig(stream=sys.stderr, level=logging.DEBUG, format='%(name)s (%(levelname)s): %(message)s')) try: arguments = parse_command_line(sys.argv) # Do something with arguments. -
elmotec renamed this gist
Jul 16, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
elmotec created this gist
Jul 16, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #!/usr/bin/env python """Minimal python commad line.""" __version__ = "1.0" import sys import argparse import logging log = logging.getLogger(__name__) def parse_command_line(argv): """Parses command line argument. See -h option Arguments: argv: arguments on the command line must include caller file name. """ module = argv[0] formatter_class = argparse.RawDescriptionHelpFormatter parser = argparse.ArgumentParser(description=module, formatter_class=formatter_class) parser.add_argument("--version", action="version", version="%(prog)s {}".format(__version__)) parser.add_argument("-v", "--verbose", dest="verbose_count", action="count", default=0, help="increases log verbosity for each occurence.") parser.add_argument('-o', metavar="output", type=argparse.FileType('w'), default=sys.stdout, help="redirect output to a file") #parser.add_argument('input', metavar="input", ## nargs='+', # argparse.REMAINDER, #help="input if any...") arguments = parser.parse_args(argv[1:]) # Sets log level to WARN going more verbose for each new -v. log.setLevel(max(3 - arguments.verbose_count, 0) * 10) return arguments def main(): logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) try: arguments = parse_command_line(sys.argv) # Do something with arguments. finally: logging.shutdown() if __name__ == "__main__": sys.exit(main())