Rev 4201: (jam) Include .pyx files as part of test_source for GPL and Copyright in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Mar 25 02:50:09 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4201
revision-id: pqm at pqm.ubuntu.com-20090325025005-f21q20k8uahh4h9x
parent: pqm at pqm.ubuntu.com-20090325020341-dmq0yek061gtungf
parent: john at arbash-meinel.com-20090324200457-avdxpzoxw2p0yu08
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-03-25 02:50:05 +0000
message:
  (jam) Include .pyx files as part of test_source for GPL and Copyright
  	checks.
modified:
  bzrlib/tests/test_source.py    test_source.py-20051207061333-a58dea6abecc030d
    ------------------------------------------------------------
    revno: 4198.1.1
    revision-id: john at arbash-meinel.com-20090324200457-avdxpzoxw2p0yu08
    parent: pqm at pqm.ubuntu.com-20090324175300-mnu99mqpmjkkzgq6
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Tue 2009-03-24 15:04:57 -0500
    message:
      Include pyrex files in our source testing for GPL and Copyright checks.
    modified:
      bzrlib/tests/test_source.py    test_source.py-20051207061333-a58dea6abecc030d
=== modified file 'bzrlib/tests/test_source.py'
--- a/bzrlib/tests/test_source.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_source.py	2009-03-24 20:04:57 +0000
@@ -110,13 +110,15 @@
                               % source_dir)
         return source_dir
 
-    def get_source_files(self):
+    def get_source_files(self, extensions=None):
         """Yield all source files for bzr and bzrlib
 
         :param our_files_only: If true, exclude files from included libraries
             or plugins.
         """
         bzrlib_dir = self.get_bzrlib_dir()
+        if extensions is None:
+            extensions = ('.py',)
 
         # This is the front-end 'bzr' script
         bzr_path = self.get_bzr_path()
@@ -127,12 +129,16 @@
                 if d.endswith('.tmp'):
                     dirs.remove(d)
             for f in files:
-                if not f.endswith('.py'):
+                for extension in extensions:
+                    if f.endswith(extension):
+                        break
+                else:
+                    # Did not match the accepted extensions
                     continue
                 yield osutils.pathjoin(root, f)
 
-    def get_source_file_contents(self):
-        for fname in self.get_source_files():
+    def get_source_file_contents(self, extensions=None):
+        for fname in self.get_source_files(extensions=extensions):
             f = open(fname, 'rb')
             try:
                 text = f.read()
@@ -176,9 +182,7 @@
                           % filename)
 
     def test_copyright(self):
-        """Test that all .py files have a valid copyright statement"""
-        # These are files which contain a different copyright statement
-        # and that is okay.
+        """Test that all .py and .pyx files have a valid copyright statement"""
         incorrect = []
 
         copyright_re = re.compile('#\\s*copyright.*(?=\n)', re.I)
@@ -188,7 +192,8 @@
             r'.*Canonical Ltd' # And containing 'Canonical Ltd'
             )
 
-        for fname, text in self.get_source_file_contents():
+        for fname, text in self.get_source_file_contents(
+                extensions=('.py', '.pyx')):
             if self.is_copyright_exception(fname):
                 continue
             match = copyright_canonical_re.search(text)
@@ -223,7 +228,7 @@
             self.fail('\n'.join(help_text))
 
     def test_gpl(self):
-        """Test that all .py files have a GPL disclaimer"""
+        """Test that all .py and .pyx files have a GPL disclaimer."""
         incorrect = []
 
         gpl_txt = """
@@ -243,7 +248,8 @@
 """
         gpl_re = re.compile(re.escape(gpl_txt), re.MULTILINE)
 
-        for fname, text in self.get_source_file_contents():
+        for fname, text in self.get_source_file_contents(
+                extensions=('.py', '.pyx')):
             if self.is_license_exception(fname):
                 continue
             if not gpl_re.search(text):
@@ -291,7 +297,8 @@
         illegal_newlines = {}
         long_lines = {}
         no_newline_at_eof = []
-        for fname, text in self.get_source_file_contents():
+        for fname, text in self.get_source_file_contents(
+                extensions=('.py', '.pyx')):
             if not self.is_our_code(fname):
                 continue
             lines = text.splitlines(True)




More information about the bazaar-commits mailing list