diff Generic/fiebdc.py @ 25:189f8274aecd

gui. switch navigation menu on switch page
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Mon, 20 May 2019 13:18:33 +0200
parents 65e7ae0d0e63
children 16f91684686b
line wrap: on
line diff
--- a/Generic/fiebdc.py	Fri May 03 11:11:00 2019 +0200
+++ b/Generic/fiebdc.py	Mon May 20 13:18:33 2019 +0200
@@ -147,27 +147,39 @@
         if it is posible return a valid code else return a empty string.
         """
         if not isinstance(code, unicode):
-            print(_("Invalid code, it must be a unicode string") )
+            _str = _("Invalid code, it must be a unicode string")
+            print(_str.encode("utf-8") )
             return u""
         # Valid chararcter: A-Z a-z 0-9 ñ Ñ . $ # % & _ 
         # "valid_code" : "[^A-Za-z0-9ñÑ.$#%&_]"
         _ucode = self.__pattern["valid_code"].sub(u"_", code)
         if _ucode != code:
             try:
-                print(utils.mapping(_("The code '$1' have invalid characters, replaced by '$2'."),
-                               (code.encode("utf8"),_ucode.encode("utf8"))) )
+                _tstr = _("The code '$1' have invalid characters," \
+                         " replaced by '$2'.")
+                print(utils.mapping(_tstr, (code.encode("utf8"),
+                                    _ucode.encode("utf8"))) )
             except:
-                print(utils.mapping(_("The code '$1' have invalid characters and can not be encoded in utf8."), (code,)) )
+                _tstr = _("The code '$1' have invalid characters and can not" \
+                         " be encoded in utf8.")
+                print(utils.mapping(_tstr, (code,)).encode("utf-8") )
             
             if len(_ucode) == 0:
-                _normalize_code = ''.join((c for c in unicodedata.normalize('NFD', _ucode) if unicodedata.category(c) != 'Mn'))
-                # from http://www.leccionespracticas.com/uncategorized/eliminar-tildes-con-python-solucionado/
+                _normalize_code = ""
+                for c in unicodedata.normalize('NFD', _ucode):
+                    if unicodedata.category(c) != 'Mn':
+                        _normalize_code.join(c)
+                #_normalize_code = ''.join((c for c in unicodedata.normalize(
+                # 'NFD', _ucode) if unicodedata.category(c) != 'Mn'))
+                # from http://www.leccionespracticas.com/uncategorized/
+                #      eliminar-tildes-con-python-solucionado/
                 _ucode = self.__pattern["valid_code"].sub(u"", _normalize_code)
                 if len(_ucode) == 0:
                     _hash_code = hashlib.sha256()
                     _hash_code.update(code.encode('utf-8'))
                     _hexdigest_code = _hash_code.hexdigest()
-                    _ucode = self.__pattern["valid_code"].sub(u"", _hexdigest_code)
+                    _p_valid_code = self.__pattern["valid_code"]
+                    _ucode = _p_valid_code.sub(u"", _hexdigest_code)
             code = _ucode
         if code == u"##":
             # root code is an empty code : set to ROOT
@@ -185,7 +197,8 @@
             # only one charecter # % or &
             if sum([code.count(c) for c in u'#%&']) > 1:
                 print(utils.mapping(_("The code '$1' contains special "\
-                                      "characters repeated."),(code.encode("utf8"),)) )
+                      "characters repeated."),
+                      (code.encode("utf8"),)).encode("utf-8") )
                 _i = min([code.find(c) for c in u'#%&'])
                 code = code[:_i+1] + \
                         self.__pattern["special_char"].sub(u"", code[_i+1:])
@@ -388,7 +401,8 @@
             self.__statistics.A += 1
             self._parseA(_field_list)
         else:
-            print(utils.mapping(_("FIEBDC. Unknow record: $1"),(record[:100],)))
+            print(utils.mapping(_("FIEBDC. Unknow record: $1"),
+                                  (record[:100],)).encode("utf-8"))
             self.__statistics.unknow += 1
 
     def _parseV(self, field_list):
@@ -409,9 +423,10 @@
         if self.__statistics.records != 1:
             print(utils.mapping(_("The 'V' record (Property and Version) "\
                     "must be the first record in the file but it is the "\
-                    "number: $1"), (str(self.__statistics.records),)) )
+                    "number: $1"),
+                    (str(self.__statistics.records),)).encode("utf-8") )
             print(_("The default values were taken and this V record is "\
-                  "ignored") )
+                  "ignored").encode("utf-8") )
             return
         # _____number of fields_____
         # Any INFORMATION after last field separator is ignored
@@ -444,7 +459,8 @@
         _file_format = _version_date[0]
         if _file_format in self.__format_list:
             self.__file_format = _file_format
-            print(utils.mapping(_("FIEBDC format: $1"),(_file_format,)) )
+            print(utils.mapping(_("FIEBDC format: $1"),
+                                  (_file_format,)).encode("utf-8") )
 
         if len(_version_date) > 1:
             _date = _version_date[1]
@@ -454,7 +470,8 @@
                     self.__budget.setDate(_parsed_date)
         # _____Generator_____
         # ignored field
-        print(utils.mapping(_("FIEBDC file generated by $1"),(_generator,)) )
+        print(utils.mapping(_("FIEBDC file generated by $1"),
+                            (_generator,)).encode("utf-8") )
         # _____Header_Title_____
         _header_title = _header_title.split(u"\\")
         _header_title = [_title.strip() for _title in _header_title]
@@ -795,7 +812,7 @@
             _code = _codes[0]
             _synonyms = [synonym.encode("utf8") for synonym in _codes]
         else:
-            print(_("Record C without a valid code") )
+            print(_("Record C without a valid code").encode("utf-8") )
             return
         # _____Unit_____
         # nothing to do
@@ -874,7 +891,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         elif _hierarchy == 1:
@@ -886,7 +904,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         else:
@@ -914,7 +933,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         self.__budget.setRecord(_code.encode("utf8"), _synonyms, _hierarchy,
@@ -971,7 +991,8 @@
                           "descomposition of the record $1, the factor "\
                           "of the child $2 must be a float number and "\
                           "can not be $3, seted default value 1.0"),
-                          (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
+                          (_code.encode("utf8"), _child_code.encode("utf8"),
+                           _factor.encode("utf8"))).encode("utf-8") )
                     _factor = 1.0
             #____yield___
             if _yield != u"":
@@ -982,7 +1003,8 @@
                           "descomposition of the record $1, the yield of "\
                           "the child $2, must be a float number and can"\
                           "not be $3,  seted default value 1.0"),
-                           (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
+                           (_code.encode("utf8"), _child_code.encode("utf8"),
+                            _factor.encode("utf8"))).encode("utf-8") )
                     _yield = 1.0
             if _child_code != u"" and _code != u"":
                 _children_list.append([_child_code, _factor, _yield ])
@@ -990,7 +1012,8 @@
                 _position = _child_index / 3
             else: #_record_type == "Y"
                 _position = -1
-            self.__budget.setTree(_code.encode("utf8"), _child_code.encode("utf8"), _position, _factor, 
+            self.__budget.setTree(_code.encode("utf8"),
+                _child_code.encode("utf8"), _position, _factor, 
                 _yield, "", "", "", "")
             _child_index = _child_index + 3
             interface.updateGui()
@@ -1068,11 +1091,13 @@
             _parent_code = None
         else:
             print(utils.mapping(_("Invalid codes in $1 record, codes $2"),
-                  (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             return
         if _child_code == u"":
             print(utils.mapping(_("Empty child code in $1 record, codes: "\
-                  "$2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  "$2"), (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             return
         if _parent_code == None:
             # Empty parent code. No-estructured measures.
@@ -1092,7 +1117,8 @@
                 _path = int(_path)
             except ValueError:
                 print(utils.mapping(_("Invalid path in $1 record, "\
-                      "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                      "codes $2"), (_record_type.encode("utf8"),
+                       _codes.encode("utf8"))).encode("utf-8") )
                 return
             if _path > 0:
                 _path -= 1
@@ -1104,7 +1130,8 @@
         except ValueError:
             print(utils.mapping(_("Invalid Total Measure value in $1 "\
                   "record, codes $2. Total fixed to 0."),
-                  (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             _total = 0
         # _____Measure lines_____
         _lines = _lines.split(u"\\")
@@ -1125,7 +1152,8 @@
                 if self.__pattern["formula"].match(_comment):
                     print(utils.mapping(_("The comment is not a formula or "\
                           "its have invalid characters, in the $1 record, "\
-                          "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                          "codes $2"), (_record_type.encode("utf8"),
+                           _codes.encode("utf8"))).encode("utf-8") )
                     return
                 else:
                     _formula = _comment.encode("utf8")
@@ -1150,7 +1178,8 @@
                 if _height != u"": _height = float(_height)
             except ValueError:
                 print(utils.mapping(_("The measure values are not float "\
-                      "numbers, code $1"), (_codes.encode("utf8"),)) )
+                      "numbers, code $1"),
+                      (_codes.encode("utf8"),)).encode("utf-8") )
                 return
             # Prevent subfield units remains empty.
             if (_units == u"" and (_length != u"" or _width != u""
@@ -1160,7 +1189,8 @@
                                _length, _width, _height, _formula])
             _line_index = _line_index + 6
         self.__budget.setTree(_parent_code, _child_code.encode("utf8"), _path, "", "",
-                           _total, _line_list, _label.encode("utf8"), _record_type.encode("utf8"))
+                           _total, _line_list, _label.encode("utf8"),
+                           _record_type.encode("utf8"))
         self.__statistics.valid = self.__statistics.valid + 1
 
     def _parseW(self, field_list):
@@ -1197,7 +1227,9 @@
             _field_code = self.delete_control_space(_field_code)
             # _____section_title_____
             if _field_code != u"":
-                _field_dict[_field_code.encode("utf8")] = _field_title.encode("utf8")
+                _e_field_code = _field_code.encode("utf8")
+                _e_field_title = _field_title.encode("utf8")
+                _field_dict[_e_field_code] = _e_field_title
             _field_index = _field_index + 2
         self.__budget.setSheetFields(_field_dict)
         self.__statistics.valid = self.__statistics.valid +1
@@ -1247,7 +1279,9 @@
                 # _____section_title_____
                 _section_title = self.delete_control_space(_section_title)
                 if _section_code != u"":
-                    _section_dict[_section_code.encode("utf8")] = _section_title.encode("utf8")
+                    _e_section_code = _section_code.encode("utf8")
+                    _e_section_title = _section_title.encode("utf8")
+                    _section_dict[_e_section_code] = _e_section_title
                 _section_index = _section_index + 2
             self.__budget.setSheetSections(_section_dict)
             self.__statistics.valid = self.__statistics.valid +1
@@ -1267,7 +1301,8 @@
             _scodes_text = field_list[1]
             if _scodes_text == u"":
                 # TODO: rtf and html files
-                print("Html and rtf files not yet implemented in ~L record" )
+                _str = "Html and rtf files not yet implemented in ~L record"
+                print(_str.encode("utf-8") )
             else:
                 # _____Section-code_Section-text_____
                 # last \ is erased
@@ -1288,11 +1323,15 @@
                     if _section_code != u"" and _section_text != u"":
                         #-# paragraph #-#
                         _paragraph_code = _record_code + _section_code + u"*"
-                        _paragraph_dict[ _paragraph_code.encode("utf8") ] = _section_text.encode("utf8")
-                        _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
+                        _e_paragraph_code = _paragraph_code.encode("utf8")
+                        _e_section_text = _section_text.encode("utf8")
+                        _paragraph_dict[_e_paragraph_code] = _e_section_text
+                        _e_section_code = _section_code.encode("utf8")
+                        _section_dict[_e_section_code] = _e_paragraph_code
                     _section_index = _section_index + 2
                 self.__budget.setSheetParagraphs(_paragraph_dict)
-                self.__budget.setSheetRecord(_record_code.encode("utf8"), "*", _section_dict)
+                self.__budget.setSheetRecord(_record_code.encode("utf8"), "*",
+                                             _section_dict)
                 self.__statistics.valid = self.__statistics.valid +1
     
     def _parseQ(self, field_list):
@@ -1350,10 +1389,13 @@
                     else:
                         _section_dict = {}
                         _field_dict[_field_key] = _section_dict
-                    _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
+                    _e_section_code = _section_code.encode("utf8")
+                    _e_paragraph_code = _paragraph_code.encode("utf8")
+                    _section_dict[_e_section_code] = _e_paragraph_code
             _section_index = _section_index + 3
         for _field, _section_dict in _field_dict.iteritems():
-            self.__budget.setSheetRecord(_record_code.encode("utf8"), _field.encode("utf8"), _section_dict)
+            self.__budget.setSheetRecord(_record_code.encode("utf8"),
+                                         _field.encode("utf8"), _section_dict)
         self.__statistics.valid = self.__statistics.valid +1
     
     def _parseJ(self, field_list):
@@ -1382,9 +1424,11 @@
         _paragraph_text = field_list[1]
         if _paragraph_text == u"":
             # TODO: rtf and html files
-            print("Html and rtf files not yet implemented in ~J record" )
+            _str = "Html and rtf files not yet implemented in ~J record"
+            print(_str.encode("utf-8") )
         else:
-            self.__budget.setSheetParagraph(paragraph_code.encode("utf8"), paragraph_text.encode("utf8"))
+            self.__budget.setSheetParagraph(paragraph_code.encode("utf8"),
+                                            paragraph_text.encode("utf8"))
             self.__statistics.valid = self.__statistics.valid +1
     
     def _parseG(self, field_list):
@@ -1450,10 +1494,11 @@
                     _tested_grafic_file_list.append(_grafic_file_path_ll)
                 else:
                     print(utils.mapping(_("The file $1 do not exist"),
-                        (_grafic_file_path.decode("utf8"),)) )
+                        (_grafic_file_path.decode("utf8"),)).encode("utf-8") )
         if len(_grafic_file_list) > 0:
             for _grafic_file in _tested_grafic_file_list:
-                self.__budget.addFile(_record_code.encode("utf8"), _grafic_file, "img", "")
+                self.__budget.addFile(_record_code.encode("utf8"),
+                                      _grafic_file, "img", "")
             self.__statistics.valid = self.__statistics.valid +1
     
     def _parseE(self, field_list):
@@ -1530,11 +1575,16 @@
                _postal_code != u"" or _town != u"" or _province != u"" or \
                _country != u"" or _phone != u"" or _fax != u"" or \
                _contact_person != u"":
-                _local_offices.append([_type.encode("utf8"), _subname.encode("utf8"),
-                                       _address.encode("utf8"), _postal_code.encode("utf8"),
-                                       _town.encode("utf8"), _province.encode("utf8"),
-                                       _country.encode("utf8"), _phone_list,
-                                       _fax_list, _contact_person.encode("utf8")])
+                _local_offices.append([_type.encode("utf8"),
+                                       _subname.encode("utf8"),
+                                       _address.encode("utf8"),
+                                       _postal_code.encode("utf8"),
+                                       _town.encode("utf8"),
+                                       _province.encode("utf8"),
+                                       _country.encode("utf8"),
+                                       _phone_list,
+                                       _fax_list,
+                                       _contact_person.encode("utf8")])
             _local_offices_index = _local_offices_index + 10
         # _____cif web email_____
         _c_w_e = self.delete_control_space(field_list[4])
@@ -1590,7 +1640,8 @@
                 _ti_description = _field_2_list[_ti_index+1]
                 _ti_unit = _field_2_list[_ti_index+2]
                 if _ti_code != "":
-                    self.__budget.addTecInfo(_ti_code.encode("utf8"), _ti_description.encode("utf8"),
+                    self.__budget.addTecInfo(_ti_code.encode("utf8"), 
+                                             _ti_description.encode("utf8"),
                                              _ti_unit.encode("utf8"))
                 _ti_index = _ti_index + 3
         else:
@@ -1607,7 +1658,8 @@
                 if _ti_code != u"" and _ti_value != u"":
                     _ti_dict[_ti_code.encode("utf8")] = _ti_value.encode("utf8")
                 _ti_index = _ti_index + 2
-            self.__budget.setTecnicalInformation(_record_code.encode("utf8"), _ti_dict)
+            self.__budget.setTecnicalInformation(_record_code.encode("utf8"),
+                                                 _ti_dict)
         self.__statistics.valid = self.__statistics.valid +1
 
     def _parseF(self, field_list):
@@ -1618,8 +1670,6 @@
             1- Record code
             2- { Type \ { Filenames; } \ [Description] }
         """
