Created
October 25, 2019 09:04
-
-
Save tedpelas/b2f8513693db32b6333de33e3316fbc4 to your computer and use it in GitHub Desktop.
Skeleton Python3 file template
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 | |
| """ | |
| Module documentation | |
| """ | |
| # Imports | |
| import sys | |
| import logging | |
| import argparse | |
| # Global variables | |
| # Class declarations | |
| # Function declarations | |
| def main(args): | |
| return 0 | |
| # Main body | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(prog=sys.argv[0]) | |
| # Optional arguments | |
| parser.add_argument('-v', '--verbose', help='Show verbose messages', action='count', default=0) | |
| # Positional arguments | |
| # parser.add_argument('file', help='Input file', type=file) | |
| args = parser.parse_args() | |
| if args.verbose == 1: | |
| logging.getLogger().setLevel(logging.INFO) | |
| elif args.verbose == 2: | |
| logging.getLogger().setLevel(logging.DEBUG) | |
| try: | |
| sys.exit(main(args)) | |
| except Exception as exc: | |
| logging.error('Error in main: %s', exc, exc_info=args.verbose) | |
| sys.exit(-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment