-
-
Save simrit1/92a1aee5d3524d9ebdb349dbe4821c70 to your computer and use it in GitHub Desktop.
This is the source to my video: https://youtu.be/7XJMe8q6JZE
This file contains 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
import logging | |
from argparse import ArgumentParser | |
logger = logging.getLogger(__name__) | |
def data(): | |
logger.info('run data func') | |
def video(): | |
logger.info('run video func') | |
def setup_logger(level=0): | |
logger = logging.getLogger() | |
levels = [logging.WARNING, logging.INFO, logging.DEBUG] | |
level = levels[level or 0] | |
logger.setLevel(level) | |
ch = logging.StreamHandler() | |
ch.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) | |
logger.addHandler(ch) | |
def main(): | |
funcs = { | |
'data': data, | |
'video': video, | |
} | |
parser = ArgumentParser() | |
parser.add_argument('-v', '--verbose', action='count') | |
parser.add_argument('action', nargs='?', choices=funcs.keys()) | |
args = parser.parse_args() | |
setup_logger(args.verbose) | |
funcs.get(args.action, parser.print_help)() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment