Created
May 13, 2022 11:45
-
-
Save notareverser/cc834acc64fa15b9e9258261b0ca8ab3 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