[Python-checkins] r76161 - sandbox/trunk/2to3/lib2to3/refactor.py

benjamin.peterson python-checkins at python.org
Mon Nov 9 02:05:37 CET 2009


Author: benjamin.peterson
Date: Mon Nov  9 02:05:37 2009
New Revision: 76161

Log:
simplify condition

Modified:
   sandbox/trunk/2to3/lib2to3/refactor.py

Modified: sandbox/trunk/2to3/lib2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/refactor.py	(original)
+++ sandbox/trunk/2to3/lib2to3/refactor.py	Mon Nov  9 02:05:37 2009
@@ -138,26 +138,23 @@
                 if have_docstring:
                     break
                 have_docstring = True
-            elif tp == token.NAME:
-                if value == u"from":
+            elif tp == token.NAME and value == u"from":
+                tp, value = advance()
+                if tp != token.NAME and value != u"__future__":
+                    break
+                tp, value = advance()
+                if tp != token.NAME and value != u"import":
+                    break
+                tp, value = advance()
+                if tp == token.OP and value == u"(":
                     tp, value = advance()
-                    if tp != token.NAME and value != u"__future__":
-                        break
+                while tp == token.NAME:
+                    if value == u"print_function":
+                        return True
                     tp, value = advance()
-                    if tp != token.NAME and value != u"import":
+                    if tp != token.OP and value != u",":
                         break
                     tp, value = advance()
-                    if tp == token.OP and value == u"(":
-                        tp, value = advance()
-                    while tp == token.NAME:
-                        if value == u"print_function":
-                            return True
-                        tp, value = advance()
-                        if tp != token.OP and value != u",":
-                            break
-                        tp, value = advance()
-                else:
-                    break
             else:
                 break
     except StopIteration:


More information about the Python-checkins mailing list