From e90c00fa351e303400529ef1554751f73b34090c Mon Sep 17 00:00:00 2001 From: ?ric Araujo Date: Thu, 9 Dec 2010 03:35:18 +0100 Subject: Fix attribute error --- distutils2/command/cmd.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'distutils2/command/cmd.py') diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index 2bc5546..382acb5 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -165,7 +165,10 @@ class Command(object): header = "command options for '%s':" % self.get_command_name() self.announce(indent + header, level=log.INFO) indent = indent + " " + negative_opt = getattr(self, 'negative_opt', ()) for (option, _, _) in self.user_options: + if option in negative_opt: + continue option = option.replace('-', '_') if option[-1] == "=": option = option[:-1] -- cgit v1.2.1 From 37d72aef1b216abd0840afd73c114bad25621a39 Mon Sep 17 00:00:00 2001 From: ?ric Araujo Date: Thu, 10 Feb 2011 00:51:42 +0100 Subject: Use lazy form in logging calls, again. Logging calls have the signature (msg, *args, **kwargs) so that the %-formatting can be delayed until it is needed. Logger objects also have an isEnabledFor method that can be used to isolate expensive code. Next steps: use only one of d2.logger methods or logging module functions; use a proper handler in our test machinery instead of monkey-patching; remove cmd.warn and cmd.announce and use logging instead. TODOs have been added in the modules and on the wiki. --- distutils2/command/cmd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'distutils2/command/cmd.py') diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index 0e4d99e..e91d924 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -182,6 +182,7 @@ class Command(object): raise RuntimeError( "abstract method -- subclass %s must override" % self.__class__) + # TODO remove this method, just use logging def announce(self, msg, level=logging.INFO): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. @@ -363,8 +364,9 @@ class Command(object): # -- External world manipulation ----------------------------------- + # TODO remove this method, just use logging def warn(self, msg): - logger.warning("warning: %s: %s\n" % (self.get_command_name(), msg)) + logger.warning("warning: %s: %s\n", self.get_command_name(), msg) def execute(self, func, args, msg=None, level=1): util.execute(func, args, msg, dry_run=self.dry_run) -- cgit v1.2.1 From 0d8fcc59e85ef42479dea9128bb051aca9dade14 Mon Sep 17 00:00:00 2001 From: ?ric Araujo Date: Thu, 10 Feb 2011 01:48:09 +0100 Subject: More logging tweaks: use real warning method, merge some calls. --- distutils2/command/cmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'distutils2/command/cmd.py') diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index e91d924..9cfc5d9 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -182,7 +182,7 @@ class Command(object): raise RuntimeError( "abstract method -- subclass %s must override" % self.__class__) - # TODO remove this method, just use logging + # TODO remove this method, just use logging.info def announce(self, msg, level=logging.INFO): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. @@ -364,7 +364,7 @@ class Command(object): # -- External world manipulation ----------------------------------- - # TODO remove this method, just use logging + # TODO remove this method, just use logging.warn def warn(self, msg): logger.warning("warning: %s: %s\n", self.get_command_name(), msg) -- cgit v1.2.1