Last active
January 8, 2022 17:43
Revisions
-
ssokolow revised this gist
Jul 10, 2013 . 1 changed file with 9 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 @@ -14,11 +14,17 @@ if __name__ == '__main__': from optparse import OptionParser parser = OptionParser(version="%%prog v%s" % __version__, usage="%prog [options] <argument> ...", description=__doc__.replace('\r\n', '\n').split('\n--snip--\n')[0]) parser.add_option('-v', '--verbose', action="count", dest="verbose", default=2, help="Increase the verbosity. Use twice for extra effect") parser.add_option('-q', '--quiet', action="count", dest="quiet", default=0, help="Decrease the verbosity. Use twice for extra effect") #Reminder: %default can be used in help strings. # Allow pre-formatted descriptions parser.formatter.format_description = lambda description: description opts, args = parser.parse_args() -
ssokolow revised this gist
Jul 8, 2011 . 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 @@ -17,7 +17,7 @@ parser = OptionParser(description=__doc__, version="%%prog v%s" % __version__) parser.add_option('-v', '--verbose', action="count", dest="verbose", default=2, help="Increase the verbosity. Can be used twice for extra effect.") parser.add_option('-q', '--quiet', action="count", dest="quiet", default=0, help="Decrease the verbosity. Can be used twice for extra effect.") opts, args = parser.parse_args() -
ssokolow revised this gist
Jul 8, 2011 . 2 changed files with 32 additions and 21 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,21 +0,0 @@ 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,32 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """[application description here]""" __appname__ = "[application name here]" __author__ = "Stephan Sokolow (deitarion/SSokolow)" __version__ = "0.0pre0" __license__ = "GNU GPL 3.0 or later" import logging log = logging.getLogger(__name__) # -- Code Here -- if __name__ == '__main__': from optparse import OptionParser parser = OptionParser(description=__doc__, version="%%prog v%s" % __version__) parser.add_option('-v', '--verbose', action="count", dest="verbose", default=2, help="Increase the verbosity. Can be used twice for extra effect.") parser.add_option('-q', '--verbose', action="count", dest="quiet", default=0, help="Decrease the verbosity. Can be used twice for extra effect.") opts, args = parser.parse_args() # Set up clean logging to stderr log_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG] opts.verbose = min(opts.verbose - opts.quiet, len(log_levels) - 1) opts.verbose = max(opts.verbose, 0) logging.basicConfig(level=log_levels[opts.verbose], format='%(levelname)s: %(message)s') -
ssokolow created this gist
Jul 21, 2009 .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,21 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """[application description here]""" __appname__ = "[application name here]" __author__ = "Stephan Sokolow (deitarion/SSokolow)" __version__ = "0.0pre0" __license__ = "GNU GPL 3.0 or later" import logging logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') # -- Code Here -- if __name__ == '__main__': from optparse import OptionParser parser = OptionParser(description=__doc__, version="%%prog v%s" % __version__) #parser.add_option('-v', '--verbose', action="store_true", dest="verbose", # default=False, help="Increase verbosity") opts, args = parser.parse_args()