-        print("parseF")
-        print(field_list)
         # _____Number of fields_____
         # The record must have at least 3 fields
         if len(field_list) < 3:
@@ -1647,7 +1697,6 @@
             _files_list.extend[u""]*(3 - len(_files_list)%3)
         _file_index = 0
         _tested_files_list = []
-        print(_files_list)
         while _file_index < len(_files_list)-3:
             _type = _files_list[_file_index].replace(u" ",u"")
             ## _types = {
@@ -1665,16 +1714,13 @@
             ##                  "etc. de empresa"),
             ##          "11": _("certificado/s de empresa"),
             ##          "12": _("obras realizadas")}
-            _types = [u"0", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"10",
-                      u"11", u"12"]
+            _types = [u"0", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8",
+                      u"9", u"10", u"11", u"12"]
             if not _type in _types:
                 _type = u"0"
             _filenames = _files_list[_file_index + 1]
             _description = _files_list[_file_index + 2]
             _file_index += 3
-            print(u"type: " + _type)
-            print(u"filenames: " + _filenames)
-            print(u"_description: " + _description)
             if len(_filenames) and _filenames[-1] == u";":
                 _files = _files[:-1]
             _filenames_list = _filenames.split(u";")
@@ -1702,23 +1748,28 @@
                     _file_path_lu = os.path.join(_path, _lu)
                     _file_path_ll = os.path.join(_path, _ll)
                     if os.path.exists(_file_path_uu):
