Changeset 100
- Timestamp:
- 07/21/06 17:30:39 (2 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r99 r100 352 352 value = -1 353 353 details = "" 354 advices = "" 354 355 355 356 def __init__(self, *indices): … … 496 497 return self._indices_dict[name] 497 498 499 def get_advices(self): 500 if self.subindices: 501 return ''.join(map(lambda index: index.get_advices(), self.subindices)) 502 return self.advices 503 498 504 ################################################################################ 499 505 ## Index that computes scores based on files and directories. … … 504 510 self.possibilities = possibilities 505 511 def __str__(self): 506 return ' one of %s' % (self.possibilities,)512 return '/'.join(map(lambda x: str(x), self.possibilities)) 507 513 508 514 def WithOptionalExt(name, extensions): … … 552 558 553 559 return 0 560 561 def get_not_used(self, files_rules): 562 """Get only these of files_rules that didn't match during computation. 563 564 >>> rules = { 565 ... Doc('readme'): 30, 566 ... OneOf(Doc('license'), Doc('copying')): 30, 567 ... 'demo': 10, 568 ... } 569 >>> index = FilesIndex() 570 >>> index._used_rules.append('demo') 571 >>> map(lambda x: str(x), index.get_not_used(rules.keys())) 572 ['license/license.html/license.txt/copying/copying.html/copying.txt', 'readme/readme.html/readme.txt'] 573 """ 574 return filter(lambda rule: rule not in self._used_rules, 575 files_rules) 554 576 555 577 def match_filename(self, name, rule): … … 769 791 (files_count, dirs_count) 770 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') 803 771 804 return self.value 772 805 … … 1186 1219 logger.setconsumer('null', None) 1187 1220 1188 if self.verbose: 1189 self.log = logger.MultipleProducer('cheesecake console') 1190 else: 1191 self.log = logger.MultipleProducer('cheesecake logfile') 1192 1221 self.log = logger.MultipleProducer('cheesecake logfile') 1193 1222 self.log.info = logger.MultipleProducer('cheesecake logfile') 1194 1223 self.log.debug = logger.MultipleProducer('cheesecake logfile') … … 1505 1534 max_cheesecake_index, 1506 1535 percentage) 1536 1537 if self.verbose: 1538 print 1539 print self.index.get_advices(), 1507 1540 1508 1541 return cheesecake_index
