Package linda :: Module err_print
[hide private]

Source Code for Module linda.err_print

 1  import os, linda 
 2  from linda import clparser 
 3  from linda.debug import dprint 
 4  from linda.output import OutputException 
 5  from linda.parser.debfilename import DebFilenameParser 
 6   
7 -class PrintErrors:
8 - def __init__(self, file):
9 debfn = DebFilenameParser(file) 10 self.pkg_name = debfn.package 11 self.data = {}
12
13 - def print_error(self, errs, data_file):
14 for err_dict in errs.keys(): 15 dprint(_("Printing data from %s.") % err_dict) 16 sorted_keys = errs[err_dict].keys() 17 sorted_keys.sort() 18 for tag in sorted_keys: 19 errs[err_dict][tag].sort() 20 if data_file.has_key(err_dict) and \ 21 data_file[err_dict].has_key(tag): 22 onechar = self.get_single(data_file[err_dict][tag]['Type']) 23 else: 24 raise ErrorPrintingException("%s doesn't exist in %s!" % (tag, \ 25 err_dict)) 26 if onechar not in clparser['types']: 27 dprint(_("Told to skip type %s.") % \ 28 data_file[err_dict][tag]['Type']) 29 continue 30 for data in errs[err_dict][tag]: 31 try: 32 linda.outputobj.print_out(tag, data, \ 33 data_file[err_dict][tag], self.pkg_name) 34 except OutputException, e: 35 raise ErrorPrintingException(e)
36
37 - def get_single(self, str):
38 is_up = map(lambda x: x.isupper(), str) 39 if reduce(lambda x, y: x + y, is_up): 40 return str[is_up.index(True)] 41 return ''
42
43 -class ErrorPrintingException(Exception):
44 pass
45