Changeset 24

Show
Ignore:
Timestamp:
05/29/06 13:34:41 (7 years ago)
Author:
mk
Message:

Decrease score for .pyo files (closes ticket #4).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/cheesecake/cheesecake_index.py

    r23 r24  
    208208        self.INDEX_REQUIRED_FILES = 100 
    209209        self.INDEX_FILE_PYC      = -20 
     210        self.INDEX_FILE_PYO      = -20 
    210211        self.INDEX_DIR_CRITICAL  = 25 
    211212        self.INDEX_DIR           = 20 
     
    233234            "INDEX_INSTALL", "INDEX_FILE_CRITICAL", "INDEX_FILE", 
    234235            "INDEX_REQUIRED_FILES", "INDEX_FILE_PYC", 
     236            "INDEX_FILE_PYO", 
    235237            "INDEX_DIR_CRITICAL", "INDEX_DIR", "INDEX_DIR_EMPTY", 
    236238            "MAX_INDEX_DOCSTRINGS", "MAX_INDEX_PYLINT", 
     
    362364        self.pkg_files = {} 
    363365        self.pkg_dirs = {} 
    364         self.file_types =   ["py", "pyc", "test", 
    365                             ] 
     366        self.file_types = ["py", "pyc", "pyo", "test"] 
    366367        for type in self.file_types: 
    367368            self.pkg_files[type] = [] 
     
    659660                    self.pkg_files["pyc"].append(fullpath) 
    660661                    self.log.debug("pyc file found: " + fullpath) 
     662                elif self.is_pyo_file(file, dirs_in_rootdir): 
     663                    self.pkg_files["pyo"].append(fullpath) 
     664                    self.log.debug("pyo file found: " + fullpath) 
    661665 
    662666        len_pyc_list = len(self.pkg_files["pyc"]) 
     
    664668            self.index["file"].set_index("pyc", value=self.INDEX_FILE_PYC, 
    665669                details="%d .pyc files found" % len_pyc_list) 
     670 
     671        len_pyo_list = len(self.pkg_files["pyo"]) 
     672        if len_pyo_list: 
     673            self.index["file"].set_index("pyo", value=self.INDEX_FILE_PYO, 
     674                details="%d .pyo files found" % len_pyo_list) 
     675 
    666676        self.log.debug("Found %d py files" % len(self.pkg_files["py"])) 
    667         self.log.debug("Found %d pyc files" % len(self.pkg_files["pyc"])) 
     677        self.log.debug("Found %d pyc files" % len_pyc_list) 
     678        self.log.debug("Found %d pyo files" % len_pyo_list) 
    668679        self.log.debug("Found %d test files" % len(self.pkg_files["test"])) 
    669680 
     
    671682 
    672683    def is_pyc_file(self, filename, dirs): 
    673         return has_extension(file, ".pyc") 
    674  
    675     def is_py_file(self, file, dirs): 
     684        return has_extension(filename, ".pyc") 
     685 
     686    def is_pyo_file(self, filename, dirs): 
     687        return has_extension(filename, ".pyo") 
     688 
     689    def is_py_file(self, filename, dirs): 
    676690        """ 
    677691        Return True if file ends with .py and it is not a special file and it is not 
    678692        in special directory 
    679693        """ 
    680         if not has_extension(file, ".py"): 
     694        if not has_extension(filename, ".py"): 
    681695            return False 
    682696        if file in ["setup.py", "ez_setup.py", "__init__.py", "__pkginfo__.py"]: 
  • branches/mk/tests/test_count_files.py

    r23 r24  
    88import _path_cheesecake 
    99from cheesecake.cheesecake_index import Cheesecake 
     10 
     11if 'set' not in dir(__builtins__): 
     12    from sets import Set as set 
    1013 
    1114 
     
    5457        self.cheesecake.walk_pkg() 
    5558 
    56         assert self.cheesecake.pkg_files['py'] == py_files 
     59        assert set(self.cheesecake.pkg_files['py']) == set(py_files) 
    5760        assert self.cheesecake.pkg_files['pyc'] == [] 
     61        assert self.cheesecake.pkg_files['pyo'] == [] 
    5862        assert self.cheesecake.pkg_files['test'] == [] 
    5963 
     64 
     65class TestPycPyoFiles(CountFiles): 
     66    def test_some_pyc_and_pyo_files(self): 
     67        py_files = self.prefix_with_package_name(['main.py']) 
     68        pyc_files = self.prefix_with_package_name(['main.pyc', 'missing.pyc']) 
     69        pyo_files = self.prefix_with_package_name(['main.pyo', 'optimised.pyo']) 
     70 
     71        self.create_files(py_files + pyc_files + pyo_files) 
     72        self.cheesecake.walk_pkg() 
     73 
     74        assert set(self.cheesecake.pkg_files['py']) == set(py_files) 
     75        assert set(self.cheesecake.pkg_files['pyc']) == set(pyc_files) 
     76        assert set(self.cheesecake.pkg_files['pyo']) == set(pyo_files) 
     77        assert self.cheesecake.pkg_files['test'] == []