diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
commit | a73a964e51247ed169d322c725a3a18859f109a3 (patch) | |
tree | 3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Doc/lib/required_2.py | |
parent | e64efe273fcb921a61bf27d33b230c4e64fcd425 (diff) |
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Doc/lib/required_2.py')
-rwxr-xr-x | sys/src/cmd/python/Doc/lib/required_2.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/sys/src/cmd/python/Doc/lib/required_2.py b/sys/src/cmd/python/Doc/lib/required_2.py deleted file mode 100755 index 421514af0..000000000 --- a/sys/src/cmd/python/Doc/lib/required_2.py +++ /dev/null @@ -1,41 +0,0 @@ -import optparse - -class Option (optparse.Option): - ATTRS = optparse.Option.ATTRS + ['required'] - - def _check_required (self): - if self.required and not self.takes_value(): - raise OptionError( - "required flag set for option that doesn't take a value", - self) - - # Make sure _check_required() is called from the constructor! - CHECK_METHODS = optparse.Option.CHECK_METHODS + [_check_required] - - def process (self, opt, value, values, parser): - optparse.Option.process(self, opt, value, values, parser) - parser.option_seen[self] = 1 - - -class OptionParser (optparse.OptionParser): - - def _init_parsing_state (self): - optparse.OptionParser._init_parsing_state(self) - self.option_seen = {} - - def check_values (self, values, args): - for option in self.option_list: - if (isinstance(option, Option) and - option.required and - not self.option_seen.has_key(option)): - self.error("%s not supplied" % option) - return (values, args) - - -parser = OptionParser(option_list=[ - Option("-v", action="count", dest="verbose"), - Option("-f", "--file", required=1)]) -(options, args) = parser.parse_args() - -print "verbose:", options.verbose -print "file:", options.file |