setup main

This commit is contained in:
2020-07-24 21:40:33 +02:00
parent 83b6da6ced
commit d33f45d87d
3 changed files with 45 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/.project
/.pydevproject

0
src/scraper/__init__.py Normal file
View File

43
src/scraper/__main__.py Normal file
View File

@@ -0,0 +1,43 @@
#!python3
# Created Jul 24, 2020
# @author: andreas
""" Module: Main Template """
from argparse import ArgumentParser
import logging
import sys
import os
LOG = logging.getLogger(__name__)
def cli(argv=None):
# command line interface
if argv is None:
argv = sys.argv
LOG.info("%s %s", os.path.basename(argv[0]), " ".join(argv[1:]))
parser = ArgumentParser(description="Module Template")
parser.add_argument("--action", help="mock action verb")
parser.add_argument("--database", help="database connection")
parser.add_argument("--config_file", help="json filepath, not used by mock")
args = parser.parse_args(argv[1:])
argd = vars(args)
# arguments
for k, v in argd.items():
print(k, v)
# enviroment
for k, v in os.environ.items():
print(k, v)
# feature
LOG.info("Hello world!")
LOG.info("done")
return 0
if __name__ == "__main__":
logging.Formatter.default_time_format = '%H:%M:%S'
logging.Formatter.default_msec_format = '%s.%03d'
logging.basicConfig(level=logging.INFO,
format='%(asctime)s [%(process)i] %(levelname).4s %(module)s.%(funcName)s: %(message)s')
sys.exit(cli())