Last active
May 9, 2018 16:44
-
-
Save craig8/42f53b59204310bc6fdec0dd5ec4d14a to your computer and use it in GitHub Desktop.
python main module 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
import argparse | |
import logging | |
import sys | |
LOG_FORMAT = "%(asctime)s:%(levelname)s:%(processName)s - %(name)s %(message)s" | |
logging.basicConfig(stream=sys.stdout, level=logging.INFO, | |
format=LOG_FORMAT) | |
_log = logging.getLogger("main") | |
def get_opts(): | |
parser = argparse.ArgumentParser() | |
# Add arguments to parse | |
#parser.add_argument('--output-dir', default="crate_output", | |
# help="Root directory to output data to.") | |
#parser.add_argument('--start-date', required=True, | |
# help="Date to start the export from.") | |
#parser.add_argument('--days', default=1, type=int, | |
# help="Days to export from the start date") | |
#parser.add_argument('--gzip', default=False, action='store_true', | |
# help="Output files should be gzip strings.") | |
#parser.add_argument('--topics-file', required=True, | |
# type=argparse.FileType('r'), | |
# help="List of topics to extract from the database.") | |
# Parse arguments and validate the opts if necessary below. | |
opts = parser.parse_args() | |
# Extra Validation here | |
# | |
return opts | |
def _main(): | |
# Retrieve options from passed arguments to the program | |
opts = get_opts() | |
# Main body of program here | |
sys.exit(0) | |
if __name__ == "__main__": | |
_main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment