-
-
Save stvemillertime/28af36c3e6e1e9eda2daf5e86119cb39 to your computer and use it in GitHub Desktop.
Boilerplate Python script
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 | |
| import argparse | |
| import sys | |
| import json | |
| import logging | |
| logging.basicConfig( level=logging.ERROR, | |
| format='%(asctime)s %(levelname)-8s %(message)s', | |
| datefmt='%Y-%m-%dT%H:%M:%S', | |
| handlers={logging.StreamHandler(sys.stderr)}) | |
| def parseArguments(): | |
| parser = argparse.ArgumentParser(description="Arguments for script") | |
| parser.add_argument('files', nargs='+') | |
| parser.add_argument('-v', '--verbose', action='store', default=None, help='If specified, output verbose input') | |
| args = parser.parse_args() | |
| if args.verbose != None: | |
| newLevel = getattr(logging, args.verbose.upper(), None) | |
| if isinstance(newLevel, int): | |
| logging.getLogger().setLevel(newLevel) | |
| return args | |
| def main(): | |
| args = parseArguments() | |
| if __name__ == '__main__': | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment