[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-bugs] #9975 [Flashproxy]: use argparse rather than getopt



#9975: use argparse rather than getopt
-------------------------+---------------------
 Reporter:  infinity0    |          Owner:  dcf
     Type:  enhancement  |         Status:  new
 Priority:  minor        |      Milestone:
Component:  Flashproxy   |        Version:
 Keywords:               |  Actual Points:
Parent ID:               |         Points:
-------------------------+---------------------
 Depends on #6810

 We ought to move to argparse rather than hard-code our own. This would
 make it easier to inheritance options between modules, for example
 something like

 {{{
 # in flashproxy.util

 def add_module_opts(parser):
   parser.add_argument("--unsafe_logging", etc)
   old_parse = parser.parse_args
   parser.parse_args = lambda **kwargs:
 _parse_module_opts(old_parse(**kwargs))

 def _parse_module_opts(parsed_opts): # a Namespace object
   if parsed_opts.unsafe_logging:
     # do something
   return parsed_opts
 }}}

 Then in the main script:

 {{{
 def main(argv):
   parser = argparse.ArgumentParser()
   parser.add_argument(app-specific)
   flashproxy.util.add_module_opts(parser)
   ...
   opts = parser.parse_args()
   ...
 }}}

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9975>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs