Created
May 27, 2017 23:38
-
-
Save stan1y/e207d0bc773fb8348f4c1b4b5466bad0 to your computer and use it in GitHub Desktop.
Revisions
-
stan1y created this gist
May 27, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import optparse import sys def populate_with_regex(expr): # return list of int ids return [1, 2, 3] def do_business_with_devices_list(lst): print("business: %s" % repr(lst)) def main(): parser = optparse.OptionParser() parser.add_option("--devices", action="append", type="int") parser.add_option("--device-regex", type="string") (options, args) = parser.parse_args() if options.devices_regex: options.devices = populate_with_regex(options.regex) do_business_with_devices_list(options.devices) if __name__ == '__main__': sys.exit(main())