Patchwork [1,of,2] check-code: do not abort on an unreadable file, only report this

login
register
mail settings
Submitter Simon Heimberg
Date July 13, 2013, 7:10 p.m.
Message ID <089daf84e6c4088633c3.1373742615@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1871/
State Superseded, archived
Headers show

Comments

Simon Heimberg - July 13, 2013, 7:10 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1373741217 -7200
# Node ID 089daf84e6c4088633c39290142694000af25f37
# Parent  2fe7dc2afce4ff87e89180828f18a5c849c962fe
check-code: do not abort on an unreadable file, only report this

Patch

diff -r 2fe7dc2afce4 -r 089daf84e6c4 contrib/check-code.py
--- a/contrib/check-code.py	Sam Jul 13 20:11:47 2013 +0200
+++ b/contrib/check-code.py	Sam Jul 13 20:46:57 2013 +0200
@@ -462,7 +462,11 @@ 
                 print "Skipping %s for %s it doesn't match %s" % (
                        name, match, f)
             continue
-        fp = open(f)
+        try:
+            fp = open(f)
+        except IOError, e:
+            print "Skipping %s, %s" % (f, str(e).split(':', 1)[0])
+            continue
         pre = post = fp.read()
         fp.close()
         if "no-" "check-code" in pre:
diff -r 2fe7dc2afce4 -r 089daf84e6c4 tests/test-check-code.t
--- a/tests/test-check-code.t	Sam Jul 13 20:11:47 2013 +0200
+++ b/tests/test-check-code.t	Sam Jul 13 20:46:57 2013 +0200
@@ -177,8 +177,10 @@ 
   > # this next line is okay
   > raise SomeException(arg1, arg2)
   > EOF
-  $ "$check_code" raise-format.py
+  $ "$check_code" not-existing.py raise-format.py
+  Skipping*not-existing.py* (glob)
   raise-format.py:1:
    > raise SomeException, message
    don't use old-style two-argument raise, use Exception(message)
   [1]
+