annotate Generic/fiebdc.py @ 23:65e7ae0d0e63

GTK2 to GTK3
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Thu, 02 May 2019 16:31:17 +0200
parents f7e0cc58737f
children 189f8274aecd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1 #!/usr/bin/python
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3 ## File fiebdc.py
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4 ## This file is part of pyArq-Presupuestos.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5 ##
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
6 ## Copyright (C) 2010-2019 Miguel Ángel Bárcena Rodríguez
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
7 ## <miguelangel@obraencurso.es>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
8 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
9 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
10 ## it under the terms of the GNU General Public License as published by
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
11 ## the Free Software Foundation, either version 3 of the License, or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
12 ## (at your option) any later version.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
13 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
14 ## pyArq-Presupuestos is distributed in the hope that it will be useful,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
17 ## GNU General Public License for more details.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
18 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
19 ## You should have received a copy of the GNU General Public License
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
20 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
21
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
22 # specifications in http://www.fiebdc.org
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
23
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
24 # Modules
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
25 import time
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
26 import re
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
27 import calendar
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
28 import os.path
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
29 import unicodedata
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
30 import hashlib
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
31 # pyArq-Presupuestos modules
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
32 import base
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
33 from Generic import utils
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
34 from Generic import globalVars
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
35
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
36 class Read(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
37 """fiebdc.Read:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
38
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
39 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
40 Reads and parses a fiebdc file
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
41 +-- __budget: budget ("base.Budget" object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
42 +-- __file_format: File format of the fiebdc file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
43 +-- __format_list: List of file format that can be readed
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
44 +-- __character_sets_dict: Dictionary with the character sets supported
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
45 +-- __character_set: character_set of the file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
46 +- __generator: program which the file is created
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
47 +-- __cancel: Boolean value, True mean that the read process must stop
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
48 +-- __filename: The filename of the fiebdc file that is readed
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
49 +-- __pattern: re compiled pattern dict
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
50 +-- __statistics: Statistics object, records number
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
51 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
52 fiebdc.Read(filename=None, budget=None)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
53 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
54 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
55 +-- Read
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
56 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
57 No public Atributes
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
58 Methods:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
59 cancel()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
60 eraseControlCharacters(string)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
61 validateCode(code)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
62 parseDate(date)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
63 parseRecord(record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
64 readFile(budget=None, filename=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
65 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
66 def __init__(self, filename=None, budget=None):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
67 """def __init__(filename=None, budget=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
68
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
69 Sets the instance attributes
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
70 __budget: budget ("base.Budget" object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
71 __file_format: File format of the fiebdc file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
72 __format_list: List of file format that can be readed
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
73 __character_sets_dict: Dictionary with the character sets supported
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
74 __character_set: character_set of the file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
75 __generator: program which the file is created
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
76 __cancel: Boolean value, True mean that the read process must stop
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
77 __filename: The filename of the fiebdc file that is readed
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
78 __pattern: re compiled pattern dict
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
79 __statistics: Statistics object, records number
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
80 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
81 self.__budget = budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
82 self.__filename = filename
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
83 if not self.__budget is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
84 self.__budget.filename = self.__filename
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
85 self.__cancel = False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
86 self.__format_list = ["FIEBDC-3/95", "FIEBDC-3/98", "FIEBDC-3/2002",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
87 "FIEBDC-3/2004", "FIEBDC-3/2007"]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
88 # ANSI->¿"ISO-8859-15" or "latin1 ISO-8859-1" or "cp1252 windows-1252"?
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
89 # 850 -> IBM850 -> cp850
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
90 # 437 -> IBM437 -> cp437
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
91 self.__character_sets_dict = {"ANSI" : "cp1252",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
92 "850" : "850",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
93 "437" : "cp437"}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
94 self.__file_format = "FIEBDC-3/2007"
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
95 self.__generator = globalVars.name + " " + globalVars.version
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
96 self.__character_set = "850"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
97 self.__pattern = {
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
98 "control_tilde" : re.compile(u"((\r\n)| |\t)+~"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
99 "control_vbar" : re.compile(u"((\r\n)| |\t)+\|"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
100 "control_backslash" : re.compile(ur"((\r\n)| |\t)+\\"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
101 "valid_code" : re.compile(u"[^A-Za-z0-9ñÑ.$#%&_]"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
102 "special_char": re.compile(u"[#%&]"),
19
bea86fd8dfc6 - in float
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 18
diff changeset
103 "no_float": re.compile(u"[^\-0-9.]"),
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
104 "formula" : re.compile(u".*[^0123456789\.()\+\-\*/\^abcdp ].*"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
105 "comment": re.compile(u"#.*\r\n"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
106 "empty_line": re.compile(ur"(\r\n) *\r\n"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
107 "space_before_backslash" : re.compile(ur"( )+\\"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
108 "space_after_backslash" : re.compile(ur"\\( )+"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
109 "start_noend_backslash" : re.compile(u"(\r\n\\\.*[^\\\])\r\n"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
110 "end_oper": re.compile(u"(\+|-|\*|/|/^|@|&|<|>|<=|>=|=|!) *\r\n"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
111 "matricial_var" : re.compile(u"(\r\n *[%|\$][A-ZÑ].*=.*,) *\r\n"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
112 "descomposition" : re.compile(u"^([^:]+):(.*)$"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
113 "var" : re.compile(u"^([$%][A-ZÑ][()0-9, ]*)=(.*)$"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
114 "after_first_tilde" : re.compile(u"^[^~]*~"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
115 "end_control" : re.compile(u"((\r\n)| |\t)+$"),
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
116 }
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
117 self.__statistics = Statistics()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
118
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
119 def cancel(self):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
120 """def cancel()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
121
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
122 Sets the "__cancel" attribute to True, It stops the read process.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
123 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
124 self.__cancel = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
125
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
126 def eraseControlCharacters(self, string):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
127 """eraseControlCharacters(string)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
128
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
129 Return a copy of the string with the blank characters (32),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
130 tabs (9) and end of line (13 and 10) before of the separators
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
131 '~', '|' erased.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
132 Before separator \ not deleted because it affects the reading of the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
133 record ~P
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
134 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
135 # "control_tilde" : "((\r\n)| |\t)+~"
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
136 string = self.__pattern["control_tilde"].sub(u"~",string)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
137 # "control_vbar" : "((\r\n)| |\t)+\|"
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
138 string = self.__pattern["control_vbar"].sub(u"|",string)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
139 # "control_backslash" : r"((\r\n)| |\t)+\\"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
140 #string = self.__pattern["control_backslash"].sub(r"\\",string)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
141 return string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
142
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
143 def validateCode(self, code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
144 """validateCode(code)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
145
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
146 Test if the code have invalid characters and try to erase it,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
147 if it is posible return a valid code else return a empty string.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
148 """
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
149 if not isinstance(code, unicode):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
150 print(_("Invalid code, it must be a unicode string") )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
151 return u""
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
152 # Valid chararcter: A-Z a-z 0-9 ñ Ñ . $ # % & _
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
153 # "valid_code" : "[^A-Za-z0-9ñÑ.$#%&_]"
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
154 _ucode = self.__pattern["valid_code"].sub(u"_", code)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
155 if _ucode != code:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
156 try:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
157 print(utils.mapping(_("The code '$1' have invalid characters, replaced by '$2'."),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
158 (code.encode("utf8"),_ucode.encode("utf8"))) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
159 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
160 print(utils.mapping(_("The code '$1' have invalid characters and can not be encoded in utf8."), (code,)) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
161
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
162 if len(_ucode) == 0:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
163 _normalize_code = ''.join((c for c in unicodedata.normalize('NFD', _ucode) if unicodedata.category(c) != 'Mn'))
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
164 # from http://www.leccionespracticas.com/uncategorized/eliminar-tildes-con-python-solucionado/
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
165 _ucode = self.__pattern["valid_code"].sub(u"", _normalize_code)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
166 if len(_ucode) == 0:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
167 _hash_code = hashlib.sha256()
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
168 _hash_code.update(code.encode('utf-8'))
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
169 _hexdigest_code = _hash_code.hexdigest()
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
170 _ucode = self.__pattern["valid_code"].sub(u"", _hexdigest_code)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
171 code = _ucode
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
172 if code == u"##":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
173 # root code is an empty code : set to ROOT
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
174 return u"ROOT"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
175 # the lasts characters can not be <#> or <##>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
176 # <##> -> root record in FIEFDC-3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
177 # <#> -> chapter record in FIEFDC-3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
178 if len(code) > 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
179 while code[-1] == u"#":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
180 code = code[:-1]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
181 if len(code) == 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
182 return code
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
183 if len(code) > 20:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
184 code = code[:20]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
185 # only one charecter # % or &
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
186 if sum([code.count(c) for c in u'#%&']) > 1:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
187 print(utils.mapping(_("The code '$1' contains special "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
188 "characters repeated."),(code.encode("utf8"),)) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
189 _i = min([code.find(c) for c in u'#%&'])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
190 code = code[:_i+1] + \
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
191 self.__pattern["special_char"].sub(u"", code[_i+1:])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
192 return code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
193
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
194 def parseDate(self, date):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
195 """parseDate(date)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
196
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
197 date: in the format:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
198 uneven len: add a Leading 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
199 len = 8 DDMMYYYY
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
200 len <= 6 DDMMYY “80/20”. >80 -> >1980 <80 -> <2080
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
201 len < 5 MMYY
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
202 len < 3 YY
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
203 Test date string and return a tuple (YYYY, MM, DD)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
204 or None if the date format is invalid
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
205 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
206 # All characters must be numbers, len <= 8 and not empty string
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
207 if not date.isdigit() or len(date) > 8 or date == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
208 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
209 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
210 if len(date)%2 == 1: # uneven len: add a leading 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
211 date = u"0" + date
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
212 if len(date) == 8:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
213 _d = int(date[:2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
214 _m = int(date[2:4])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
215 _y = int(date[4:8])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
216 elif len(date) <= 6:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
217 _y = int(date[-2:])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
218 if _y < 80: _y = 2000 + _y
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
219 else: _y = 1900 + _y
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
220 if len(date) == 6:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
221 _d = int(date[:2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
222 _m = int(date[2:4])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
223 elif len(date) == 4:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
224 _d = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
225 _m = int(date[:2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
226 elif len(date) == 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
227 _d = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
228 _m = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
229 if not _d in range(1,31): _d = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
230 if not _m in range(1,12): _m = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
231 if _m == 0: _d = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
232 if _m != 0 and _d != 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
233 if calendar.monthrange(_y, _m)[1] < _d:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
234 _d = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
235 return (_y, _m, _d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
236
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
237 def parseRecord(self, record, interface):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
238 """parseRecord(record, interface)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
239
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
240 record: the record line readed from the file whith the format:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
241 type|field|field|subfield\subfield|...
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
242 [a] nothing or "a"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
243 {a} zero or more #-#twice#-# "a"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
244 <a> one or more #-#twice#-# "a"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
245 Types: V C D Y M N T K L Q J G E X B F A
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
246 V: Property and Version
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
247 1- [File_Owner]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
248 2- Format_Version[\DDMMYYYY]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
249 3- [Program_Generator]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
250 4- [Header]\{Title\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
251 5- [Chaters_set]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
252 6- [Comment]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
253 C: Record:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
254 1- Code{\Code}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
255 2- [Unit]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
256 3- [Summary]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
257 4- {Price\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
258 5- {Date\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
259 6- [Type]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
260 D or Y: DECOMPOSITION or ADD DECOMPOSITION
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
261 1- Parent Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
262 2- <Child Code\ [Factor]\ [Yield]>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
263 M or N: MEASURE or ADD MEASURE
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
264 1- [Parent Code\]Child Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
265 2- {Path\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
266 3- TOTAL MEASURE
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
267 4- {Type\Comment\Unit\Length\Width\Height\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
268 5- [Label]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
269 T: Text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
270 1- Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
271 2- Description text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
272 K: Coefficients
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
273 1- { DN \ DD \ DS \ DR \ DI \ DP \ DC \ DM \ DIVISA \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
274 2- CI \ GG \ BI \ BAJA \ IVA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
275 3- { DRC \ DC \ DRO \ DFS \ DRS \ DFO \ DUO \ DI \ DES \ DN \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
276 DD \ DS \ DIVISA \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
277 4- [ n ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
278 L: Sheet of Conditions 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
279 A)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
280 1- Empty
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
281 2- {Section Code\Section Title}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
282 B)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
283 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
284 2- {Section Code\Section Text}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
285 3- {Section Code\RTF file}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
286 4- {Section Code\HTM file}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
287 Q: Sheet of Conditions 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
288 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
289 2- {Section Code\Paragraph key\{Field key;}\}|
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
290 J: Sheet of Conditions 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
291 1- Paragraph code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
292 2- [Paragraph text]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
293 3- [RTF file]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
294 4- [HTML file]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
295 G: Grafic info
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
296 1- <grafic_file.ext\>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
297 E: Company
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
298 1- company Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
299 2 [ summary ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
300 3- [ name ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
301 4- { [ type ] \ [ subname ] \ [ address ] \ [ postal_code ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
302 \ [ town ] \ [ province ] \ [ country ] \ { phone; }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
303 \ { fax; } \ {contact_person; } \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
304 5- [ cif ] \ [ web ] \ [ email ] \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
305 X: Tecnical information
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
306 A)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
307 1- Empty
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
308 2- < TI_Code \ TI_Descitption \ TI_Unit >
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
309 B)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
310 1- Record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
311 2- < TI_Code \ TI_value >
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
312 F: #-#Adjunto#-# File
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
313 1- Record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
314 2- { Type \ { Filenames; } \ [Description] }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
315 B: Change code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
316 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
317 2- New code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
318 A: Labels
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
319 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
320 2- <Label\>
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
321 interface:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
322 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
323 # TODO: ~L ~J RTF and HTML files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
324 # TODO: test ~Q ~J ~G
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
325 # TODO: ~P. Registro tipo Descripción Paramétrica.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
326 # TODO: ~O. Registro tipo Relación Comercial.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
327 # TODO: test records
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
328 _field_list = record.split(u"|")
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
329 self.__statistics.records = self.__statistics.records +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
330 _budget = self.__budget
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
331 if _field_list[0] == u"V":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
332 self.__statistics.V += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
333 self._parseV(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
334 elif _field_list[0] == u"C":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
335 self.__statistics.C += 1
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
336 self._parseC(_field_list, interface)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
337 elif _field_list[0] == u"D":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
338 self.__statistics.D += 1
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
339 self._parseDY(_field_list, interface)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
340 elif _field_list[0] == u"Y":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
341 self.__statistics.Y += 1
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
342 self._parseDY(_field_list, interface)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
343 elif _field_list[0] == u"M":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
344 self.__statistics.M += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
345 self._parseMN(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
346 elif _field_list[0] == u"N":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
347 self.__statistics.N += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
348 self._parseMN(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
349 elif _field_list[0] == u"T":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
350 self.__statistics.T += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
351 self._parseT(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
352 elif _field_list[0] == u"K":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
353 self.__statistics.K += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
354 self._parseK(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
355 elif _field_list[0] == u"W":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
356 self.__statistics.W += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
357 self._parseW(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
358 elif _field_list[0] == u"L":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
359 self.__statistics.L += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
360 self._parseL(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
361 elif _field_list[0] == u"Q":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
362 self.__statistics.Q += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
363 self._parseQ(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
364 elif _field_list[0] == u"J":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
365 self.__statistics.J += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
366 self._parseJ(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
367 elif _field_list[0] == u"G":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
368 self.__statistics.G += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
369 self._parseG(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
370 elif _field_list[0] == u"E":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
371 self.__statistics.E += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
372 self._parseE(_field_list)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
373 elif _field_list[0] == "O":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
374 self.__statistics.O += 1
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
375 elif _field_list[0] == u"P":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
376 self.__statistics.P += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
377 self._parseP(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
378 elif _field_list[0] == u"X":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
379 self.__statistics.X += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
380 self._parseX(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
381 elif _field_list[0] == u"B":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
382 self.__statistics.B += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
383 self._parseB(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
384 elif _field_list[0] == u"F":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
385 self.__statistics.F += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
386 self._parseF(_field_list)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
387 elif _field_list[0] == u"A":
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
388 self.__statistics.A += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
389 self._parseA(_field_list)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
390 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
391 print(utils.mapping(_("FIEBDC. Unknow record: $1"),(record[:100],)))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
392 self.__statistics.unknow += 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
393
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
394 def _parseV(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
395 """_parseV(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
396
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
397 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
398 0- V :Property and Version
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
399 1- [File_Owner]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
400 2- Format_Version[\DDMMYYYY]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
401 3- [Program_Generator]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
402 4- [Header]\{Title\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
403 5- [Chaters_set]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
404 6- [Comment]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
405 7- [Data type]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
406 8- [Number budget certificate]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
407 9- [Date budget certificate]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
408 """
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
409 if self.__statistics.records != 1:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
410 print(utils.mapping(_("The 'V' record (Property and Version) "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
411 "must be the first record in the file but it is the "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
412 "number: $1"), (str(self.__statistics.records),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
413 print(_("The default values were taken and this V record is "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
414 "ignored") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
415 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
416 # _____number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
417 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
418 if len(field_list) > 10:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
419 field_list = field_list[:10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
420 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
421 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
422 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
423 field_list = field_list + [u""]*(10-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
424 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
425 # only leading and trailing whitespace in owner, generator, comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
426 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
427 _record_type = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
428 _owner = field_list[1].strip()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
429 _owner = self.delete_control(_owner)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
430 _version_date = self.delete_control_space(field_list[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
431 _generator = field_list[3].strip()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
432 _generator = self.delete_control(_generator)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
433 _header_title = field_list[4].strip()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
434 _header_title = self.delete_control(_header_title)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
435 _character_set = self.delete_control_space(field_list[5])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
436 _comment = field_list[6].strip(u"\t \n\r")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
437 _data_type = self.delete_control_space(field_list[7])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
438 _number_certificate = self.delete_control_space(field_list[8])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
439 __date_certificate = self.delete_control_space(field_list[9])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
440 # _____Owner_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
441 self.__budget.setOwner(_owner)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
442 # _____Version-Date_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
443 _version_date = _version_date.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
444 _file_format = _version_date[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
445 if _file_format in self.__format_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
446 self.__file_format = _file_format
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
447 print(utils.mapping(_("FIEBDC format: $1"),(_file_format,)) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
448
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
449 if len(_version_date) > 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
450 _date = _version_date[1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
451 if _date != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
452 _parsed_date = self.parseDate(_date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
453 if _parsed_date is not None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
454 self.__budget.setDate(_parsed_date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
455 # _____Generator_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
456 # ignored field
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
457 print(utils.mapping(_("FIEBDC file generated by $1"),(_generator,)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
458 # _____Header_Title_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
459 _header_title = _header_title.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
460 _header_title = [_title.strip() for _title in _header_title]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
461 _header = _header_title.pop(0)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
462 _header = [_item.encode("utf8") for _item in _header]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
463 _title = [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
464 for _title_index in _header_title:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
465 if _title_index != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
466 _title.append(_title_index)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
467 _title = [_item.encode("utf8") for _item in _title]
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
468 if _header != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
469 self.__budget.setTitleList([ _header, _title])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
470 # _____Characters_set_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
471 # field parsed in readFile method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
472 # _____Comment_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
473 if _comment != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
474 self.__budget.setComment(_comment.encode("utf8"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
475 # _____Data type_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
476 # 1 -> Base data.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
477 # 2 -> Budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
478 # 3 -> Budget certificate.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
479 # 4 -> Base date update.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
480 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
481 _data_type = int(_data_type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
482 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
483 _data_type = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
484 if _data_type == 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
485 # _____Number budget certificate_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
486 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
487 _number_certificate = int(_number_certificate)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
488 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
489 _number_certificate = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
490 # _____Date budget certificate_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
491 if _date_certificate != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
492 _parsed_date_certificate = self.parseDate(_date_certificate)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
493 if _parsed_date_certificate is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
494 _date_certificate = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
495 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
496 _date_certificate = _parsed_date_certificate
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
497 self.__budget.setBudgetype(_data_type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
498 self.__budget.setCertificateOrder(_number_certificate)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
499 self.__budget.setCertificateDate(_parsed_date_cerfificate)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
500 elif _data_type != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
501 self.__budget.setBudgeType(_data_type)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
502 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
503
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
504 def _parseK(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
505 """_parseK(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
506
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
507 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
508 0- K: Coefficients
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
509 1- { DN \ DD \ DS \ DR \ DI \ DP \ DC \ DM \ DIVISA \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
510 2- CI \ GG \ BI \ BAJA \ IVA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
511 3-
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
512 A){ DRC \ DC \ DRO \ DFS \ DRS \ DFO \ DUO \ DI \ DES \ DN \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
513 DD \ DS \ DIVISA \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
514 B){ DRC \ DC \ \ DFS \ DRS \ \ DUO \ DI \ DES \ DN \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
515 DD \ DS \ DSP\ DEC\ DIVISA \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
516 4- [ n ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
517 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
518 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
519 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
520 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
521 # The last field is ignored, pyArq hate dll's
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
522 if len(field_list) > 4:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
523 field_list = field_list[1:4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
524 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
525 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
526 field_list = field_list[1:] + [""]*(4-len(field_list))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
527 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
528 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
529 _field0 = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
530 _field1 = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
531 _field2 = self.delete_control_space(field_list[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
532 # _____Field 1_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
533 if len(_field1) > 0 and _field1[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
534 _field1 = _field1[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
535 # if there are a \ character at the end it must be erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
536 _percentages = _field1.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
537 if len(_percentages) > 5:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
538 _percentages = _percentages[:5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
539 # If there are no sufficient subfields, the subfields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
540 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
541 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
542 _percentages = _percentages + [u""]*(5-len(_percentages))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
543 _percentage_titles = [ "CI", "GG", "BI", "BAJA", "IVA" ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
544 _percentage_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
545 for _percentage_index in range(len(_percentages)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
546 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
547 _percentage = int(_percentages[_percentage_index])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
548 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
549 _percentage = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
550 _percentage_dict[_percentage_titles[_percentage_index]] = \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
551 _percentage
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
552 self.__budget.setPercentages(_percentage_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
553 # _____Field 0 and 1_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
554 # Default number of decimal places
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
555 # Number of titles in ~V record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
556 _title_num = len(self.__budget.getTitleList()[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
557 if _title_num == 0: _title_num = 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
558 # If the field 2 is empty, the field 0 is readed
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
559 if _field2 == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
560 # _____Field 0_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
561 if _field0[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
562 _field0 = _field0[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
563 # if there are a \ character at the end it must be erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
564 _decimal_list = _field0.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
565 _decimal_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
566 if len(_decimal_list)%9 != 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
567 # if it is not multiple of 9, empty subfield are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
568 _decimal_list = _decimal_list + [""]*(9 - \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
569 len(_decimal_list)%9)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
570 # The number of decimal values is the same as the numbers of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
571 # titles in the V record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
572 if len(_decimal_list)//9 > _title_num:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
573 _decimal_list = _decimal_list[:_title_num*9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
574 elif len(_decimal_list)//9 < _title_num:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
575 _decimal_list = _decimal_list + _decimal_list[-9:] * \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
576 (_title_num-(len(_decimal_list)//9))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
577 while _decimal_index <= len(_decimal_list)-9:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
578 _decimals = _decimal_list[_decimal_index:(_decimal_index + 9)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
579 _forlist = range(len(_decimals)-1)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
580 for _index in range(len(_decimals)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
581 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
582 #TODO: test this
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
583 _decimals[_index] = int(_decimals[_index])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
584 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
585 _decimals[_index] = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
586 _DN = _decimals[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
587 _DD = _decimals[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
588 _DS = _decimals[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
589 _DR = _decimals[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
590 _DI = _decimals[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
591 _DP = _decimals[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
592 _DC = _decimals[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
593 _DM = _decimals[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
594 _DIVISA = _decimals[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
595 _percentage_dict = {"DN" : _DN,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
596 "DD" : _DD,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
597 "DSP" : _DS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
598 "DS" : _DS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
599 "DFC" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
600 "DFPU" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
601 "DFUO" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
602 "DFA" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
603 "DRC" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
604 "DRPU" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
605 "DRUO" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
606 "DRA" : _DR,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
607 "DP" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
608 "DC" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
609 "DPU" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
610 "DUO" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
611 "DEA" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
612 "DES" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
613 "DIR" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
614 "DIRC" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
615 "DCD" : _DP,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
616 "DIVISA": _DIVISA }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
617 _decimal_index = _decimal_index + 9
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
618 self.__budget.setDecimals(_percentage_dict,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
619 (_decimal_index//9))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
620 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
621 # _____Field 3_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
622 if _field2[-1] == "\\":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
623 _field2 = _field2[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
624 # if there are a \ character at the end it must be erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
625 _decimal_list = _field2.split("\\")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
626 # test if the Divisa subfield is 12 or 14 position
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
627 # Divisa is the only Alphanumeric subfield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
628 # "no_float": "[^0-9.]"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
629 if len(_decimal_list) >= 13 and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
630 self.__pattern["no_float"].search(_decimal_list[12]):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
631 _multiple = 13
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
632 elif len(_decimal_list) >= 15 and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
633 self.__pattern["no_float"].search(_decimal_list[14]):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
634 _multiple = 15
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
635 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
636 if self.__file_format == "FIEBDC-3/2002":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
637 _multiple = 13
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
638 elif self.__file_format == "FIEBDC-3/2004":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
639 _multiple = 13
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
640 elif self.__file_format == "FIEBDC-3/2007":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
641 _multiple = 15
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
642 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
643 _multiple = 15
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
644 _decimal_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
645 if len(_decimal_list)%_multiple != 0 :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
646 # if it is not multiple of _multiple, empty subfield are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
647 _decimal_list = _decimal_list + \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
648 [""]*(_multiple-len(_decimal_list)%_multiple)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
649 # The number of decimal values is the same as the numbers of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
650 # titles in the V record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
651 if len(_decimal_list)//_multiple > _title_num:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
652 _decimal_list = _decimal_list[:_title_num*_multiple]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
653 elif len(_decimal_list)//_multiple < _title_num:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
654 _decimal_list = _decimal_list + [_decimal_list[-_multiple:]]*\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
655 (_title_num-(len(_decimal_list)//_multiple))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
656 while _decimal_index <= len(_decimal_list)-_multiple:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
657 _decimals = _decimal_list[_decimal_index:(_decimal_index +\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
658 _multiple)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
659 for _index in range(len(_decimals)-1):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
660 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
661 _decimals[_index] = int(_decimals[_index])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
662 except:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
663 _decimals[_index] = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
664 if _multiple == 13:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
665 _DRC = _decimals[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
666 _DC = _decimals[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
667 _DRO = _decimals[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
668 _DFS = _decimals[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
669 _DRS = _decimals[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
670 _DFO = _decimals[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
671 _DUO = _decimals[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
672 _DI = _decimals[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
673 _DES = _decimals[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
674 _DN = _decimals[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
675 _DD = _decimals[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
676 _DS = _decimals[11]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
677 _DIVISA = _decimals[12]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
678 _percentage_dict = {
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
679 "DN" : _DN,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
680 "DD" : _DD,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
681 "DSP" : _DS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
682 "DS" : _DS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
683 "DFC" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
684 "DFPU" : _DRC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
685 "DFUO" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
686 "DFA" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
687 "DRC" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
688 "DRPU" : _DRC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
689 "DRUO" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
690 "DRA" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
691 "DP" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
692 "DC" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
693 "DPU" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
694 "DUO" : _DUO,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
695 "DEA" : _DES,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
696 "DES" : _DES,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
697 "DIR" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
698 "DIRC" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
699 "DCD" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
700 "DIVISA": _DIVISA,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
701 }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
702 else: # _multiple == 15:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
703 _DRC = _decimals[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
704 _DC = _decimals[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
705 _DRO = _decimals[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
706 _DFS = _decimals[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
707 _DRS = _decimals[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
708 _DFO = _decimals[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
709 _DUO = _decimals[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
710 _DI = _decimals[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
711 _DES = _decimals[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
712 _DN = _decimals[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
713 _DD = _decimals[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
714 _DS = _decimals[11]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
715 _DSP = _decimals[12]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
716 _DEC = _decimals[13]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
717 _DIVISA = _decimals[14]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
718 _percentage_dict = {
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
719 "DN" : _DN,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
720 "DD" : _DD,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
721 "DSP" : _DSP,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
722 "DS" : _DS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
723 "DFC" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
724 "DFPU" : _DRC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
725 "DFUO" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
726 "DFA" : _DFS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
727 "DRC" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
728 "DRPU" : _DRC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
729 "DRUO" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
730 "DRA" : _DRS,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
731 "DP" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
732 "DC" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
733 "DPU" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
734 "DUO" : _DUO,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
735 "DEA" : _DEC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
736 "DES" : _DES,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
737 "DIR" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
738 "DIRC" : _DC,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
739 "DCD" : _DI,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
740 "DIVISA": _DIVISA}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
741 _decimal_index = _decimal_index + 13
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
742 self.__budget.setDecimals(_percentage_dict,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
743 (_decimal_index//13))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
744 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
745
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
746 def _parseC(self, field_list, interface):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
747 """_parseC(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
748
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
749 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
750 0- C: Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
751 1- Code{\Code}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
752 2- [Unit]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
753 3- [Summary]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
754 4- {Price\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
755 5- {Date\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
756 6- [Type]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
757 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
758 # _____number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
759 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
760 if len(field_list) > 7:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
761 field_list = field_list[:7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
762 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
763 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
764 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
765 field_list = field_list + [u""]*(7-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
766 # control character are erased: en of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
767 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
768 _record_type = field_list[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
769 _codes = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
770 _unit = self.delete_control_space(field_list[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
771 _summary = self.delete_control(field_list[3])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
772 _prices = self.delete_control_space(field_list[4])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
773 _dates = self.delete_control_space(field_list[5])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
774 _type = self.delete_control_space(field_list[6])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
775 # _____Code_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
776 _codes = _codes.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
777 if len(_codes) > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
778 # parse the hierarchy of the first code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
779 # hierarchy: 0->root, 1->Chapter/subchapter, 2->other
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
780 if len(_codes[0]) > 1 and _codes[0][-2:] == u"##":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
781 _hierarchy = 0
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
782 elif len(_codes[0]) > 0 and _codes[0][-1:] == u"#":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
783 _hierarchy = 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
784 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
785 _hierarchy = 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
786 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
787 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
788 # maximun len 20 characters
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
789 _codes = [self.validateCode(_code) for _code in _codes]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
790 # empty codes are ignored
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
791 while u"" in _codes:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
792 _codes.remove(u"")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
793 if len(_codes) > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
794 #TODO: test this
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
795 _code = _codes[0]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
796 _synonyms = [synonym.encode("utf8") for synonym in _codes]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
797 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
798 print(_("Record C without a valid code") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
799 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
800 # _____Unit_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
801 # nothing to do
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
802 # _____Summary_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
803 # nothing to do
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
804 # _____Price_____ and _____Dates_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
805 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
806 if len(_dates) > 0 and _dates[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
807 _dates = _dates[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
808 if len(_prices) > 0 and _prices[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
809 _prices = _prices[:-1]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
810 interface.updateGui()
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
811 _dates = _dates.split(u"\\")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
812 _prices = _prices.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
813 # number of prices = number of titles in "V" line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
814 # if there are no sufficient prices it takes the last price defined
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
815 _title_num = len(self.__budget.getTitleList()[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
816 if _title_num == 0: _title_num = 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
817 if len(_prices) > _title_num: _prices = _prices[:_title_num]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
818 elif len(_prices) < _title_num:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
819 _prices = _prices + [_prices[-1]]*(_title_num-len(_prices))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
820 # number of dates = number of prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
821 # if there are no sufficient dates it takes the last date defined
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
822 if len(_dates) > len(_prices): _dates = _dates[:len(_prices)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
823 elif len(_dates) < len(_prices):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
824 _dates = _dates + [_dates[-1]]*(len(_prices)-len(_dates))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
825 for _index in range(len(_prices)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
826 # TODO: lack to specify the number of decimals of the price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
827 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
828 _prices[_index] = float(_prices[_index])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
829 except:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
830 _prices[_index] = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
831 _parsed_date = self.parseDate(_dates[_index])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
832 if _parsed_date is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
833 _dates[_index] = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
834 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
835 _dates[_index] = _parsed_date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
836 # _____Type_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
837 # 0 Without classifying
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
838 # EA Auxiliary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
839 # EU Unitary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
840 # EC Complex element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
841 # EF Functional element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
842 # OB Construction site
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
843 # PA Cost overrun
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
844 # PU Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
845 # 1 Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
846 # H Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
847 # 2 Machinery and auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
848 # Q Machinery
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
849 # % Auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
850 # 3 Building materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
851 # MC Cement
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
852 # MCr Ceramic
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
853 # MM Wood
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
854 # MS Iron and steel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
855 # ME Energy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
856 # MCu Copper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
857 # MAl Aluminium
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
858 # ML Bonding agents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
859 # M Others materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
860 # Hierarchy type subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
861 # 0->root -> 0 -> None,OB
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
862 # 1->[sub]chapter -> 0 -> None,PU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
863 # 2->Other -> 0 -> None,EA,EU,EC,EF,PA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
864 # 1 -> None,H
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
865 # 2 -> None,Q,%
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
866 # 3 -> None,MC,MCr,MM,MS,ME,MCu,Mal,ML,M
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
867 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
868 if _hierarchy == 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
869 if _type == u"OB":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
870 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
871 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
872 elif _type == u"0" or _type == u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
873 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
874 _type = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
875 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
876 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
877 (_type.encode("utf8"), _code.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
878 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
879 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
880 elif _hierarchy == 1:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
881 if _type == u"PU":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
882 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
883 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
884 elif _type == u"0" or _type == u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
885 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
886 _type = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
887 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
888 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
889 (_type.encode("utf8"), _code.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
890 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
891 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
892 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
893 if _type == u"EA" or _type == u"EU" or _type == u"EC" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
894 _type == u"EF" or _type == u"PA":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
895 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
896 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
897 elif _type == u"H":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
898 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
899 _type = 1
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
900 elif _type == u"Q" or _type == u"%":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
901 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
902 _type = 2
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
903 elif _type == u"MC" or _type == u"MCr" or _type == u"MM" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
904 _type == u"MS" or _type == u"ME" or _type == u"MCu" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
905 _type == u"Mal" or _type == u"ML" or _type == u"M":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
906 _subtype = _type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
907 _type = 3
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
908 elif _type == u"0" or _type == u"1" or _type == u"2" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
909 _type == u"3":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
910 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
911 _type = int(_type)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
912 elif _type == u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
913 _subtype = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
914 _type = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
915 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
916 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
917 (_type.encode("utf8"), _code.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
918 _type = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
919 _subtype = u""
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
920 self.__budget.setRecord(_code.encode("utf8"), _synonyms, _hierarchy,
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
921 _unit.encode("utf8"), _summary.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
922 _prices, _dates, _type, _subtype.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
923 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
924
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
925 def _parseDY(self, field_list, interface):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
926 """_parseDY(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
927
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
928 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
929 0- D or Y: DECOMPOSITION or ADD DECOMPOSITION
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
930 1- Parent Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
931 2- <Child Code\ [Factor]\ [Yield]>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
932 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
933 # _____number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
934 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
935 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
936 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
937 field_list = field_list[:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
938 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
939 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
940 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
941 field_list = field_list + [u""]*(3-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
942 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
943 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
944 _record_type = field_list[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
945 _code = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
946 _children = self.delete_control_space(field_list[2])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
947 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
948 # _____Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
949 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
950 # invalid characters are also erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
951 _code = self.validateCode(_code)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
952 # _____children_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
953 # TODO: test the number of decimals in factor an yield values
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
954 _children = _children.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
955 _children_list = [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
956 _child_index = 0
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
957 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
958 while _child_index < len(_children)-3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
959 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
960 _child_code = _children[_child_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
961 _factor = _children[_child_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
962 _yield = _children[_child_index+2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
963 # _____child_code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
964 _child_code = self.validateCode(_child_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
965 # _____factor_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
966 if _factor != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
967 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
968 _factor = float(_factor)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
969 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
970 print(utils.mapping(_("ValueError loadig the "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
971 "descomposition of the record $1, the factor "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
972 "of the child $2 must be a float number and "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
973 "can not be $3, seted default value 1.0"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
974 (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
975 _factor = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
976 #____yield___
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
977 if _yield != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
978 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
979 _yield = float(_yield)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
980 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
981 print(utils.mapping(_("ValueError loading the "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
982 "descomposition of the record $1, the yield of "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
983 "the child $2, must be a float number and can"\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
984 "not be $3, seted default value 1.0"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
985 (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
986 _yield = 1.0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
987 if _child_code != u"" and _code != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
988 _children_list.append([_child_code, _factor, _yield ])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
989 if _record_type == u"D":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
990 _position = _child_index / 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
991 else: #_record_type == "Y"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
992 _position = -1
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
993 self.__budget.setTree(_code.encode("utf8"), _child_code.encode("utf8"), _position, _factor,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
994 _yield, "", "", "", "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
995 _child_index = _child_index + 3
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
996 interface.updateGui()
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
997 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
998
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
999 def _parseT(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1000 """_parseT(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1001
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1002 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1003 0- T: Text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1004 1- Record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1005 2- Description text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1006 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1007 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1008 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1009 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1010 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1011 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1012 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1013 if len(field_list) != 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1014 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1015 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1016 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1017 _code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1018 _text = field_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1019 # _____Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1020 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1021 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1022 _code = self.validateCode(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1023 # _____Text_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1024 self.__budget.setText(_code.encode("utf8"), _text.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1025 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1026
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1027 def _parseMN(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1028 """_parseMN(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1029
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1030 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1031 0- M or N: MEASURE or ADD MEASURE
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1032 1- [Parent Code\]Child Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1033 2- {Path\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1034 3- TOTAL MEASURE
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1035 4- {Type\Comment\Unit\Length\Width\Height\}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1036 5- [Label]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1037 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1038 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1039 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1040 # The record must have 6 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1041 if len(field_list) > 6:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1042 field_list = field_list[:6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1043 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1044 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1045 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1046 field_list = field_list + [u""]*(6-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1047 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1048 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1049 _record_type = field_list[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1050 _codes = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1051 _path = self.delete_control_space(field_list[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1052 _total = self.delete_control_space(field_list[3])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1053 _lines = self.delete_control(field_list[4])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1054 _label = self.delete_control_space(field_list[5])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1055 # _____Codes_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1056 _code_list = _codes.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1057 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1058 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1059 if len(_code_list) == 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1060 _parent_code = self.validateCode(_code_list[0])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1061 if _parent_code == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1062 _parent_code = None
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1063 else:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1064 _parent_code = _parent_code.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1065 _child_code = self.validateCode(_code_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1066 elif len(_code_list) == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1067 _child_code = self.validateCode(_code_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1068 _parent_code = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1069 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1070 print(utils.mapping(_("Invalid codes in $1 record, codes $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1071 (_record_type.encode("utf8"), _codes.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1072 return
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1073 if _child_code == u"":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1074 print(utils.mapping(_("Empty child code in $1 record, codes: "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1075 "$2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1076 return
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1077 if _parent_code == None:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1078 # Empty parent code. No-estructured measures.
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1079 pass
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1080
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1081 # _____Path_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1082 _path_list = _path.split( u"\\" )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1083 if len(_path_list) > 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1084 while len(_path_list) > 0 and _path_list[-1] == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1085 _path_list = _path_list[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1086 if len(_path_list) == 0:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1087 # Empty path. No-estructured measures. Path fixed to -2
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1088 _path = -2
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1089 else:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1090 _path = _path_list[-1]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1091 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1092 _path = int(_path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1093 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1094 print(utils.mapping(_("Invalid path in $1 record, "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1095 "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1096 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1097 if _path > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1098 _path -= 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1099 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1100 _path = -2
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1101 # _____Total_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1102 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1103 _total = float(_total)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1104 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1105 print(utils.mapping(_("Invalid Total Measure value in $1 "\
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1106 "record, codes $2. Total fixed to 0."),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1107 (_record_type.encode("utf8"), _codes.encode("utf8"))) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1108 _total = 0
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1109 # _____Measure lines_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1110 _lines = _lines.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1111 _line_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1112 _line_list = [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1113 while _line_index < len(_lines)-6:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1114 _linetype = _lines[_line_index]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1115 if _linetype == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1116 _linetype = 0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1117 elif _linetype == u"1" or _linetype == u"2" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1118 _linetype == u"3":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1119 _linetype = int(_linetype)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1120 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1121 _linetype = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1122 _comment= _lines[_line_index + 1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1123 if _linetype == 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1124 # "formula": ".*[^0123456789\.()\+\-\*/\^abcdp ].*"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1125 if self.__pattern["formula"].match(_comment):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1126 print(utils.mapping(_("The comment is not a formula or "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1127 "its have invalid characters, in the $1 record, "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1128 "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1129 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1130 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1131 _formula = _comment.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1132 _comment = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1133 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1134 _formula = ""
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1135 _comment = _comment.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1136 _units = _lines[_line_index + 2]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1137 _units = self.__pattern["no_float"].sub(u"", _units)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1138 _length = _lines[_line_index + 3]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1139 _length = self.__pattern["no_float"].sub(u"", _length)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1140 _width = _lines[_line_index + 4]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1141 _width = self.__pattern["no_float"].sub(u"", _width)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1142 _height = _lines[_line_index + 5]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1143 _height = self.__pattern["no_float"].sub(u"", _height)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1144
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1145 try:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1146 if _units != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1147 _units = float(_units)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1148 if _length != u"": _length = float(_length)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1149 if _width != u"": _width = float(_width)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1150 if _height != u"": _height = float(_height)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1151 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1152 print(utils.mapping(_("The measure values are not float "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1153 "numbers, code $1"), (_codes.encode("utf8"),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1154 return
20
f5ec50b625d1 Prevent subfield units remains empty
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 19
diff changeset
1155 # Prevent subfield units remains empty.
f5ec50b625d1 Prevent subfield units remains empty
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 19
diff changeset
1156 if (_units == u"" and (_length != u"" or _width != u""
f5ec50b625d1 Prevent subfield units remains empty
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 19
diff changeset
1157 or _height != u"")):
f5ec50b625d1 Prevent subfield units remains empty
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 19
diff changeset
1158 _units = 1.0
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1159 _line_list.append([_linetype, _comment, _units,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1160 _length, _width, _height, _formula])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1161 _line_index = _line_index + 6
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1162 self.__budget.setTree(_parent_code, _child_code.encode("utf8"), _path, "", "",
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1163 _total, _line_list, _label.encode("utf8"), _record_type.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1164 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1165
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1166 def _parseW(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1167 """_parseW(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1168
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1169 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1170 0- W: Geografical field
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1171 1- Field Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1172 2- Field
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1173 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1174 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1175 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1176 # The record must have 2 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1177 if len(field_list) >= 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1178 field_list = field_list[1:2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1179 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1180 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1181 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1182 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1183 _code_fields = field_list[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1184 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1185 if len(_code_fields) and _code_fields[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1186 _code_fields = _code_fields[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1187 _code_fields = _code_fields.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1188 _field_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1189 _field_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1190 while _field_index < len(_code_fields)-1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1191 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1192 _field_code = _code_fields[_field_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1193 _field_title = _code_fields[_field_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1194 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1195 # _____section_code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1196 #"control": "[\t \n\r]"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1197 _field_code = self.delete_control_space(_field_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1198 # _____section_title_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1199 if _field_code != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1200 _field_dict[_field_code.encode("utf8")] = _field_title.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1201 _field_index = _field_index + 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1202 self.__budget.setSheetFields(_field_dict)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1203 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1204
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1205 def _parseL(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1206 """_parseL(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1207
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1208 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1209 0- L: Sheet of Conditions 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1210 A:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1211 1- Empty
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1212 2- {Section Code\Section Title}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1213 B:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1214 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1215 2- {Section Code\Section Text}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1216 3- {Section Code\RTF file}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1217 4- {Section Code\HTM file}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1218 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1219 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1220 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1221 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1222 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1223 _code = field_list[1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1224 if _code == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1225 # A: Section Titles
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1226 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1227 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1228 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1229 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1230 field_list = field_list[1:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1231 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1232 _section_codes = field_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1233 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1234 if len(_section_codes) and _section_codes[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1235 _section_codes = _section_codes[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1236 _section_codes = _section_codes.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1237 _section_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1238 _section_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1239 while _section_index < len(_section_codes)-1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1240 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1241 _section_code = _section_codes[_section_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1242
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1243 _section_title = _section_codes[_section_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1244 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1245 # _____section_code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1246 _section_code = self.delete_control_space(_section_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1247 # _____section_title_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1248 _section_title = self.delete_control_space(_section_title)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1249 if _section_code != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1250 _section_dict[_section_code.encode("utf8")] = _section_title.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1251 _section_index = _section_index + 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1252 self.__budget.setSheetSections(_section_dict)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1253 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1254
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1255 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1256 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1257 # The record must have 5 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1258 if len(field_list) > 5:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1259 field_list = field_list[0:5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1260 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1261 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1262 # _____Record Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1263 _record_code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1264 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1265 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1266 _record_code = self.validateCode(_record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1267 _scodes_text = field_list[1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1268 if _scodes_text == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1269 # TODO: rtf and html files
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1270 print("Html and rtf files not yet implemented in ~L record" )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1271 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1272 # _____Section-code_Section-text_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1273 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1274 if len(_scodes_text) and _scodes_text[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1275 _scodes_text = _scodes_text[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1276 _scodes_text = _scodes_text.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1277 _paragraph_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1278 _section_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1279 _section_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1280 while _section_index < len(_scodes_text)-1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1281 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1282 _section_code = _scodes_text[_section_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1283 _section_text = _scodes_text[_section_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1284 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1285 # _____section_code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1286 _section_code = self.delete_control_space(_section_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1287 # _____section_text_____
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1288 if _section_code != u"" and _section_text != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1289 #-# paragraph #-#
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1290 _paragraph_code = _record_code + _section_code + u"*"
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1291 _paragraph_dict[ _paragraph_code.encode("utf8") ] = _section_text.encode("utf8")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1292 _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1293 _section_index = _section_index + 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1294 self.__budget.setSheetParagraphs(_paragraph_dict)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1295 self.__budget.setSheetRecord(_record_code.encode("utf8"), "*", _section_dict)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1296 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1297
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1298 def _parseQ(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1299 """_parseQ(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1300
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1301 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1302 0- Q: Sheet of Conditions 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1303 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1304 2- {Section Code\Paragraph key\{Field key;}\}|
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1305 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1306 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1307 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1308 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1309 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1310 _code = field_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1311 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1312 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1313 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1314 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1315 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1316 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1317 # _____Record Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1318 _record_code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1319 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1320 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1321 _record_code = self.validateCode(_record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1322 _scodes_pkey = field_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1323 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1324 if len(_scodes_pkey) and _scodes_pkey[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1325 _scodes_pkey = _scodes_pkey[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1326 _scodes_pkey = _scodes_pkey.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1327 _field_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1328 _section_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1329 while _section_index < len(_scodes_pkey) -1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1330 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1331 _section_code = _scodes_pkey[_section_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1332 _paragraph_key = _scodes_text[_section_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1333 _field_keys = _scodes_text[_section_index+2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1334 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1335 # _____section_code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1336 _section_code = self.delete_control_space(_section_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1337 # _____section_text_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1338 _paragraph_key = self.delete_control_space(_paragraph_key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1339 # _____Fields keys_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1340 _field_keys = self.delete_control_space(_field_keys)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1341 # last ; is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1342 if len(_field_keys) and _field_keys[-1] == u";":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1343 _field_keys = _field_keys[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1344 _field_keys_list = _scodes_pkey.split(u";")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1345 for _field_key in _field_keys_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1346 if _field_key != u"" and _section_code != u"" and \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1347 _paragraph_key != u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1348 if _field_key in _field_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1349 _section_dict = _field_dict[_field_key]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1350 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1351 _section_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1352 _field_dict[_field_key] = _section_dict
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1353 _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1354 _section_index = _section_index + 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1355 for _field, _section_dict in _field_dict.iteritems():
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1356 self.__budget.setSheetRecord(_record_code.encode("utf8"), _field.encode("utf8"), _section_dict)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1357 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1358
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1359 def _parseJ(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1360 """_parseJ(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1361
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1362 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1363 0- J: Sheet of Conditions 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1364 1- Paragraph code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1365 2- [Paragraph text]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1366 3- [RTF file]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1367 4- [HTML file]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1368 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1369 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1370 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1371 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1372 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1373 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1374 # The record must have 5 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1375 if len(field_list) > 5:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1376 field_list = field_list[0:5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1377 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1378 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1379 # _____Paragraph code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1380 _paragraph_code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1381 # _____Paragraph text_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1382 _paragraph_text = field_list[1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1383 if _paragraph_text == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1384 # TODO: rtf and html files
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1385 print("Html and rtf files not yet implemented in ~J record" )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1386 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1387 self.__budget.setSheetParagraph(paragraph_code.encode("utf8"), paragraph_text.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1388 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1389
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1390 def _parseG(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1391 """_parseG(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1392
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1393 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1394 0- G: Grafic info
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1395 1- record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1396 2- <grafic_file.ext\>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1397 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1398 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1399 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1400 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1401 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1402 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1403 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1404 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1405 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1406 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1407 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1408 # _____Record Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1409 _record_code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1410 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1411 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1412 _record_code = self.validateCode(_record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1413 # _____Grafic files_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1414 _grafic_files = self.delete_control(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1415 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1416 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1417 if len(_grafic_files) and _grafic_files[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1418 _grafic_files = _grafic_files[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1419 _grafic_file_list = _grafic_files.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1420 _tested_grafic_file_list = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1421 for _grafic_file in _grafic_file_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1422 _str_grafic_file = _grafic_file.encode("utf8")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1423 _path = os.path.dirname(self.__filename).encode("utf8")
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1424 _grafic_file_path = os.path.join(_path, _str_grafic_file)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1425 if os.path.exists(_grafic_file_path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1426 _tested_grafic_file_list.append(_grafic_file_path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1427 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1428 _name_ext = os.path.splitext(_str_grafic_file)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1429 _grafic_file_name = _name_ext[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1430 _grafic_file_ext = _name_ext[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1431 _grafic_file_name_u = _grafic_file_name.upper()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1432 _grafic_file_name_l = _grafic_file_name.lower()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1433 _grafic_file_ext_u = _grafic_file_ext.upper()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1434 _grafic_file_ext_l = _grafic_file_ext.lower()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1435 _uu = _grafic_file_name_u + _grafic_file_ext_u
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1436 _ul = _grafic_file_name_u + _grafic_file_ext_l
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1437 _lu = _grafic_file_name_l + _grafic_file_ext_u
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1438 _ll = _grafic_file_name_l + _grafic_file_ext_l
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1439 _grafic_file_path_uu = os.path.join(_path, _uu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1440 _grafic_file_path_ul = os.path.join(_path, _ul)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1441 _grafic_file_path_lu = os.path.join(_path, _lu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1442 _grafic_file_path_ll = os.path.join(_path, _ll)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1443 if os.path.exists(_grafic_file_path_uu):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1444 _tested_grafic_file_list.append(_grafic_file_path_uu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1445 elif os.path.exists(_grafic_file_path_ul):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1446 _tested_grafic_file_list.append(_grafic_file_path_ul)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1447 elif os.path.exists(_grafic_file_path_lu):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1448 _tested_grafic_file_list.append(_grafic_file_path_lu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1449 elif os.path.exists(_grafic_file_path_ll):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1450 _tested_grafic_file_list.append(_grafic_file_path_ll)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1451 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1452 print(utils.mapping(_("The file $1 do not exist"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1453 (_grafic_file_path.decode("utf8"),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1454 if len(_grafic_file_list) > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1455 for _grafic_file in _tested_grafic_file_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1456 self.__budget.addFile(_record_code.encode("utf8"), _grafic_file, "img", "")
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1457 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1458
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1459 def _parseE(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1460 """_parseE(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1461
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1462 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1463 0- E: Company
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1464 1- company Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1465 2 [ summary ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1466 3- [ name ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1467 4- { [ type ] \ [ subname ] \ [ address ] \ [ postal_code ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1468 \ [ town ] \ [ province ] \ [ country ] \ { phone; }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1469 \ { fax; } \ {contact_person; } \ }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1470 5- [ cif ] \ [ web ] \ [ email ] \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1471 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1472
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1473 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1474 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1475 # The record must have 6 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1476 if len(field_list) > 6:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1477 field_list = field_list[1:6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1478 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1479 # with empty value:""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1480 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1481 field_list = field_list[1:] + [u""]*(6-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1482 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1483 # _____company Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1484 _company_code = self.delete_control_space(field_list[0])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1485 if _company_code == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1486 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1487 # _____Summary_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1488
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1489 _sumamary = self.delete_control(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1490 # _____Name_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1491 _name = self.delete_control(field_list[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1492 # _____local_offices_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1493 _local_offices = self.delete_control(field_list[3])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1494 # _____subfields of local_offices_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1495 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1496 if len(_local_offices) and _local_offices[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1497 _local_offices = _local_offices[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1498 _local_offices_list = _local_offices.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1499 # If there are no sufficent subfields, the subfields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1500 # whith empty value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1501 _nsub = len(_local_offices_list) % 10
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1502 if _nsub != 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1503 _local_offices_list = _local_offices_list + \
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1504 [u""]*(10-len(field_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1505 _local_offices = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1506 _local_offices_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1507 while _local_offices_index < len(_local_offices_list)-9:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1508 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1509 _type = _local_offices_list[_local_offices_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1510 _subname = _local_offices_list[_local_offices_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1511 _address = _local_offices_list[_local_offices_index+2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1512 _postal_code = _local_offices_list[_local_offices_index+3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1513 _town = _local_offices_list[_local_offices_index+4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1514 _province = _local_offices_list[_local_offices_index+5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1515 _country = _local_offices_list[_local_offices_index+6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1516 _phone = _local_offices_list[_local_offices_index+7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1517 # last ; is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1518 if len(_phone) and _phone[-1] == u";":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1519 _phone = _phone[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1520 _phone_list = _phone.split(u";")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1521 _phone_list = [_phone.encode("utf8") for _phone in _phone_list]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1522 _fax = _local_offices_list[_local_offices_index+8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1523 # last ; is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1524 if len(_fax) and _fax[-1] == u";":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1525 _fax = _fax[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1526 _fax_list = _fax.split(u";")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1527 _fax_list = [_fax.encode("utf8") for _fax in _fax_list]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1528 _contact_person = _local_offices_list[_local_offices_index+9]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1529 if _type != u"" or _subname != u"" or _address != u"" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1530 _postal_code != u"" or _town != u"" or _province != u"" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1531 _country != u"" or _phone != u"" or _fax != u"" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1532 _contact_person != u"":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1533 _local_offices.append([_type.encode("utf8"), _subname.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1534 _address.encode("utf8"), _postal_code.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1535 _town.encode("utf8"), _province.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1536 _country.encode("utf8"), _phone_list,
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1537 _fax_list, _contact_person.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1538 _local_offices_index = _local_offices_index + 10
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1539 # _____cif web email_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1540 _c_w_e = self.delete_control_space(field_list[4])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1541 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1542 if len(_c_w_e) and _c_w_e[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1543 _c_w_e = _c_w_e[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1544 _c_w_e_list = _c_w_e.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1545 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1546 # If there are no sufficient fields, the fields are added
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1547 # with empty value:""
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1548 _c_w_e_list = _c_w_e_list + [u""]*(3-len(_c_w_e_list))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1549 _cif = _c_w_e_list[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1550 _web = _c_w_e_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1551 _email = _c_w_e_list[2]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1552 self.__budget.setCompany(_company_code.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1553 _sumamary.encode("utf8"), _name.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1554 _local_offices, _cif.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1555 _web.encode("utf8"), _email.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1556 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1557
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1558 def _parseX(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1559 """_parseX(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1560
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1561 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1562 A)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1563 0- X: Tecnical information
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1564 1- Empty
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1565 2- < TI_Code \ TI_Descitption \ TI_Unit >
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1566 B)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1567 0- X: Tecnical information
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1568 1- Record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1569 2- < TI_Code \ TI_value >
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1570 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1571 # Tecnical information
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1572 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1573 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1574 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1575 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1576 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1577 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1578 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1579 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1580 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1581 # "control": "[\t \n\r]"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1582 _field_1 = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1583 _field_2 = self.delete_control_space(field_list[1])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1584 if _field_1 == u"":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1585 # A)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1586 _field_2_list = _field_2.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1587 _ti_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1588 while _ti_index < len(_field_2_list)-3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1589 _ti_code = _field_2_list[_ti_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1590 _ti_description = _field_2_list[_ti_index+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1591 _ti_unit = _field_2_list[_ti_index+2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1592 if _ti_code != "":
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1593 self.__budget.addTecInfo(_ti_code.encode("utf8"), _ti_description.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1594 _ti_unit.encode("utf8"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1595 _ti_index = _ti_index + 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1596 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1597 # B)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1598 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1599 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1600 _record_code = self.validateCode(_field_1)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1601 _field_2_list = _field_2.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1602 _ti_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1603 _ti_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1604 while _ti_index < len(_field_2_list)-2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1605 _ti_code = _field_2_list[_ti_index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1606 _ti_value = _field_2_list[_ti_index+1]
18
878159a13494 bug fix: except raise when parses X records importing fiebdc files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
1607 if _ti_code != u"" and _ti_value != u"":
878159a13494 bug fix: except raise when parses X records importing fiebdc files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
1608 _ti_dict[_ti_code.encode("utf8")] = _ti_value.encode("utf8")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1609 _ti_index = _ti_index + 2
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1610 self.__budget.setTecnicalInformation(_record_code.encode("utf8"), _ti_dict)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1611 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1612
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1613 def _parseF(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1614 """_parseF(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1615
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1616 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1617 0- F: Files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1618 1- Record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1619 2- { Type \ { Filenames; } \ [Description] }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1620 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1621 print("parseF")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1622 print(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1623 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1624 # The record must have at least 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1625 if len(field_list) < 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1626 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1627 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1628 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1629 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1630 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1631 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1632 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1633 # _____Record Code_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1634 _record_code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1635 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1636 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1637 _record_code = self.validateCode(_record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1638 # _____Grafic files_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1639 _files = self.delete_control(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1640 # _____subfields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1641 # last \ is erased
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1642 if len(_files) and _files[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1643 _files = _files[:-1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1644 _files_list = _files.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1645 # adding empty subfiels if necesary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1646 if len(_files_list)%3 > 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1647 _files_list.extend[u""]*(3 - len(_files_list)%3)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1648 _file_index = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1649 _tested_files_list = []
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1650 print(_files_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1651 while _file_index < len(_files_list)-3:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1652 _type = _files_list[_file_index].replace(u" ",u"")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1653 ## _types = {
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1654 ## "0": _("others"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1655 ## "1": _("características técnicas y de fabricación"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1656 ## "2": _("manual de colocación, uso y mantenimiento"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1657 ## "3": _("certificado/s de elementos y sistemas"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1658 ## "4": _("normativa y bibliografía"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1659 ## "5": _("tarifa de precios"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1660 ## "6": _("condiciones de venta"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1661 ## "7": _("carta de colores"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1662 ## "8": _("ámbito de aplicación y criterios selección"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1663 ## "9": _("cálculo de elementos y sistemas"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1664 ## "10": _("presentación, datos generales, objetivos, " \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1665 ## "etc. de empresa"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1666 ## "11": _("certificado/s de empresa"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1667 ## "12": _("obras realizadas")}
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1668 _types = [u"0", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"10",
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1669 u"11", u"12"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1670 if not _type in _types:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1671 _type = u"0"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1672 _filenames = _files_list[_file_index + 1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1673 _description = _files_list[_file_index + 2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1674 _file_index += 3
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1675 print(u"type: " + _type)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1676 print(u"filenames: " + _filenames)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1677 print(u"_description: " + _description)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1678 if len(_filenames) and _filenames[-1] == u";":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1679 _files = _files[:-1]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1680 _filenames_list = _filenames.split(u";")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1681
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1682 _path = os.path.dirname(self.__filename)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1683 for _filename in _filenames_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1684 _file_path = os.path.join(_path, _filename.encode("utf8"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1685 if os.path.exists(_file_path):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1686 _tested_files_list.append([_file_path, _type.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1687 _description.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1688 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1689 _name_ext = os.path.splitext(_filename)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1690 _file_name = _name_ext[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1691 _file_ext = _name_ext[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1692 _file_name_u = _file_name.upper()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1693 _file_name_l = _file_name.lower()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1694 _file_ext_u = _file_ext.upper()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1695 _file_ext_l = _file_ext.lower()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1696 _uu = _file_name_u + _file_ext_u
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1697 _ul = _file_name_u + _file_ext_l
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1698 _lu = _file_name_l + _file_ext_u
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1699 _ll = _file_name_l + _file_ext_l
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1700 _file_path_uu = os.path.join(_path, _uu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1701 _file_path_ul = os.path.join(_path, _ul)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1702 _file_path_lu = os.path.join(_path, _lu)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1703 _file_path_ll = os.path.join(_path, _ll)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1704 if os.path.exists(_file_path_uu):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1705 _tested_files_list.append([_file_path_uu, _type.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1706 _description.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1707 elif os.path.exists(_grafic_file_path_ul):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1708 _tested_files_list.append([_file_path_ul, _type.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1709 _description.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1710 elif os.path.exists(_grafic_file_path_lu):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1711 _tested_files_list.append([_file_path_lu, _type.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1712 _description.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1713 elif os.path.exists(_grafic_file_path_ll):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1714 _tested_files_list.append([_file_path_ll, _type.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1715 _description.encode("utf8")])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1716 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1717 print(utils.mapping(_("The file $1 do not exist"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1718 (_file_path,)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1719 if len(_tested_files_list) > 0:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1720 for _file in _tested_files_list:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1721 self.__budget.addFile(_record_code.encode("utf8"), _file[0], _file[1], _file[2])
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1722 self.__statistics.valid = self.__statistics.valid +1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1723
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1724 def _parseB(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1725 """_parseB(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1726
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1727 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1728 0- B: Change code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1729 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1730 2- New code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1731 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1732 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1733 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1734 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1735 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1736 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1737 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1738 if len(field_list) != 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1739 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1740 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1741 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1742 _code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1743 _new_code = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1744 # _____Codes_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1745 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1746 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1747 _code = self.validateCode(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1748 _new_code = self.validateCode(_new_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1749 # change code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1750 self.__budget.changeCode(_code, _new_code)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1751 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1752
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1753 def _parseA(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1754 """_parseA(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1755
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1756 field_list: field list of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1757 0- A: Labels
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1758 1- Record Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1759 2- <Label\>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1760 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1761 # _____Number of fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1762 # Any INFORMATION after last field separator is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1763 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1764 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1765 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1766 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1767 if len(field_list) != 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1768 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1769 # control character are erased: end of line, tab, space
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1770 # _____Fields_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1771 # "control": "[\t \n\r]"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1772 _code = self.delete_control_space(field_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1773 _labels = self.delete_control_space(field_list[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1774 # _____Codes_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1775 # "#" and "##" characters at the end of the code are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1776 # invalid characters are also erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1777 _code = self.validateCode(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1778 # _____Labels_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1779 # last \ is erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1780 # TODO: change the others parsers to this:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1781 while len(_labels) > 0 and _labels[-1] == u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1782 _labels = _labels[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1783 # replace "_" to " "
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1784 _labels = _labels.replace(u"_",u" ")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1785 _label_list = _labels.split(u"\\")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1786 for _label in _label_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1787 self.__budget.addLabel(_code.encode("utf8"), _label.encode("utf8"))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1788 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1789
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1790 def _parseP(self, field_list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1791 """_parseP(field_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1792
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1793 field_list: Parametric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1794 A) Global paremetric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1795 0- P: Parametric
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1796 1- Empty
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1797 2- [Parametric description]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1798 3- [library.DLL]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1799 B) Family Parametric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1800 0- P: Parametric
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1801 1- Family Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1802 2- [Parametric description]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1803 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1804 # TODO: Use global parametric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1805 if len(field_list) > 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1806 # delete control caracters and spaces
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1807 _family_code = self.delete_control_space(field_list[1])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1808 if _family_code == u"": # A)Global paremetric record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1809 # The record must have 3 or 4 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1810 if len(field_list) > 4:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1811 field_list = field_list[0:4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1812 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1813 if len(field_list) == 2:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1814 field_list.append(u"")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1815 if len(field_list) != 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1816 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1817 else: # B)Family Parametric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1818 # The record must have 3 fields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1819 if len(field_list) > 3:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1820 field_list = field_list[0:3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1821 field_list = field_list[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1822 if len(field_list) != 2:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1823 print(_("PyArq hates parametric DLLs") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1824 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1825 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1826 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1827 # _____Description_____
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1828 _description = field_list[1]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1829 if _description == u"":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1830 print(_("PyArq hates parametric DLLs") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1831 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1832 # Adding last end of line
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1833 _description = _description + u"\r\n"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1834 # Delete comments
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1835 # "comment" : "#.*\r\n"
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1836 _description = self.__pattern["comment"].sub(u"\r\n",_description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1837 # Tabs to spaces
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1838 _description = _description.replace(u"\t",u" ")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1839 # Delete empty lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1840 # "empty_line": r"(\r\n) *\r\n"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1841 while self.__pattern["empty_line"].search(_description):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1842 _description = self.__pattern["empty_line"].sub(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1843 lambda x: x.groups()[0], _description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1844 # Delete spaces before and after /
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1845 # "space_before_backslash" : r"( )+\\"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1846 _description = self.__pattern["space_before_backslash"].sub(
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1847 ur"\\",_description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1848 # "space_after_backslash" : r"\\( )+"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1849 _description = self.__pattern["space_after_backslash"].sub(
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1850 ur"\\",_description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1851 # Join lines that start but not end with /
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1852 _description = u"\r\n" + _description # add leading end of line
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1853 # "start_noend_backslash": "(\r\n\\\.*[^\\\])\r\n"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1854 while self.__pattern["start_noend_backslash"].search(_description):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1855 _description = self.__pattern["start_noend_backslash"].sub(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1856 lambda x: x.groups()[0], _description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1857 # Join lines that end with a + - * / ^ and @ & < > <= >= = <> !
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1858 # "end_oper" : "(\+|-|\*|/|/^|@|&|<|>|<=|>=|=|!) *\r\n"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1859 _description = self.__pattern["end_oper"].sub(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1860 lambda x: x.groups()[0], _description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1861 # Join lines for matricial vars
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1862 # matricial_var : "(\r\n *[%|\$][A-ZÑ].*=.*,) *\r\n"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1863 while self.__pattern["matricial_var"].search(_description):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1864 _description = self.__pattern["matricial_var"].sub(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1865 lambda x: x.groups()[0], _description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1866 _description = _description[2:] # remove leading end of line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1867 #_description = re.sub(r"\\( )+",r"\\",_description)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1868 _lines = _description.split(u"\r\n")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1869 _final_description = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1870 _pass_line = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1871 for index in range(len(_lines)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1872 _line = _lines[index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1873 # Parse lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1874 if len(_line) != 0: # Delete empty lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1875 if _pass_line > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1876 _pass_line = _pass_line -1
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1877 _line = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1878 elif _line.isspace():
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1879 _line = u""
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1880 elif _line[0] != u"\\":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1881 # Delete spaces out "" delimiter
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1882 _list = _line.split(u'"')
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1883 _final_line = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1884 for index1 in range(len(_list)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1885 if index1 % 2 != 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1886 _parcial_line = u'"' + _list[index1]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1887 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1888 _parcial_line = u'"' + _list[index1].replace(u" ",u"")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1889 _final_line = _final_line + _parcial_line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1890 _line = _final_line[1:]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1891 _lines[index] = _line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1892 # parse data
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1893 if len(_line) > 2 and _line[:2] == u"::":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1894 # Delete spaces out " delimiter
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1895 #print("__PRECIO__" + _line[2:])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1896 pass
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1897 elif len(_line) > 2 and _line[:2] == u"%:":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1898 # Delete spaces out " delimiter
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1899 #print("__%AUX__" + _line[2:])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1900 pass
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1901 elif len(_line) > 3 and _line[:2] == u"%%:":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1902 # Delete spaces out " delimiter
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1903 #print("__%%AUX__" + _line[2:] )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1904 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1905 elif self.__pattern["var"].search(_line):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1906 # Delete spaces out " delimiter
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1907 #print( "line =", _line )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1908 while _line.count(u'"') % 2 == 1 and \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1909 index + _pass_line + 1 < len(_lines) -1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1910 _line = _line + _lines[index + _pass_line + 1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1911 _pass_line = _pass_line + 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1912 _search = self.__pattern["var"].search(_line)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1913 if _search is not None:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1914 _var = _search.groups()[0] + u" = " + _search.groups()[1]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1915 #print("__VAR__" + str(_var) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1916 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1917 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1918 #print( "no __VAR__", _line )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1919 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1920 elif self.__pattern["descomposition"].search(_line):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1921 # Delete spaces out " delimiter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1922 #_patern = "(^[^:]*):(.*)$"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1923 _search = self.__pattern["descomposition"].search(_line)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1924 if _search is not None:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1925 _var = _search.groups()[0] + u":" + _search.groups()[1]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1926 #print( "__Descomposición__" + str(_var) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1927 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1928 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1929 #print("no __Descomposición__", _line )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1930 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1931 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1932 print("Parametric: code: " + _family_code.encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1933 print("******* Desconocido *** : " + _line )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1934 if index-10 > 0: print("-11 : " + _lines[index-11].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1935 if index-10 > 0: print("-10 : " + _lines[index-10].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1936 if index-9 > 0: print("-9 : " + _lines[index-9].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1937 if index-8 > 0: print("-8 : " + _lines[index-8].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1938 if index-7 > 0: print("-7 : " + _lines[index-7].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1939 if index-6 > 0: print("-6 : " + _lines[index-6].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1940 if index-5 > 0: print("-5 : " + _lines[index-5].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1941 if index-4 > 0: print("-4 : " + _lines[index-4].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1942 if index-3 > 0: print("-3 : " + _lines[index-3].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1943 if index-2 > 0: print("-2 : " + _lines[index-2].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1944 if index-1 > 0: print("-1 : " + _lines[index-1].encode("utf8") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1945 print("-0 :" + _lines[index-0] )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1946 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1947 else:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1948 _parameter_list = _line.split(u"\\")[1:-1]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1949 if len(_parameter_list) >= 2:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1950 if _parameter_list[0] == u"C" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1951 _parameter_list[0] == u"COMENTARIO":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1952 #print( "__COMENTARIO__" + _parameter_list[1])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1953 self.__budget.setParametricSelectComment(
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1954 _family_code.encode("utf8"), _parameter_list[1].encode("utf8"))
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1955 elif _parameter_list[0] == u"R" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1956 _parameter_list[0] == u"RESUMEN":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1957 #print( "__RESUMEN__" + _parameter_list[1])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1958 self.__budget.setParametricSummary(_family_code.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1959 _parameter_list[1].encode("utf8"))
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1960 elif _parameter_list[0] == u"T" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1961 _parameter_list[0] == u"TEXTO":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1962 #print( "__TEXTO__" + _parameter_list[1])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1963 self.__budget.setParametricText(_family_code.encode("utf8"),
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1964 _parameter_list[1].encode("utf8"))
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1965 elif _parameter_list[0] == u"P" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1966 _parameter_list[0] == u"PLIEGO":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1967 #print( "__PLIEGO__" + str(_parameter_list[1:]) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1968 pass
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1969 elif _parameter_list[0] == u"K" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1970 _parameter_list[0] == u"CLAVES":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1971 #print( "__CLAVES__" + str(_parameter_list[1:]) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1972 pass
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1973 elif _parameter_list[0] == u"F" or \
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1974 _parameter_list[0] == u"COMERCIAL":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1975 #print( "__COMERCIAL__" + str(_parameter_list[1:]) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1976 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1977 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1978 #print( "==PARAMETRO==" + str(_parameter_list[:]) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1979 pass
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1980 _final_description = _final_description + _line + u"\r\n"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1981
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1982 #print( _line )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1983 # Delete last empty line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1984 _description = _final_description[:-2]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1985 _lines = _description.split(u"\r\n")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1986 for _line in _lines:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1987 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1988 #print( _line )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1989 self.__statistics.valid = self.__statistics.valid + 1
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1990
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1991 def readFile(self, budget=None, filename=None, interface=None):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1992 """readFile(budget=None, filename=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1993
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1994 filename: the filename of the fiebdc file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1995 budget: base.obra object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1996 interface: a object to send messages
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1997 must have readFile_send_message(message)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1998 readFile_set_statistics(statistics)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
1999 readFile_progress(percent)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2000 readFile_end()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2001 readFile_cancel()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2002 updateGui()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2003 Return None
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2004 """
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2005 if not filename is None and not budget is None:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2006 self.__filename = filename
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2007 self.__budget = budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2008 self.__budget.filename = self.__filename
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2009 if self.__filename is None or self.__budget is None or self.__cancel:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2010 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2011 if not os.path.exists(self.__filename):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2012 return None
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2013 if interface is None:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2014 interface = Interface()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2015 interface.readFile_set_statistics(self.__statistics)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2016 _time = time.time()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2017 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2018 _file = open(self.__filename, 'r')
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2019 except IOError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2020 print( utils.mapping("IOError: $1", (self.__filename,)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2021 return None
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2022 _filesize = float(os.path.getsize(self.__filename))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2023 if _filesize == 0.0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2024 print( utils.mapping("Empty File: $1", (self.__filename,)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2025 # Todo: Create empty budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2026 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2027 self.__budget.filename = self.__filename
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2028 interface.readFile_send_message(utils.mapping(_("Loading file $1"),
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2029 (self.__filename,)))
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2030 interface.readFile_progress(_file.tell() / _filesize)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2031 _buffer = _file.read(1000)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2032 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2033 # set codepage from V record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2034 _record_list = _buffer.split("~")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2035 registro_V = _record_list[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2036 # ~V|[PROPIEDAD_ARCHIVO]|VERSION_FORMATO[\DDMMAAAA]|[PROGRAMA_EMISION]|
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2037 # [CABECERA]\{ ROTULO_IDENTIFICACION \}|[JUEGO_CARACTERES]|
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2038 # [COMENTARIO]|[TIPO INFORMACIÓN]|[NÚMERO CERTIFICACIÓN]|
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2039 # [FECHA CERTIFICACIÓN ] |
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2040 registro_V = registro_V.split("|")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2041 if registro_V[0] == "V":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2042 #_codepage = registro_V[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2043 if len(registro_V) > 5:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2044 _version = registro_V[5].strip()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2045 # remove leading spaces
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2046 if _version in self.__character_sets_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2047 self.__character_set = self.__character_sets_dict[_version]
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2048 interface.readFile_send_message(utils.mapping(
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2049 _("FIEBDC character encoding: $1"),
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2050 (self.__character_set,)))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2051 else:
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2052 interface.readFile_send_message(utils.mapping(
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2053 _("This Character encoding do not exist in "\
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2054 "FIEBDC3! Default Character encoding: $1"),
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2055 (self.__character_set,)))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2056 else:
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2057 interface.readFile_send_message(utils.mapping(_(
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2058 "This V record dot have a character encoding! "\
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2059 "Default character encoding: $1"),
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2060 (self.__character_set,)))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2061 else:
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2062 interface.readFile_send_message(utils.mapping(_(
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2063 "Not 'V' record in File! Default character encoding: "\
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2064 "$1"), (self.__character_set,)))
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2065 _buffer = unicode(_buffer, self.__character_set)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2066 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2067 # Any INFORMATION between the beginning of the file and the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2068 # beginning of the first registry “~” is ignored
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2069 #"after_first_tilde" : "^[^~]*~"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2070 _buffer = self.__pattern["after_first_tilde"].sub("",_buffer)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2071 while _buffer != u"" and not self.__cancel:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2072 #-# the blank characters (32), tabs (9) and end of line (13 and 10)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2073 # before the separators '~', '|' are erased.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2074 # Before separator \ not deleted because it affects the reading of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2075 # the record ~P
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2076 _buffer = self.eraseControlCharacters(_buffer)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2077 _record_list = _buffer.split(u"~")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2078 # The last record can be incomplete unless it is the last one of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2079 # the file
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2080 #if len(_record_list) > 1:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2081 if (_file.tell() / _filesize) != 1.0:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2082 # not the end
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2083 _last_record = _record_list.pop()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2084 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2085 # The last record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2086 # The blank characters (32), tabs (9) and end of line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2087 # (13 and 10) at the end of the file are ignored.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2088 #"end_control" : "((\r\n)| |\t)+$"
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2089 _record_list[-1] = self.__pattern["end_control"].sub(u"",
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2090 _record_list[-1])
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2091 _last_record = u""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2092 for record in _record_list:
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2093 if self.__cancel:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2094 break
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2095 self.parseRecord(record, interface)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2096 interface.updateGui()
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2097 interface.readFile_progress(_file.tell() / _filesize)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2098 _buffer2 = _file.read(100000)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2099 interface.updateGui()
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2100 _buffer2 = unicode(_buffer2, self.__character_set)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2101 _buffer = _last_record + _buffer2
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2102 interface.updateGui()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2103 _file.close()
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2104 if self.__cancel:
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2105 interface.readFile_cancel()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2106 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2107 else:
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2108 self.__statistics.time = time.time()-_time
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2109 if self.__statistics.O > 0:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2110 interface.readFile_send_message(
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2111 utils.mapping(_("$1 unsuported record type O: "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2112 "Comercial Relationship"), (str(self.__statistics.O,))))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2113 if self.__statistics.valid == 0:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2114 interface.readFile_send_message(_("This file is not a valid FIBDC3 file"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2115 return None
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2116 interface.readFile_end()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2117 self._testBudget(self.__budget, interface)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2118 return None
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2119
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2120 def _testBudget(self, budget, interface):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2121 """testBudget(budget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2122
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2123 budget: base.obra object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2124 Test and repair budget object after read it from bc3 file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2125 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2126 # TODO: more to do here
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2127 print( _("Testing budget ...") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2128 # Add price to records without price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2129 _iter = budget.iter()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2130 _titlelist = budget.getTitleList()[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2131 if len(_titlelist) == 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2132 _titlenum = 1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2133 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2134 _titlenum = len(_titlelist)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2135 for _code in _iter:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2136 _record = budget.getRecord(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2137 _prices = _record.getPrices()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2138 _len_prices = len(_prices)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2139 if _titlenum > _len_prices:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2140 _leftprices = _titlenum - _len_prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2141 for _index in range(0,_leftprices):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2142 _root = budget.getRecord(budget.getRoot())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2143 _price = [0.0, _root.getDate(_len_prices + _index)]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2144 budget.addPriceToRecord(_price,_record)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2145 interface.updateGui()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2146 print( _("End Test") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2147
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2148 def delete_control_space(self, text):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2149 text = self.delete_control(text)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2150 text = text.replace(u" ", u"")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2151 return text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2152
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2153 def delete_control(self, text):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2154 text = text.replace(u"\t", u"")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2155 text = text.replace(u"\r", u"")
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2156 text = text.replace(u"\n", u"")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2157 return text
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2158
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2159 class Interface(object):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2160 """fiebdc.Interface
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2161
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2162 Description:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2163 An example interface
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2164 Constructor:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2165 fiebdc.Interface()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2166 Ancestry:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2167 +-- object
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2168 +-- Interface
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2169 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2170 "endSuccessfully": True/False
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2171 "__progress": The progress percentage
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2172 "__statistics": The record statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2173 Methods:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2174 __init__(self)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2175 readFile_send_message(message)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2176 readFile_progress(percent)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2177 readFile_set_statistics(statistics)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2178 readFile_end()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2179 readFile_cancel()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2180 updateGui()
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2181
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2182 """
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2183 def __init__(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2184 self.__progress = 0.0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2185 self.__statistics = Statistics()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2186 self.endSuccessfully = False
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2187
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2188 def readFile_set_statistics(self, statistics):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2189 """readFile_set_statistics(statistics)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2190
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2191 statistics: record statistics from readFile method
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2192
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2193 sets record statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2194 """
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2195 self.__statistics = statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2196
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2197 def readFile_send_message(self, message):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2198 """readFile_send_message(message)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2199
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2200 message: mesage from readFile method
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2201
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2202 print( message )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2203 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2204 print( message )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2205
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2206 def readFile_progress(self, percent):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2207 """progress(percent)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2208
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2209 percent: Percentage executed.
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2210
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2211 Sets progress
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2212 """
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2213 self.__progress = percent
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2214
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2215 def readFile_end(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2216 """readFile_end()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2217
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2218 The readFile method end successfully
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2219 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2220 self.endSuccessfully == True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2221 print(self.__statistics)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2222 print("progreso = " + str(self.__progress))
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2223
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2224 def readFile_cancel(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2225 """readFile_cancel()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2226
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2227 The readFile method is canceled
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2228 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2229 self.endSuccessfully == False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2230 print( _("Process terminated") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2231 print("progreso = " + str(self.__progress))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2232
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2233 def updateGui(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2234 """updateGui(self)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2235
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2236 Some interfaces need update gui while doing some time intensive
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2237 computation. Do it here.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2238 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2239 pass
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2240
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2241 class Statistics(object):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2242 """fiebdc.Statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2243
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2244 Description:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2245 BC3 Statistics. Records types.
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2246 Constructor:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2247 fiebdc.Statistics()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2248 Ancestry:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2249 +-- object
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2250 +-- Statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2251 Atributes:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2252 "records": number of records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2253 "valid": number of valid records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2254 "V": number of V records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2255 "C": number of C records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2256 "D":number of D records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2257 "Y":number of Y records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2258 "M":number of M records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2259 "N":number of N records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2260 "T":number of T records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2261 "K":number of K records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2262 "W":number of W records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2263 "L":number of L records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2264 "Q":number of Q records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2265 "J": number of J records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2266 "G":number of G records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2267 "E":number of E records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2268 "O":number of O records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2269 "P":number of P records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2270 "X":number of X records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2271 "B":number of B records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2272 "F":number of F records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2273 "A":number of A records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2274 "unknow": number of Unknow records
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2275 "time": Time to load
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2276
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2277 Methods:
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2278 __init__(self)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2279
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2280 """
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2281 def __init__(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2282 self.records = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2283 self.valid = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2284 self.V = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2285 self.C = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2286 self.D = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2287 self.Y = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2288 self.M = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2289 self.N = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2290 self.T = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2291 self.K = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2292 self.W = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2293 self.L = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2294 self.Q = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2295 self.J = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2296 self.G = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2297 self.E = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2298 self.O = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2299 self.P = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2300 self.X = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2301 self.B = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2302 self.F = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2303 self.A = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2304 self.unknow = 0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2305 self.time = 0.0
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2306
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2307 def __str__(self):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2308 return self.str().encode("utf8")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2309
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2310 def str(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2311
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2312 return utils.mapping(_("Time to load: $1 seconds"),
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2313 (("%.2f" %(self.time)),)) + "\n" + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2314 utils.mapping(_("Records/Valid Records: $1/$2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2315 (str(self.records), str(self.valid))) + "\n" +\
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2316 "V: %s\n" %(self.V,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2317 "C: %s\n" %(self.C,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2318 "D: %s\n" %(self.D,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2319 "Y: %s\n" %(self.Y,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2320 "M: %s\n" %(self.M,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2321 "N: %s\n" %(self.N,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2322 "T: %s\n" %(self.T,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2323 "K: %s\n" %(self.K,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2324 "W: %s\n" %(self.W,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2325 "L: %s\n" %(self.L,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2326 "Q: %s\n" %(self.Q,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2327 "J: %s\n" %(self.J,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2328 "G: %s\n" %(self.G,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2329 "E: %s\n" %(self.E,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2330 "O: %s\n" %(self.O,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2331 "P: %s\n" %(self.P,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2332 "X: %s\n" %(self.X,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2333 "B: %s\n" %(self.B,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2334 "F: %s\n" %(self.F,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2335 "A: %s\n" %(self.A,) + \
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2336 "?: %s\n" %(self.unknow,)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 20
diff changeset
2337