-                        _tested_files_list.append([_file_path_uu, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_uu,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_ul):
-                        _tested_files_list.append([_file_path_ul, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_ul,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_lu):
-                        _tested_files_list.append([_file_path_lu, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_lu,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_ll):
-                        _tested_files_list.append([_file_path_ll, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_ll,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     else:
                         print(utils.mapping(_("The file $1 do not exist"),
-                            (_file_path,)) )
+                            (_file_path,)).encode("utf-8") )
         if len(_tested_files_list) > 0:
             for _file in _tested_files_list:
-                self.__budget.addFile(_record_code.encode("utf8"), _file[0], _file[1], _file[2])
+                self.__budget.addFile(_record_code.encode("utf8"), _file[0],
+                                      _file[1], _file[2])
         self.__statistics.valid = self.__statistics.valid +1
 
     def _parseB(self, field_list):
@@ -1820,14 +1871,14 @@
                     field_list = field_list[0:3]
                 field_list = field_list[1:]
                 if len(field_list) != 2:
-                    print(_("PyArq hates parametric DLLs") )
+                    print(_("PyArq hates parametric DLLs").encode("utf-8") )
                     return
         else:
             return
         # _____Description_____
         _description = field_list[1]
         if _description == u"":
-            print(_("PyArq hates parametric DLLs") )
+            print(_("PyArq hates parametric DLLs").encode("utf-8") )
             return
         # Adding last end of line
         _description = _description + u"\r\n"
@@ -1885,7 +1936,8 @@
                         if index1 % 2 != 0:
                             _parcial_line = u'"' + _list[index1]
                         else:
-                            _parcial_line =  u'"' + _list[index1].replace(u" ",u"")
+                            _parcial_line = _list[index1].replace(u" ",u"")
+                            _parcial_line = u'"' + _parcial_line
                         _final_line = _final_line + _parcial_line
                     _line = _final_line[1:]
                     _lines[index] = _line
@@ -1911,7 +1963,9 @@
                             _pass_line = _pass_line + 1
                         _search = self.__pattern["var"].search(_line)
                         if _search is not None:
-                            _var = _search.groups()[0] + u" = " + _search.groups()[1]
+                            _var0 = _search.groups()[0]
+                            _var1 = _search.groups()[1]
+                            _var = _var0 + u" = " + _var1
                             #print("__VAR__" + str(_var) )
                             pass
                         else:
@@ -1922,27 +1976,43 @@
                         #_patern = "(^[^:]*):(.*)$"
                         _search = self.__pattern["descomposition"].search(_line)
                         if _search is not None:
-                            _var = _search.groups()[0] + u":" + _search.groups()[1]
+                            _var0 = _search.groups()[0]
+                            _var1 = _search.groups()[1]
+                            _var = _var0  + u":" + _var1
                             #print( "__Descomposición__" + str(_var) )
                             pass
                         else:
                             #print("no __Descomposición__", _line )
                             pass
                     else:
-                        print("Parametric: code: " + _family_code.encode("utf8") )
-                        print("******* Desconocido *** : " + _line )
-                        if index-10 > 0: print("-11 : " + _lines[index-11].encode("utf8") )
-                        if index-10 > 0: print("-10 : " + _lines[index-10].encode("utf8") )
-                        if index-9 > 0: print("-9 : " + _lines[index-9].encode("utf8") )
-                        if index-8 > 0: print("-8 : " + _lines[index-8].encode("utf8") )
-                        if index-7 > 0: print("-7 : " + _lines[index-7].encode("utf8") )
-                        if index-6 > 0: print("-6 : " + _lines[index-6].encode("utf8") )
-                        if index-5 > 0: print("-5 : " + _lines[index-5].encode("utf8") )
-                        if index-4 > 0: print("-4 : " + _lines[index-4].encode("utf8") )
-                        if index-3 > 0: print("-3 : " + _lines[index-3].encode("utf8") )
-                        if index-2 > 0: print("-2 : " + _lines[index-2].encode("utf8") )
-                        if index-1 > 0: print("-1 : " + _lines[index-1].encode("utf8") )
-                        print("-0 :" + _lines[index-0] )
+                        _str = "Parametric: code: " + \
+                               _family_code.encode("utf8")
+                        print(_str.encode("utf-8") )
+                        _str = "******* Desconocido *** : " + _line
+                        print(_str.encode("utf-8") )
+                        if index-10 > 0:
+                            print("-11 : " + _lines[index-11].encode("utf8") )
+                        if index-10 > 0:
+                            print("-10 : " + _lines[index-10].encode("utf8") )
+                        if index-9 > 0:
+                            print("-9 : " + _lines[index-9].encode("utf8") )
+                        if index-8 > 0:
+                            print("-8 : " + _lines[index-8].encode("utf8") )
+                        if index-7 > 0:
+                            print("-7 : " + _lines[index-7].encode("utf8") )
+                        if index-6 > 0:
+                            print("-6 : " + _lines[index-6].encode("utf8") )
+                        if index-5 > 0:
+                            print("-5 : " + _lines[index-5].encode("utf8") )
+                        if index-4 > 0:
+                            print("-4 : " + _lines[index-4].encode("utf8") )
+                        if index-3 > 0:
+                            print("-3 : " + _lines[index-3].encode("utf8") )
+                        if index-2 > 0:
+                            print("-2 : " + _lines[index-2].encode("utf8") )
+                        if index-1 > 0:
+                            print("-1 : " + _lines[index-1].encode("utf8") )
+                        print(("-0 :" + _lines[index-0]).encode("utf-8") )
                         pass
                 else:
                     _parameter_list = _line.split(u"\\")[1:-1]
@@ -1951,16 +2021,19 @@
                            _parameter_list[0] == u"COMENTARIO":
                             #print( "__COMENTARIO__" + _parameter_list[1])
                             self.__budget.setParametricSelectComment(
-                                _family_code.encode("utf8"), _parameter_list[1].encode("utf8"))
+                                _family_code.encode("utf8"),
+                                _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"R" or \
                            _parameter_list[0] == u"RESUMEN":
                             #print( "__RESUMEN__" + _parameter_list[1])
-                            self.__budget.setParametricSummary(_family_code.encode("utf8"),
+                            self.__budget.setParametricSummary(
+                                _family_code.encode("utf8"),
                                 _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"T" or \
                            _parameter_list[0] == u"TEXTO":
                             #print( "__TEXTO__" + _parameter_list[1])
-                            self.__budget.setParametricText(_family_code.encode("utf8"),
+                            self.__budget.setParametricText(
+                                _family_code.encode("utf8"),
                                 _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"P" or \
                            _parameter_list[0] == u"PLIEGO":
@@ -2017,16 +2090,18 @@
         try:
             _file =  open(self.__filename, 'r')
         except IOError:
-            print( utils.mapping("IOError: $1", (self.__filename,)) )
+            _str = utils.mapping("IOError: $1", (self.__filename,))
+            print( _str.encode("utf-8") )
             return None
         _filesize = float(os.path.getsize(self.__filename))
         if _filesize == 0.0:
-            print( utils.mapping("Empty File: $1", (self.__filename,)) )
+            _str = utils.mapping("Empty File: $1", (self.__filename,))
+            print( _str.encode("utf-8") )
             # Todo: Create empty budget
             return None
         self.__budget.filename = self.__filename
         interface.readFile_send_message(utils.mapping(_("Loading file $1"),
-                         (self.__filename,)))
+                         (self.__filename,)).encode("utf-8"))
         interface.readFile_progress(_file.tell() / _filesize)
         _buffer = _file.read(1000)
         interface.updateGui()
@@ -2047,21 +2122,21 @@
                     self.__character_set = self.__character_sets_dict[_version]
                     interface.readFile_send_message(utils.mapping(
                         _("FIEBDC character encoding: $1"),
-                          (self.__character_set,)))
+                          (self.__character_set,)).encode("utf8"))
                 else:
                     interface.readFile_send_message(utils.mapping(
                         _("This Character encoding do not exist in "\
                           "FIEBDC3! Default Character encoding: $1"),
-                          (self.__character_set,)))
+                          (self.__character_set,)).encode("utf-8"))
             else:
                 interface.readFile_send_message(utils.mapping(_(
                          "This V record dot have a character encoding! "\
                          "Default character encoding: $1"),
-                         (self.__character_set,)))
+                         (self.__character_set,)).encode("utf-8"))
         else:
             interface.readFile_send_message(utils.mapping(_(
                   "Not 'V' record in File! Default character encoding: "\
-                  "$1"), (self.__character_set,)))
+                  "$1"), (self.__character_set,)).encode("utf-8"))
         _buffer = unicode(_buffer, self.__character_set)
         interface.updateGui()
         # Any INFORMATION between the beginning of the file and the
