From 0dbd46680a7fac7ac74c2945e23b95dd04ff79dc Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Thu, 25 Apr 2013 17:08:56 +0200 Subject: giscanner: simplify the MainTransformer().transform() method The ast.Namespace.names instance attribute is an OrderedDict which itself is a specialised dict() subclass. There are any number of ways to test if a dict() is empty or not. Creating a copy of it's keys by iterating over them just to count the number of items in the copy is not the most elegant way though. https://bugzilla.gnome.org/show_bug.cgi?id=699533 --- giscanner/maintransformer.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 6cf5a006..d2a8be7b 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -48,12 +48,10 @@ class MainTransformer(object): # Public API def transform(self): - contents = list(self._namespace.itervalues()) - if len(contents) == 0: - message.fatal("""Namespace is empty; likely causes are: -* Not including .h files to be scanned -* Broken --identifier-prefix -""") + if not self._namespace.names: + message.fatal('Namespace is empty; likely causes are:\n' + '* Not including .h files to be scanned\n' + '* Broken --identifier-prefix') # Some initial namespace surgery self._namespace.walk(self._pass_fixup_hidden_fields) -- cgit v1.2.1