Skip to content

Instantly share code, notes, and snippets.

@stan1y
Created May 27, 2017 23:38
Show Gist options
  • Select an option

  • Save stan1y/e207d0bc773fb8348f4c1b4b5466bad0 to your computer and use it in GitHub Desktop.

Select an option

Save stan1y/e207d0bc773fb8348f4c1b4b5466bad0 to your computer and use it in GitHub Desktop.

Revisions

  1. stan1y created this gist May 27, 2017.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original 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())