17d68d00bSMichael Walsh#!/usr/bin/env python 27d68d00bSMichael Walsh 37d68d00bSMichael Walshr""" 4e5391dc4SMichael WalshSee help text for details. 57d68d00bSMichael Walsh""" 67d68d00bSMichael Walsh 77d68d00bSMichael Walshimport sys 87d68d00bSMichael Walsh 96607a28eSMichael Walshsave_dir_path = sys.path.pop(0) 107d68d00bSMichael Walsh 116607a28eSMichael Walshmodules = ['gen_arg', 'gen_print', 'gen_valid'] 126607a28eSMichael Walshfor module in modules: 136607a28eSMichael Walsh exec("from " + module + " import *") 147d68d00bSMichael Walsh 156607a28eSMichael Walshsys.path.insert(0, save_dir_path) 162d8d7f3cSMichael Walsh 177d68d00bSMichael Walshparser = argparse.ArgumentParser( 187d68d00bSMichael Walsh usage='%(prog)s [OPTIONS]', 197d68d00bSMichael Walsh description="%(prog)s will...", 20d0741f8aSMichael Walsh formatter_class=argparse.ArgumentDefaultsHelpFormatter, 217d68d00bSMichael Walsh prefix_chars='-+') 227d68d00bSMichael Walsh 237d68d00bSMichael Walshparser.add_argument( 247d68d00bSMichael Walsh '--whatever', 252d8d7f3cSMichael Walsh default='', 267d68d00bSMichael Walsh help='bla, bla.') 277d68d00bSMichael Walsh 2841dda1b0SMichael Walsh# Populate stock_list with options we want. 297d68d00bSMichael Walshstock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)] 307d68d00bSMichael Walsh 317d68d00bSMichael Walsh 32*ee24ff55SMichael Walshdef exit_function(): 337d68d00bSMichael Walsh r""" 34410b1787SMichael Walsh Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). 357d68d00bSMichael Walsh """ 367d68d00bSMichael Walsh 37410b1787SMichael Walsh # This function will be called by gen_exit_function(). If you have no cleanup to do, you can delete 38410b1787SMichael Walsh # this function altogether. 397d68d00bSMichael Walsh 407d68d00bSMichael Walsh # Your cleanup code here. 417d68d00bSMichael Walsh 427d68d00bSMichael Walsh 437d68d00bSMichael Walshdef validate_parms(): 447d68d00bSMichael Walsh r""" 452d8d7f3cSMichael Walsh Validate program parameters, etc. 467d68d00bSMichael Walsh """ 477d68d00bSMichael Walsh 48410b1787SMichael Walsh # This function will be called by gen_setup(). If you have no validation to do, you can delete this 49410b1787SMichael Walsh # function altogether. 506607a28eSMichael Walsh 512d8d7f3cSMichael Walsh # Your validation code here... 522d8d7f3cSMichael Walsh # valid_value(whatever) 537d68d00bSMichael Walsh 547d68d00bSMichael Walsh 557d68d00bSMichael Walshdef main(): 567d68d00bSMichael Walsh 576607a28eSMichael Walsh gen_setup() 587d68d00bSMichael Walsh 597d68d00bSMichael Walsh # Your code here. 607d68d00bSMichael Walsh 617d68d00bSMichael Walsh 622d8d7f3cSMichael Walshmain() 63