-
-
Save 4e1e0603/a8ae67774c8fb6b2fc8447fd3db91c64 to your computer and use it in GitHub Desktop.
Python __main__.py parser example
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 data2tabshop | |
# from data2tabshop import __version__ | |
__version__ = '0.1.0' | |
__author__ = u'Steffen Exler' | |
def get_parser(): | |
""" | |
Creates a new argument parser. | |
""" | |
parser = argparse.ArgumentParser('Data2TabShop') | |
version = '%(prog)s ' + __version__ | |
parser.add_argument('--version', '-v', action='version', version=version) | |
parser.add_argument('--loadDatabase', '-l', type=load_database, | |
help='Load a File to Google Spreadsheet: -l data.xml', ) | |
return parser | |
def load_database(file): | |
print("File will be loaded") | |
print(file) | |
def main(args=None): | |
""" | |
Main entry point for your project. | |
Args: | |
args : list | |
A of arguments as if they were input in the command line. Leave it | |
None to use sys.argv. | |
""" | |
parser = get_parser() | |
args = parser.parse_args(args) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment