Anonymous avatar Anonymous committed 61069bd

code.py simplification + else statements in try/except block

Comments (0)

Files changed (1)

 
 try:
     import pep8
+except ImportError:
+    HAS_PEP8 = False
+else:
     HAS_PEP8 = True
     PEP8_VERSION = tuple([int(x) for x in pep8.__version__.split('.')])
-except ImportError:
-    HAS_PEP8 = False
 
 try:
     import pyflakes.checker
-    HAS_PYFLAKES = True
 except ImportError:
     HAS_PYFLAKES = False
+else:
+    HAS_PYFLAKES = True
 
 try:
     import pyjslint
-    HAS_JSLINT = True
 except ImportError:
     HAS_JSLINT = False
+else:
+    HAS_JSLINT = True
 
 try:
     import pep257
-    HAS_PEP257 = True
 except ImportError:
     HAS_PEP257 = False
+else:
+    HAS_PEP257 = True
 
 
 from hghooks import CheckerManager, re_options
 
 def jslint_check(data, filename):
     output = pyjslint.check_JSLint(data)
-    if len(output) > 0:
+    if output:
         print >> sys.stderr, "%s: problem decoding source" % (filename, )
         print >> sys.stderr, '\n'.join(output)
         return 1
 
 def pep257_check(data, filename):
     output = pep257.check_source(data, filename)
-    if len(output) > 0:
+    if output:
         print >> sys.stderr, '\n'.join([str(out) for out in output])
         return 1
     return 0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.