From 4aa89d35a0108035486b7b41e236cc9a5aab8a62 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Tue, 18 Oct 2005 16:30:25 +0000 Subject: [PATCH] Correct deprecated attribute so warnings are thrown when a deprecated option is seen, not when it's defined. --- ChangeLog | 10 ++++++++++ pykickstart/parser.py | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3af420a..626f356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-10-18 Chris Lumens + + * pykickstart/parser.py: Correct deprecated attribute so warnings are + thrown when a deprecated option is seen, not when it's defined. + +2005-10-17 Chris Lumens + + * docs/programmers-guide: Added documentation for extending and + programming with pykickstart. + 2005-10-13 Chris Lumens * pykickstart.spec: Correct python lib directory on 64-bit archs diff --git a/pykickstart/parser.py b/pykickstart/parser.py index 9f73d34..8988de7 100644 --- a/pykickstart/parser.py +++ b/pykickstart/parser.py @@ -83,9 +83,13 @@ class KSOptionParser(OptionParser): def check_values (self, values, args): for option in self.option_list: - if (isinstance(option, Option) and option.required and + if (isinstance(option, Option) and option.required and \ not self.option_seen.has_key(option)): raise KickstartError, "Option %s is required" % option + elif isinstance(option, Option) and option.deprecated and \ + self.option_seen.has_key(option): + warnings.warn("Ignoring deprecated option: %s" % option, + DeprecationWarning) return (values, args) @@ -132,11 +136,9 @@ class MappableOption(RequiredOption): class DeprecatedOption(MappableOption): ATTRS = MappableOption.ATTRS + ['deprecated'] - def _check_deprecated (self): - if self.deprecated: - warnings.warn("Ignoring deprecated option: %s" % self.get_opt_string(), DeprecationWarning) - - CHECK_METHODS = MappableOption.CHECK_METHODS + [_check_deprecated] + def process (self, opt, value, values, parser): + MappableOption.process(self, opt, value, values, parser) + parser.option_seen[self] = 1 ### ### SCRIPT HANDLING -- 2.11.4.GIT