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