@@ -2107,11 +2182,13 @@
         else:
             self.__statistics.time = time.time()-_time
             if self.__statistics.O > 0:
-                interface.readFile_send_message(
-                    utils.mapping(_("$1 unsuported record type O: "\
-                    "Comercial Relationship"), (str(self.__statistics.O,))))
+                _str = utils.mapping(
+                    _("$1 unsuported record type O: Comercial Relationship"),
+                    (str(self.__statistics.O,)))
+                interface.readFile_send_message(_str.encode("utf-8"))
             if self.__statistics.valid == 0:
-                interface.readFile_send_message(_("This file is not a valid FIBDC3 file"))
+                _str = _("This file is not a valid FIBDC3 file")
+                interface.readFile_send_message(_str.encode("utf-8"))
                 return None
             interface.readFile_end()
             self._testBudget(self.__budget, interface)
@@ -2124,7 +2201,7 @@
         Test and repair budget object after read it from bc3 file
         """
         # TODO: more to do here
-        print( _("Testing budget ...") )
+        print( _("Testing budget ...").encode("utf-8") )
         # Add price to records without price
         _iter = budget.iter()
         _titlelist = budget.getTitleList()[1]
@@ -2143,7 +2220,7 @@
                     _price = [0.0, _root.getDate(_len_prices + _index)]
                     budget.addPriceToRecord(_price,_record)
             interface.updateGui()
-        print( _("End Test") )
+        print(_("End Test").encode("utf-8"))
 
     def delete_control_space(self, text):
         text = self.delete_control(text)
@@ -2201,7 +2278,7 @@
         
         print( message )
         """
