Changeset 101

Show
Ignore:
Timestamp:
07/22/06 11:49:34 (2 years ago)
Author:
mk
Message:

Fixed a bug in IndexRequiredFiles? compute method (thanks to Will Guaraldi for report and solution).

Files:

Legend:

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

    r100 r101  
    352352    value = -1 
    353353    details = "" 
    354     advices = "" 
     354    info = "" 
    355355 
    356356    def __init__(self, *indices): 
     
    497497        return self._indices_dict[name] 
    498498 
    499     def get_advices(self): 
     499    def get_info(self): 
    500500        if self.subindices: 
    501             return ''.join(map(lambda index: index.get_advices(), self.subindices)) 
    502         return self.advices 
     501            return ''.join(map(lambda index: index.get_info(), self.subindices)) 
     502        return self.info 
    503503 
    504504################################################################################ 
     
    783783 
    784784    def compute(self, files_list, dirs_list, package_dir): 
     785        # Inform user of files and directories the package is missing. 
     786        def make_info(dictionary, what): 
     787            missing = self.get_not_used(dictionary.keys()) 
     788            importance = {30: ' critical', 20: ' important', 10: ''} 
     789            info = [] 
     790 
     791            positive_msg = "[%s] Package has%s %s: %s.\n" 
     792            negative_msg = "[%s] Package doesn't have%s %s: %s.\n" 
     793 
     794            for key in dictionary.keys(): 
     795                msg = positive_msg 
     796                if key in missing: 
     797                    msg = negative_msg 
     798                info.append(msg % (index_class_to_name(self.name), importance[dictionary[key]], what, str(key))) 
     799 
     800            return ''.join(info) 
     801 
     802        # Compute required files. 
    785803        files_count, files_value = self._compute_from_rules(files_list, package_dir, self.cheese_files) 
     804        self.info = make_info(self.cheese_files, 'file') 
     805 
     806        # Compute required directories. 
    786807        dirs_count, dirs_value = self._compute_from_rules(dirs_list, package_dir, self.cheese_dirs) 
     808        self.info += make_info(self.cheese_dirs, 'directory') 
    787809 
    788810        self.value = files_value + dirs_value 
     
    790812        self.details = "%d files and %d required directories found" % \ 
    791813                       (files_count, dirs_count) 
    792  
    793         # Inform user of files and directories the package is missing. 
    794         def make_advices(dictionary, what): 
    795             missing = self.get_not_used(dictionary.keys()) 
    796             importance = {30: ' critical', 20: ' important', 10: ''} 
    797             return ''.join(map(lambda miss: "Package don't have%s %s: %s.\n" % \ 
    798                                  (importance[dictionary[miss]], what, str(miss)), 
    799                                  missing)) 
    800  
    801         self.advices = make_advices(self.cheese_files, 'file') +\ 
    802                        make_advices(self.cheese_dirs, 'directory') 
    803814 
    804815        return self.value 
     
    15371548            if self.verbose: 
    15381549                print 
    1539                 print self.index.get_advices(), 
     1550                print self.index.get_info(), 
    15401551 
    15411552        return cheesecake_index