Created
January 28, 2015 10:22
-
-
Save krzyspmac/a7b3fbc2dcccf0ea6a7e to your computer and use it in GitHub Desktop.
Basic Python Command Line Parameter Parser
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
#!/usr/bin/python | |
import getopt | |
import os, sys | |
path = False | |
# | |
# usage | |
# | |
def usage(): | |
print " ConvertFileToByteArray -f <filename>" | |
pass | |
# | |
# config setup | |
# | |
def ConfigSetup(argv): | |
global path | |
try: | |
opts, args = getopt.getopt(argv, "f:h", ["file=", "help"]) | |
except getopt.GetoptError: | |
usage() | |
sys.exit(2) | |
for opt, arg in opts: | |
if opt in ("-h", "--help"): | |
usage() | |
sys.exit() | |
pass | |
elif opt in ("-f", "--file"): | |
path = arg | |
pass | |
pass # for | |
pass | |
# | |
# main | |
# | |
def main(argv): | |
# Setup | |
ConfigSetup(argv) | |
pass | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment