An iterator over option registration args.

Review Request #2478 — Created July 13, 2015 and submitted

benjyw
pants
20d1126...
pants-reviews
stuhood

See code comments for details.

To use in a task:

for name, args, kwargs in self.context.options.registration_args_iter_for_scope(self.options_scope):
if <some condition on args/kwargs>:
value = self.get_options()[name]
... do stuff with value ...

CI passes apart from unrelated codegen issue: https://travis-ci.org/pantsbuild/pants/builds/70832969

  • 0
  • 0
  • 0
  • 1
  • 1
Description From Last Updated
BE
CG
  1. 
      
  2. src/python/pants/option/parser.py (Diff revision 1)
     
     

    Cool, so self.context.options.for_scope(self.options_scope)[dest] will get us the value, and kwargs['fingerprint'] will indicate whether to include it in the task identity.

    1. Exactly, except that in a task you don't need to do self.context.options.for_scope(self.options_scope), you can just do self.get_options().

      See the description of this CR for an example.

      Also, parser.py will have to know to remove the 'fingerprint' kwarg before passing kwargs to argparse. It already does this for several other special args.

  3. 
      
CG
  1. Ship It!
  2. 
      
ST
  1. Looks good. Thanks again Benjy.

  2. 
      
BE
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as 5e0937f81ce8e327c13c79299518351b1b1f80d2.

Loading...