-
-
Save simonsan/072f580cf254f8d798e8c1dbe611e53a to your computer and use it in GitHub Desktop.
The raw/initial output from "boiler" in my ~/.vim/snippets/python.snippets
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 characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """[application description here]""" | |
| # Prevent Python 2.x PyLint from complaining if run on this | |
| from __future__ import (absolute_import, division, print_function, | |
| with_statement, unicode_literals) | |
| __author__ = "Stephan Sokolow (deitarion/SSokolow)" | |
| __appname__ = "[application name here]" | |
| __version__ = "0.0pre0" | |
| __license__ = "GNU GPL 3.0 or later" | |
| import logging | |
| log = logging.getLogger(__name__) | |
| def process_arg(path): | |
| pass # TODO: Code Here | |
| def main(): | |
| """The main entry point, compatible with setuptools entry points.""" | |
| from argparse import ArgumentParser, RawDescriptionHelpFormatter | |
| parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, | |
| description=__doc__.replace('\r\n', '\n').split('\n--snip--\n')[0]) | |
| parser.add_argument('--version', action='version', | |
| version="%%(prog)s v%s" % __version__) | |
| parser.add_argument('-v', '--verbose', action="count", | |
| default=2, help="Increase the verbosity. Use twice for extra effect.") | |
| parser.add_argument('-q', '--quiet', action="count", | |
| default=0, help="Decrease the verbosity. Use twice for extra effect.") | |
| parser.add_argument('path', action="store", nargs="+", | |
| help="Path to operate on") | |
| # Reminder: %(default)s can be used in help strings. | |
| args = parser.parse_args() | |
| # Set up clean logging to stderr | |
| log_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING, | |
| logging.INFO, logging.DEBUG] | |
| args.verbose = min(args.verbose - args.quiet, len(log_levels) - 1) | |
| args.verbose = max(args.verbose, 0) | |
| logging.basicConfig(level=log_levels[args.verbose], | |
| format='%(levelname)s: %(message)s') | |
| for path in args.path: | |
| process_arg(path) | |
| if __name__ == '__main__': | |
| main() | |
| # vim: set sw=4 sts=4 expandtab : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment