def test_invalidArgs(self): rules = ( ('Ben', 'John', 'Peter'), {'Pence': 55, 'Beal': 100, 'Woods': 1000}, ['Swimmer', 'Commander', 'Artist'] ) usage = "Usage: %s {Ben|John|Peter} {Pence|Beal|Woods} {Swimmer|Commander|Artist}" self.assertTrue( not fi.invalidArgs( ('test test', 'Ben', 'Pence', 'Swimmer'), rules ) ) self.assertEqual( fi.invalidArgs( ('hey look at me', 'JJJ', 'Pence', 'Swimmer'), rules )(), usage % 'hey look at me' ) self.assertEqual( fi.invalidArgs( ['my test program'], rules )(), usage % 'my test program' )
def main(): usage = fi.invalidArgs( sys.argv, (modules, actions), ) if usage: print usage exit(1) module, action = sys.argv[:2] # Perform action actions[action](module)
def main(): modules = { 'server': (doDatabase, ), 'client': (), } actions = ( 'install', 'uninstall', ) usage = fi.invalidArgs(sys.argv, (modules, actions)) if usage: print usage() exit(1) for func in fi.chain(doPathload, doPaths, modules[sys.argv[1]], doLogs): func(sys.argv[2])
def main(): modules = { 'server': ( doDatabase, ), 'client': (), } actions = ( 'install', 'uninstall', ) usage = fi.invalidArgs( sys.argv, (modules, actions) ) if usage: print usage() exit(1) for func in fi.chain(doPathload, doPaths, modules[sys.argv[1]], doLogs): func(sys.argv[2])