-        print( message )
+        print( message.encode("utf-8") )
 
     def readFile_progress(self, percent):
         """progress(percent)
@@ -2218,8 +2295,8 @@
         The readFile method end successfully
         """
         self.endSuccessfully == True
-        print(self.__statistics)
-        print("progreso = " + str(self.__progress))
+        print(self.__statistics.encode("utf-8"))
+        print(("progreso = " + str(self.__progress)).encode("utf-8"))
 
     def readFile_cancel(self):
         """readFile_cancel()
@@ -2227,8 +2304,8 @@
         The readFile method is canceled
         """
         self.endSuccessfully == False
-        print( _("Process terminated") )
-        print("progreso = " + str(self.__progress))
+        print( _("Process terminated").encode("utf-8") )
+        print(("progreso = " + str(self.__progress)).encode("utf-8"))
 
     def updateGui(self):
         """updateGui(self)
@@ -2305,11 +2382,10 @@
             self.time = 0.0
 
     def __str__(self):
-        return self.str().encode("utf8")
+        return self.str()
 
     def str(self):
-
-        return utils.mapping(_("Time to load: $1 seconds"),
+        _str = utils.mapping(_("Time to load: $1 seconds"),
                 (("%.2f" %(self.time)),)) + "\n" + \
                utils.mapping(_("Records/Valid Records: $1/$2"), 
                (str(self.records), str(self.valid))) + "\n" +\
@@ -2334,4 +2410,5 @@
                "F: %s\n" %(self.F,) + \
                "A: %s\n" %(self.A,) + \
                "?: %s\n" %(self.unknow,)
+        return _str.encode("utf8")