optParser= OptionParser() [ optParser.add_option(opt) for opt in [ make_option('-s', '--shapes', default= None, help= 'json file containing the shapes') ]] opts, args= optParser.parse_args() # if shape file was not pased in, display error and usage if opts.shapes == None: print >> stderr, "--shape=<filename> argument required" optParser.print_help() exit(-1) return args, opts if __name__ == '__main__': # parse cmd line args (args, opts)= parse_args(argv) # load the json file properties= load(open(opts.shapes, 'r')) # process our geometry plane geometry= Geometry(**properties.get('geometry')) for relation in geometry.relations(): print relation