annotate Generic/base.py @ 23:65e7ae0d0e63

GTK2 to GTK3
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Thu, 02 May 2019 16:31:17 +0200
parents 7bd4ca56607d
children 189f8274aecd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1 #!/usr/bin/python
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3 ## File base.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: 22
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 """base module
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 In this module are defined the data structures in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
25 classes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
26 * Record: data of each record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
27 * ParamentricRecord: data of each parametric record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
28 * Decomposition: data of the decomposition of each record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
29 * Measure: data of the measure of each record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
30 * MeasureLine: each measure line data
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
31 * Decimals: data of the decimal places of all the numbers in a budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
32 * Sheet: data of the sheet of conditions of a budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
33 * Budget: all data of a budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
34 * Company: company data
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
35 * Office: company office data
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
36 * File: file data
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
37 * RecordType: Record type data
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 schema:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
40 * Budget:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
41 +-- __records: dictionary records { code : Record }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
42 * Record:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
43 +-- code: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
44 +-- synonyms: list of synonym codes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
45 +-- hierarchy: A integer number:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
46 0 -> root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
47 1 -> Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
48 2 -> Other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
49 +-- unit: unit of measure of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
50 +-- summary: Short description of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
51 +-- prices: List of Prices/Dates
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
52 +-- type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
53 +-- subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
54 "type" and "subtype":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
55 0 Without classifying
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
56 EA Auxiliary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
57 EU Unitary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
58 EC Complex element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
59 EF Functional element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
60 OB Construction site
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
61 PA Cost overrun
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
62 PU Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
63 1 Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
64 H Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
65 2 Machinery and auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
66 Q Machinery
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
67 % Auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
68 3 Building materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
69 MC Cement
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
70 MCr Ceramic
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
71 MM Wood
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
72 MS Iron and steel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
73 ME Energy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
74 MCu Copper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
75 MAl Aluminium
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
76 ML Bonding agents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
77 M Others materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
78 Hierarchy type subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
79 0->root -> 0 -> None,OB
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
80 1->[sub]chapter -> 0 -> None,PU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
81 2->Other -> 0 -> None,EA,EU,EC,EF,PA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
82 1 -> None,H
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
83 2 -> None,Q,%
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
84 3 -> None,MC,MCr,MM,MS,ME,MCu,Mal,ML,M
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
85 +-- parents: List of parent codes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
86 +-- children: list of Decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
87 * Decomposition:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
88 +-- position: Position of the child in the parent descomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
89 TODO: change this: the position of the record in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
90 +-- code: child record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
91 +-- budget: list of budget and amended budget measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
92 * Measure:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
93 +-- measure: Total result of measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
94 +-- lines: List of measure lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
95 * MeasureLine:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
96 +-- type: Line type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
97 empty string -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
98 1 -> Parcial Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
99 2 -> Accumulated Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
100 3 -> Formula, the comment is a formula.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
101 +-- comment: Can be a descriptive text or a formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
102 Valid Operator: '(', ')', '+', '-', '*', '/' and
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
103 '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
104 Valid variable: 'a', 'b', 'c','d' y 'p'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
105 (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
106 +-- units: Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
107 +-- length: length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
108 +-- width: width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
109 +-- height: height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
110 +-- label: Record Identifiers that are used by some measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
111 programs
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
112 +-- factor: Factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
113 +-- yield_: Yield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
114 +-- certification: list of certifications for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
115 * Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
116 +-- real_cost: list of real cost of construction for months
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
117 measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
118 * Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
119 +-- cost_goals: list of cost goals of construction for months
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
120 measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
121 * Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
122 +-- cost_planned: list of costs planned and amended cost planned
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
123 measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
124 * Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
125 +-- text: Long Description of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
126 +-- sheet: Sheet of conditions object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
127 * Sheet:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
128 +-- sheet_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
129 { <Field key> : { <Section key> : <Paragraph key>}}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
130 +-- files: List of file object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
131 +-- file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
132 * Name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
133 * Type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
134 * Description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
135 +-- __synonyms: synonyms dictionary. TODO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
136 +-- __root: root record code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
137 +-- __decimals: List with the decimal places used to round the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
138 - result of the calculations with prices and measures
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
139 - The values are Decimals objects
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
140 - The <0> objets is the default Decimals (seted in FIEBDC-3),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
141 - The others keys are for the diferent groups of Prices
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
142 * Decimals:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
143 +-- DN: Number of decimal places of the field "equal-size parts" in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
144 measure lines.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
145 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
146 +-- DD: Number of decimal places of the three dimensions in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
147 measure lines.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
148 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
149 +-- DS: Number of decimal places of the total sum of a measure.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
150 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
151 +-- DFP: Number of decimal places of the yield factor in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
152 decomposition of a budget record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
153 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
154 +-- DFC: Number of decimal places of the yield factor in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
155 decomposition of a chapter or subchapter, and in its measure lines.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
156 Dafault: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
157 +-- DFUO: Number of decimal places of the yield factor in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
158 decomposition of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
159 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
160 +-- DFA: Number of decimal places of the yield factor in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
161 decomposition of a Auxiliary element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
162 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
163 +-- DRP: Number of decimal places of the yield in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
164 of a budget record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
165 Number of decumal places of the result of the multiplication of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
166 the factor and the yield in a decompositon of a budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
167 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
168 +-- DRC: Number of decimal places of the yield (or measure) in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
169 decomposition of a chapter or subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
170 Number of decimal places of the result of the multiplictaion of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
171 the yield (or measure) and the factor in a decomposition of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
172 chapter or subcharter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
173 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
174 +-- DRUO: Number of decimal places of the yield in a decomposition of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
175 unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
176 Decimal places of the result of the multiplication of the yield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
177 and the factor in a descomposition of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
178 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
179 +-- DRA: Number of decimal places of the yield in a decompositon of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
180 auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
181 Number of decimal places of the result of the multiplication of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
182 the yield and the factor in a descomposition of a auxilar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
183 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
184 +-- DP: Number of decimal places of the price of a budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
185 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
186 +-- DC: Number of decimal places of the price of a chapter or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
187 subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
188 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
189 +-- DUO: Number of decimal places of the price of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
190 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
191 +-- DEA: Number of decimal places of the price of a auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
192 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
193 +-- DES: Number of decimal places of the price of the simple elements.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
194 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
195 +-- DIR: Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
196 the total yield and the price of the elements of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
197 (When there are not measures)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
198 +-- DIM: Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
199 the total yield and the price of the elements of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
200 (When there are measures)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
201 +-- DIRC: Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
202 the total yield and the price of the elements of a budget, chapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
203 or a subchapter.(When there are not measures)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
204 +-- DIMC: Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
205 the total yield and the price of the elements of a budget, chapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
206 or a subchapter. (When there are measures)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
207 +-- DCD: Number of decimal places ot the resulting amount to sum the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
208 direct costs of a unit of work (and auxiliar element).
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
209 Number of decimal places of the indirect costs.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
210 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
211 +-- DIVISA: monetary unit.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
212 +-- __percentages: percentages dictionary:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
213 { "CI" : "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
214 "GG" : "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
215 "BI" : "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
216 "BAJA": "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
217 "IVA" : ""}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
218 +-- __file_owner
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
219 +-- __title_list: titles list: [ "Header", ["Title1", "Title2", ... ] ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
220 +-- __title_index: A integer. The active group of Prices and Decimals.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
221 +-- __sheet_sections: sheet sections dictionary { sheet_code : sheet_title }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
222 +-- __sheet_fields: sheet fields dictionary { field_code : field_title }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
223 +-- __sheet_paragraphs: sheet paragraphs dictionary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
224 { paragraph_code : paragraph_text}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
225 +-- __companys: Dictionary whith companys object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
226 { company_code: company_object }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
227 * Comapany:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
228 +-- code: company code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
229 +-- summary: short name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
230 +-- name: long name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
231 +-- offices: List of offices:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
232 * Office:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
233 +-- type: office type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
234 "C" Central office.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
235 "D" Local Office.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
236 "R" Performer.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
237 +-- subname: Office name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
238 +-- address: Ofiice address
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
239 +-- postal_code: postal code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
240 +-- town: town
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
241 +-- province: province/state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
242 +-- country: country
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
243 +-- phone: list of phone numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
244 +-- fax: list of fax numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
245 +-- contact_person: Contact person in the office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
246 +-- cif: CIF
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
247 +-- web: web page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
248 +-- email: email
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
249 +-- __comment
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
250 +-- __date
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
251 +-- __budgetType" A integer. Type of data in budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
252 0 -> Undefined
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
253 1 -> Base data.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
254 2 -> Budget.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
255 3 -> Certificate.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
256 4 -> Base date update.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
257 +-- __budgetCerficateOrder" Only valid if budgetType is 3.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
258 +-- __budgetCerficateDate" Only valid if budgetType is 3
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
259 +-- __tec_info": Dictionary whith tecnical information
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
260 {ti_code : ["desciption text", "unit"]}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
261 +-- __labels": Label dictionary { "label": [ "code", ], }
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
262 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
263
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
264 # Modules
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
265 # python 2/3 compatibility
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
266 #from __future__ import absolute_import, division, print_function, unicode_literals
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
267
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
268 import re
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
269 import datetime
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
270 import os
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
271
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
272 # pyArq-Presupuestos modules
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
273 from Generic import fiebdc
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
274 from Generic import utils
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
275
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
276
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
277 # Translatable global Vars
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
278
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
279 authors = ["Miguel Ángel Bárcena Rodríguez"]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
280 copyright = "Copyright \xc2\xa9 2019 Autoras de Pyarq Presupuestos"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
281 website = "http://pyarq.obraencurso.es/pyarq-Presupuestos"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
282 website_label = "pyarq Presupuestos Web"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
283 comments = _("""
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
284 A free program of measurements, budgets and control of construction sites.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
285 In beta development, still there is not a fully functional version.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
286 """)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
287 help = _(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
288 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
289 Usage:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
290 pyarqPresupuestos [file]...
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
291
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
292 Help Options:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
293 -h, --help Show this help
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
294 """)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
295
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
296 class Record(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
297 """base.Record:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
298
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
299 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
300 Record object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
301 Constructor:
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
302 base.Record(decimals, code, synonyms, hierarchy, unit, summary,
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
303 prices, type_, subtype, parents=None, text=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
304 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
305 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
306 +-- Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
307 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
308 "code": Write/Read. Code string
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
309 "recordType": Write/Read. RecordType object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
310 "synonyms": Write/Read. List of synonym codes.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
311 "parents": Write/Read. List of parent codes
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
312 "children": Write/Read. Decomposition list,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
313 list of "Decomposition" instances
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
314 "unit": Write/Read. measure unit of the record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
315 "summary": Write/Read. Short description of the record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
316 "prices": Read. List of prices/dates
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
317 "text": Write/Read. Long Description of the record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
318 "sheet": Write/Read. Sheet of conditions object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
319 "files": Write/Read. List of file object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
320 "labels": Write/Read. List of record labels
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
321 Methods:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
322 isPercentage
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
323 percentageMasq
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
324 hasPercentageMasq(masq)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
325 {get/set}Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
326 {get/set}Synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
327 {get/set}RecordType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
328 {get/set}Unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
329 {get/set}Summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
330 {get/set}Prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
331 addPrice
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
332 getPrice
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
333 getAmount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
334 getDate
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
335 {get/set}Parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
336 appendParent
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
337 {get/set}children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
338 appendChild
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
339 {get/set}Text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
340 {get/set}Sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
341 {get/set}Files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
342 addFile
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
343 {get/set}Labels
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
344 addLabel
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
345 getChildPositions:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
346 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
347 __slots__ = ["_Record__code", "_Record__synonyms",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
348 "_Record__recordType", "_Record__unit",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
349 "_Record__summary", "_Record__prices",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
350 "_Record__parents", "_Record__children",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
351 "_Record__text", "_Record__sheet",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
352 "_Record__files", "_Record__labels"]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
353
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
354 def __getstate__(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
355 return (self.__code, self.__synonyms, self.__recordType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
356 self.__unit, self.__summary, self.__prices,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
357 self.__parents, self.__children, self.__text,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
358 self.__sheet, self.__files, self.__labels)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
359
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
360 def __setstate__(self, tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
361 self.__code = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
362 self.__synonyms = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
363 self.__recordType = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
364 self.__unit = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
365 self.__summary = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
366 self.__prices = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
367 self.__parents = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
368 self.__children = tuple[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
369 self.__text = tuple[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
370 self.__sheet = tuple[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
371 self.__files = tuple[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
372 self.__labels = tuple[11]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
373
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
374 def __init__(self, decimals, code, synonyms, hierarchy, unit, summary,
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
375 prices, type_, subtype, parents=None, text=None):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
376 self.code = code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
377 self.synonyms = synonyms
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
378 self.recordType = (hierarchy, type_, subtype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
379 self.unit = unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
380 self.summary = summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
381 self.setPrices(prices, decimals)
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
382 if parents is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
383 parents = []
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
384 self.parents = parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
385 self.children = []
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
386 if text is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
387 text = ""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
388 self.text = text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
389 self.sheet = Sheet()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
390 self.files = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
391 self.labels = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
392
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
393 def isPercentage(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
394 if "%" in self.__code or "&" in self.__code:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
395 return True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
396 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
397 return False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
398
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
399 def percentageMasq(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
400 if "%" in self.__code:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
401 return self.__code.split("%")[0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
402 elif "&" in self.__code:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
403 return self.__code.split("&")[0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
404
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
405 def hasPercentageMasq(self, masq):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
406 if len(self.__code) >= len(masq):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
407 _part_code = self.__code[:len(masq)]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
408 if _part_code == masq:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
409 return True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
410 return False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
411
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
412 def getCode(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
413 return self.__code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
414
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
415 def setCode(self, code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
416 """setCode(code)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
417
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
418 Sets the code, must be a valid code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
419 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
420 if not utils.is_valid_code(code)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
421 raise ValueError( utils.mapping(_("Invalid code: $1"),(str(code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
422 self.__code = code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
423
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
424 def getSynonyms(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
425 return self.__synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
426
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
427 def setSynonyms(self,synonyms):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
428 """setSynonyms(synonyms)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
429
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
430 Sets the synonyms codes of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
431 synonyms must fulfill:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
432 - must be a list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
433 - the items must be valid codes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
434 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
435 if not isinstance(synonyms, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
436 raise TypeError( utils.mapping(_("Synonyms ($1) must be a list, " \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
437 "code: $2"), (str(synonyms), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
438 for code in synonyms:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
439 if not utils.is_valid_code(code)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
440 raise ValueError( utils.mapping(_("Invalid Code in synomyms "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
441 "list ($1) code: $2"), (str(code), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
442 self.__synonyms = synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
443
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
444 def getRecordType(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
445 return self.__recordType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
446
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
447 def setRecordType(self, recordType):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
448 """setRecordType(recordType)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
449
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
450 Set the record type.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
451 recordType (hierarchy, type,subtype)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
452
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
453 hierarchy must be -1, 0, 1 or 2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
454 type must be 0, 1, 2, 3 or a empty string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
455 subtype must be EA, EU, EC, EF, OB, PA, PU, H, Q, %, MC, MCr,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
456 MM, MS, ME, MCu, MAl, ML, M, or a empty string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
457 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
458 _recordType = RecordType(recordType[0],recordType[1],recordType[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
459 self.__recordType = _recordType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
460
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
461 def getUnit(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
462 return self.__unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
463
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
464 def setUnit(self,unit):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
465 """setUnit(unit)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
466
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
467 Set the unit of measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
468 The unit must be a string.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
469 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
470 if not isinstance(unit, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
471 raise TypeError( utils.mapping(_("Unit ($1) must be a string: $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
472 (str(unit), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
473 self.__unit = unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
474
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
475 def getSummary(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
476 return self.__summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
477
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
478 def setSummary(self,summary):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
479 """setSummary(summary)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
480
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
481 Set the summary of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
482 The summary must be a string.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
483 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
484 if not isinstance(summary, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
485 raise TypeError( utils.mapping(_("Summary ($1) must be a string: "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
486 "$1"), (str(summary), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
487 self.__summary = summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
488
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
489 def getPrices(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
490 return self.__prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
491
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
492 def setPrices(self, prices, decimals):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
493 """setPrice(prices, decimals)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
494
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
495 Set the price list of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
496 prices must fulfill:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
497 - it must be a list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
498 - the items must be a list with two items
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
499 - the first item: price must be a float
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
500 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
501 if not isinstance(prices, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
502 raise TypeError( utils.mapping(_("Prices ($1) must be a list: $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
503 (str(prices), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
504 for index in range(len(prices)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
505 _price_date = prices[index]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
506 _price_date = self._validate_price_date(_price_date, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
507 prices[index] = _price_date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
508 self.__prices = prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
509
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
510 def addPrice(self, price_date, decimals):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
511 """addPrice(price_date, decimals)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
512
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
513 Add a price to the price list of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
514 price must fulfill:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
515 - must be a list with two items
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
516 - the first item: price must be a float
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
517 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
518 price_date = self._validate_price_date(price_date, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
519 self.__prices.append(price_date)
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 _validate_price_date(self, price_date, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
522 if not isinstance(price_date, list) and len(price_date) == 2:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
523 raise ValueError( utils.mapping(_("Price ($1) must be a list"\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
524 " with two items: $2"), (str(price_date), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
525 _price = price_date[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
526 _date = price_date[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
527 if not isinstance(_price, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
528 raise TypeError( utils.mapping(_("Price must be a float "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
529 "number: $1"), (str(_price),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
530 _D = abs(decimals.getD(self.recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
531 _price = round(_price, _D)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
532 price_date[0] = _price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
533 # TODO: validate date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
534 return price_date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
535
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
536 def getPrice(self, index_price):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
537 if len(self.__prices) <= index_price:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
538 raise IndexError( _("The record do not have this Price. Code: %s"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
539 % self.__code) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
540 return self.__prices[index_price][0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
541
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
542 def getDate(self, index_price):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
543 if len(self.__prices) <= index_price:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
544 raise IndexError( _("The record do not have this Price") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
545 return self.__prices[index_price][1]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
546
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
547 def getParents(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
548 return self.__parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
549
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
550 def setParents(self,parents):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
551 """setParents(parents)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
552
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
553 Sets the list of parents codes of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
554 parents must fulfill
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
555 - it must be a list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
556 - the items must be valid codes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
557 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
558 if not isinstance(parents, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
559 raise TypeError( utils.mapping(_("Parents ($1) must be a list: $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
560 (str(parents), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
561 for parent in parents:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
562 if not utils.is_valid_code(parent)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
563 raise ValueError(utils.mapping(_("Invalid parent code ($1) " \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
564 "in the record: $2"), (str(padre), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
565 self.__parents = parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
566
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
567 def appendParent(self, parent):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
568 """appendParent(parent)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
569
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
570 parent must be a valid code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
571 Append a parent to the list of parents codes of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
572
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
573 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
574 if not utils.is_valid_code(parent)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
575 raise ValueError( utils.mapping(_("Invalid parent code ($1) " \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
576 "in the record: $2"), (str(parent), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
577 self.__parents.append(parent)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
578
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
579 def getchildren(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
580 return self.__children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
581
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
582 def setchildren(self,children):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
583 """setchildren(children)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
584
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
585 Sets the list of children of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
586 children must fulfill
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
587 - it must be a list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
588 - the items must be instances of Decomposition class
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
589 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
590 if not isinstance(children, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
591 raise TypeError( utils.mapping(_("children ($1) must be a list, "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
592 "record: $2"), (str(children), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
593 for _child in children:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
594 if not isinstance(_child, Decomposition):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
595 raise ValueError( utils.mapping(_("child ($1) must be a "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
596 "Decomposition object, record: $2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
597 (str(_child), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
598 _record_code = self.code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
599 for _measure_list in [_child.budgetMeasures, _child.certification,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
600 _child.real_cost, _child.cost_goals,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
601 _child.cost_planned]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
602 if isinstance(_measure_list, list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
603 for _measure in _measure_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
604 _measurerecordCode = _record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
605 self.__children = children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
606
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
607 def appendChild(self, child_code, decimals, factor=0.0, yield_=0.0,
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
608 measure=0.0, measure_list=None, type_=None, label=None):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
609 """appendChildren(child_code, factor=0.0, yield_=0.0,
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
610 measure=0.0, measure_list=None, type_=None, label=None))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
611
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
612 position:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
613 child_code:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
614 factor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
615 yield_:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
616 measure:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
617 measure_list:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
618 type_:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
619 label:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
620
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
621 Append a child to the list of children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
622 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
623 if measure_list is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
624 measure_list = []
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
625 if type_ is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
626 type_ = ""
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
627 if label is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
628 label = ""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
629 _measure = Measure(decimals, self.recordType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
630 measure, [], label, factor, yield_)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
631 if len(measure_list) > 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
632 _measure.buildMeasure( measure_list, type_, decimals,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
633 self.recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
634 _position = len(self.__children)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
635 _child = Decomposition(_position, child_code, [_measure])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
636 self.__children.append(_child)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
637 return _child
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
638
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
639 def getText(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
640 return self.__text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
641
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
642 def setText(self,text):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
643 """setText(text)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
644
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
645 Sets the text of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
646 It must be a string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
647 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
648 if not isinstance(text, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
649 raise TypeError( utils.mapping(_("Text ($1) must be a string, "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
650 "record: $2"), (str(text), str(self.__code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
651 self.__text = text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
652
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
653 def getSheet(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
654 return self.__sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
655
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
656 def setSheet(self, sheet):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
657 """setSheet(sheet)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
658
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
659 Sets the sheet of condition object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
660 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
661 if not isinstance(sheet, Sheet):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
662 raise ValueError( _("sheet must be a Sheet instance") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
663 self.__sheet = sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
664
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
665 def getFiles(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
666 return self.__files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
667
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
668 def setFiles(self, files):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
669 """setFiles(files)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
670
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
671 Sets the files list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
672 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
673 if not isinstance(files, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
674 raise ValueError( utils.mapping(_("files must be a list: $1"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
675 str(files)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
676 _files = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
677 for file in files:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
678 if isinstance(file, File):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
679 _files.append(file)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
680 elif isinstance(file, list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
681 _file_path = file[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
682 _type = file[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
683 _description = file[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
684 if not os.path.exists(file[0]):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
685 raise ValueError( _("Incorrect path") )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
686 _file = File(file_path, type_, description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
687 _files.append(_file)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
688 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
689 raise ValueError( utils.mapping(_(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
690 "file must be a list or a File object: $1"),str(file)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
691 self.__files = _files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
692
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
693 def addFile(self, file_path, type_, description):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
694 """addFile(file_path, type_, description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
695
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
696 Add a file to a record instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
697 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
698 if not os.path.exists(file_path):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
699 raise ValueError( _("Incorrect path") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
700 _name = os.path.basename(file_path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
701 _isin = False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
702 for _ofile in self.__files:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
703 if _ofile.name == _name:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
704 _isin = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
705 if not _isin:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
706 _file = File(_name, type_, description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
707 self.__files.append(_file)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
708
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
709 def getLabels(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
710 return self.__labels
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
711
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
712 def setLabels(self, labels):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
713 """setLabels(labels)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
714
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
715 Sets the labels list of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
716 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
717 if not isinstance(labels, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
718 raise ValueError( _("labels must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
719 _labels = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
720 for _label in labels:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
721 if isinstance(_label, str):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
722 _labels.append(_label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
723 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
724 raise ValueError( _("label must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
725 self.__labels = _labels
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
726
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
727 def addLabel(self, label):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
728 """addLabel(label)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
729
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
730 Add a label to a record instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
731 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
732 if not isinstance(label, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
733 raise ValueError( _("Label must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
734 if not label in self.__labels:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
735 self.__labels.append(label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
736
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
737 def getChildPositions(self, child_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
738 """getChildPath(child_code):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
739
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
740 Try to return positions of a childcode
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
741 """
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
742 children = self.children
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
743 positions = []
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
744 for child in children:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
745 if child.code == child_code:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
746 positions.append(child.position)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
747 return positions
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
748
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
749 recordType = property(getRecordType, setRecordType, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
750 """Record Type object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
751 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
752 code = property(getCode, setCode, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
753 """Record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
754 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
755 synonyms = property(getSynonyms, setSynonyms, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
756 """List of codes synonyms of the code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
757 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
758 unit = property(getUnit,setUnit, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
759 """Measure Unit of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
760 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
761 summary = property(getSummary, setSummary, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
762 """Short description of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
763 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
764 prices = property(getPrices, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
765 """List of Price/Date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
766 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
767 parents = property(getParents, setParents, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
768 """List of codes of the records which the record is in
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
769 its decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
770 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
771 children = property(getchildren, setchildren, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
772 """List of Decompositon intances""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
773 text = property(getText, setText, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
774 """Long description of the record""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
775 sheet = property(getSheet, setSheet, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
776 """Sheet of conditions object""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
777 files = property(getFiles, setFiles, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
778 """File list""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
779 labels = property(getLabels, setLabels, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
780 """Label list""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
781
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
782
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
783 class ParametricRecord(Record):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
784 """base.ParametricRecord:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
785
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
786 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
787 Parametric Record object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
788 Constructor:
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
789 base.ParametricRecord(budget, code, synonyms, hierarchy, unit, summary,
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
790 prices, type_, subtype, parents=None, text=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
791 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
792 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
793 +-- Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
794 +-- ParametricRecord
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
795 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
796
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
797 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
798
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
799 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
800
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
801 __slots__ = ["_ParametricRecord__budget",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
802 "_ParametricRecord__code", "_ParametricRecord__synonyms",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
803 "_ParametricRecord__hierarchy", "_ParametricRecord__unit",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
804 "_ParametricRecord__summary", "_ParametricRecord__prices",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
805 "_ParametricRecord__type", "_ParametricRecord__subtype",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
806 "_ParametricRecord__parents", "_ParametricRecord__children",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
807 "_ParametricRecord__text", "_ParametricRecord__sheet",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
808 "_ParametricRecord__files", "_ParametricRecord__labels",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
809 "_ParametricRecord__parameters",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
810 "_ParametricRecord__select_comment",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
811 "_ParametricRecord__vars",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
812 "_ParametricRecord__parametric_summary",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
813 "_ParametricRecord__parametric_text",]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
814
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
815 def __getstate__(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
816 return (self.__budget, self.__code, self.__synonyms, self.__hierarchy,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
817 self.__unit, self.__summary, self.__prices, self.__type,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
818 self.__subtype, self.__parents, self.__children, self.__text,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
819 self.__sheet, self.__files, self.__labels, self.__parameters,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
820 self.__select_comment, self.__vars,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
821 self.__parametric_summary, self.__parametric_text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
822
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
823 def __setstate__(self, tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
824 self.__budget = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
825 self.__code = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
826 self.__synonyms = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
827 self.__hierarchy = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
828 self.__unit = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
829 self.__summary = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
830 self.__prices = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
831 self.__type = tuple[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
832 self.__subtype = tuple[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
833 self.__parents = tuple[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
834 self.__children = tuple[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
835 self.__text = tuple[11]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
836 self.__sheet = tuple[12]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
837 self.__files = tuple[13]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
838 self.__labels = tuple[14]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
839 self.__parameters = tuple[15]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
840 self.__select_comment = tuple[16]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
841 self.__vars = tuple[17]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
842 self.__parametric_summary = tuple[18]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
843 self.__parametric_text = tuple[19]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
844
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
845 def __init__(self, budget, code, synonyms, hierarchy, unit, summary,
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
846 prices, type_, subtype, parents=None, text=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
847 if parents is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
848 parents = []
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
849 if text is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
850 text = ""
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
851 Record.__init__(self, budget, code, synonyms, hierarchy, unit, summary,
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
852 prices, type_, subtype, parents, text)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
853 self.__parameters = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
854 self.__select_comment = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
855 self.__vars = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
856 self.parametric_summary = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
857 self.parametric_text = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
858
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
859 def getParameter(self, parameter):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
860 if parameter in self.__parameters:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
861 return self.__parameters[parameter]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
862 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
863 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
864
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
865 def setParameter(self, parameter, parameter_list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
866 self.__parameters[parameter] = parameter_list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
867
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
868 def getSelectComment(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
869 return self.__select_comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
870
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
871 def setSelectComment(self, select_comment):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
872 self.__select_comment = select_comment
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
873
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
874 def getVar(self, var):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
875 if var in self.__vars:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
876 return self.__vars[var]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
877 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
878 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
879
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
880 def setVar(self, var, var_list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
881 self.__vars[var] = var_list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
882
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
883 def getParametricSummary(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
884 return self.__parametric_summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
885
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
886 def setParametricSummary(self, parametric_summary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
887 self.__parametric_summary = parametric_summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
888
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
889 def getParametricText(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
890 return self.__parametric_text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
891
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
892 def setParametricText(self, parametric_text):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
893 self.__parametric_text = parametric_text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
894
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
895 parameter = property(getParameter, setParameter, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
896 """Record parameter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
897 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
898 select_comment = property(getSelectComment, setSelectComment, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
899 """Seclect comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
900 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
901 var = property(getVar, setVar, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
902 """Record var
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
903 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
904 parametric_summary = property(getParametricSummary, setParametricSummary,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
905 None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
906 """Parametric summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
907 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
908 parametric_text = property(getParametricText, setParametricText, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
909 """Seclect comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
910 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
911
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
912
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
913 class Decomposition(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
914 """base.Decomposition:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
915
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
916 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
917 Decomposition object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
918 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
919 base.Decomposition(position, code, budgetMeasures, certification=None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
920 real_cost=None, cost_goals=None, cost_planned=None)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
921 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
922 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
923 +-- Decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
924 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
925 "position": the position of the child record in the parent record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
926 "code": Record code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
927 Measures:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
928 "budgetMeasures": list of budget and Amended budget measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
929 "certification": list of certifications for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
930 "real_cost": list of real cost of construction for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
931 "cost_goals": list of cost goals of construction for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
932 "cost_planned": list of costs planned and amended cost planned measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
933 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
934 {get/set}position
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
935 {get/set}Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
936 {get/set}BudgetMeasures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
937 {get/set}Certification
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
938 {get/set}RealCost
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
939 {get/set}CostGoals
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
940 {get/set}CostPlanned
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
941 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
942
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
943 __slots__ = ["_Decomposition__position",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
944 "_Decomposition__code",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
945 "_Decomposition__budgetMeasures",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
946 "_Decomposition__certification",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
947 "_Decomposition__real_cost",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
948 "_Decomposition__cost_goals",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
949 "_Decomposition__cost_planned",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
950 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
951
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
952 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
953 return (self.__position, self.__code, self.__budgetMeasures,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
954 self.__certification, self.__real_cost, self.__cost_goals,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
955 self.__cost_planned)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
956
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
957 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
958 self.__position = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
959 self.__code = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
960 self.__budgetMeasures = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
961 self.__certification = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
962 self.__real_cost = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
963 self.__cost_goals = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
964 self.__cost_planned = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
965
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
966 def __init__(self, position, code, budgetMeasures, certification=None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
967 real_cost=None, cost_goals=None, cost_planned=None):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
968 self.position = position
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
969 self.code = code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
970 self.budgetMeasures = budgetMeasures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
971 self.certification = certification
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
972 self.real_cost = real_cost
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
973 self.cost_goals = cost_goals
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
974 self.cost_planned = cost_planned
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
975
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
976 def getPosition(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
977 return self.__position
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
978
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
979 def setPosition(self, position):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
980 if not isinstance(position, int):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
981 raise ValueError( _("Position must be a integer") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
982 self.__position = position
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
983
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
984 def getCode(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
985 return self.__code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
986
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
987 def setCode(self, code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
988 self.__code = code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
989
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
990 def getBudgetMeasures(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
991 return self.__budgetMeasures
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
992
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
993 def setBudgetMeasures(self, budgetMeasures):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
994 if not isinstance(budgetMeasures, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
995 raise ValueError( _("BudgetMeasures atribute must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
996 for _measure in budgetMeasures:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
997 if not isinstance(_measure, Measure):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
998 raise ValueError( _("BudgetMeasures item must be a Measure "/
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
999 "object") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1000 self.__budgetMeasures = budgetMeasures
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1001
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1002 def getCertification(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1003 return self.__certification
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1004
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1005 def setCertification(self, certification):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1006 if not (certification is None or isinstance(certification, list)):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1007 raise ValueError( _("Certification atribute must be a list or None") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1008 self.__certification = certification
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1009
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1010 def getRealCost(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1011 return self.__real_cost
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1012
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1013 def setRealCost(self, real_cost):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1014 if not (real_cost is None or isinstance(real_cost, list)):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1015 raise ValueError( _("Real cost atribute must be a list or None") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1016 self.__real_cost = real_cost
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1017
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1018 def getCostGoals(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1019 return self.__cost_goals
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1020
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1021 def setCostGoals(self, cost_goals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1022 if not (cost_goals is None or isinstance(cost_goals, list)):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1023 raise ValueError( _("Cost goals atribute must be a list or None") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1024 self.__cost_goals = cost_goals
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1025
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1026 def getCostPlanned(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1027 return self.__cost_planned
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1028
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1029 def setCostPlanned(self, cost_planned):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1030 if not (cost_planned is None or isinstance(cost_planned, list)):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1031 raise ValueError( _("Cost Planned atribute must be a list or None") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1032 self.__cost_planned = cost_planned
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1033
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1034 position = property(getPosition, setPosition, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1035 """Postion of the record in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1036 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1037 code = property(getCode, setCode, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1038 """Record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1039 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1040 budgetMeasures = property(getBudgetMeasures, setBudgetMeasures, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1041 """list of budget and Amended budget measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1042 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1043 certification = property(getCertification, setCertification,None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1044 """ list of certifications by months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1045 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1046 real_cost = property(getRealCost, setRealCost, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1047 """ list of real cost of construction for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1048 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1049 cost_goals = property(getCostGoals, setCostGoals, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1050 """ list of cost goals of construction for months measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1051 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1052 cost_planned = property(getCostPlanned, setCostPlanned, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1053 """ list of costs planned and amended cost planned measures
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1054 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1055
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1056
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1057 class Measure(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1058 """base.Measure:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1059
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1060 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1061 Measure object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1062 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1063 base.Measure(decimals, recordType, measure, lines,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1064 label, factor, yield_)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1065 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1066 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1067 +-- Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1068 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1069 "measure": Total result of measure.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1070 "lines": List of measure lines, List of LineM instances.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1071 "label": Record Identifiers that are used by some measure programs.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1072 "factor":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1073 "yield":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1074 "fixed": If fixed is True the yield is not calculated from measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1075 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1076 getMeasure()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1077 setMeasure(measure, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1078 {get/set}Lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1079 {get/set}Label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1080 getFactor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1081 setFactor(factor, decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1082 getYield()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1083 setYield(yield_, decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1084 getFixed()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1085 setFixed(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1086 buildMeasure(list_lines, type, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1087 calculateMeasure(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1088 updateYield(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1089 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1090
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1091 __slots__ = ["_Measure__measure",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1092 "_Measure__lines",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1093 "_Measure__label",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1094 "_Measure__factor",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1095 "_Measure__yield_",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1096 "_Measure__fixed"]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1097
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1098 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1099 return (self.__measure, self.__lines, self.__label,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1100 self.__factor, self.__yield_, self.__fixed)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1101
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1102 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1103 self.__measure = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1104 self.__lines = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1105 self.__label = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1106 self.__factor = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1107 self.__yield_ = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1108 self.__fixed = tuple[5]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1109
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1110 def __init__(self, decimals, recordType, measure, lines,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1111 label, factor, yield_):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1112 self.setMeasure(measure, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1113 self.lines = lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1114 self.label = label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1115 self.setFactor(factor, decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1116 self.setYield(yield_, decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1117 self.__fixed = False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1118
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1119 def getMeasure(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1120 return self.__measure
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1121
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1122 def setMeasure(self, measure, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1123 if not isinstance(measure, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1124 raise ValueError( utils.mapping(_("Measure must be a float "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1125 "number. Type: $1"), (type(measure),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1126 # TODO: test after
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1127 _DS = abs(decimals.DS)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1128 measure = round(measure, _DS)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1129 self.__measure = measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1130
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1131 def getLines(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1132 return self.__lines
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1133
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1134 def setLines(self, lines):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1135 if not isinstance(lines, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1136 raise ValueError( _("Lines must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1137 for _line in lines:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1138 if not isinstance(_line, MeasureLine):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1139 raise ValueError( _("Line must be a MeasureLine objetc") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1140 self.__lines = lines
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1141
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1142 def getLabel(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1143 return self.__label
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1144
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1145 def setLabel(self, label):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1146 self.__label = label
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1147
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1148 def setFactor(self, factor, decimals, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1149 if not isinstance(factor, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1150 raise ValueError( utils.mapping(_("Factor must be a float number "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1151 "|$1|"), (str(factor),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1152 # TODO: test after
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1153 _DF = abs(decimals.getDF(recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1154 factor = round(factor, _DF)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1155 self.__factor = factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1156
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1157 def getFactor(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1158 return self.__factor
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1159
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1160 def setYield(self, yield_, decimals, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1161 if not isinstance(yield_, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1162 raise ValueError( _("Yield must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1163 # TODO: test after
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1164 _DR = abs(decimals.getDR(recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1165 yield_ = round(yield_, _DR)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1166 self.__yield_ = yield_
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1167
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1168 def getYield(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1169 return self.__yield_
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1170
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1171 def setFixed(self, fixed, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1172 if not isinstance(fixed, bool):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1173 raise ValueError( _("Fixed must be boolean object") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1174 self.__fixed = fixed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1175 self.updateYield(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1176
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1177 def getFixed(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1178 return self.__fixed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1179
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1180 measure = property(getMeasure, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1181 """Total result of the measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1182 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1183 lines = property(getLines, setLines, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1184 """List of measure lines, List of "MeasureLine" instances
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1185 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1186 label = property(getLabel, setLabel, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1187 """Record identifiers that are used in some measure programs
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1188 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1189 factor = property(getFactor, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1190 """Factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1191 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1192 yield_ = property(getYield, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1193 """Yield of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1194 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1195 fixed = property(getFixed, setFixed,None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1196 """If fixed is True the yield is not calculated from measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1197 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1198
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1199 def buildMeasure(self, list_lines, type_, decimals, recordType):
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
1200 """setMeasure(list_lines, type_, decimals, recordType)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1201
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1202 list_lines: list of measure lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1203 [ [linetype, comment, units, length, width, height, formula], ... ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1204 linetype:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1205 #-#empty string -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1206 0 -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1207 1 -> Parcial Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1208 2 -> Accumulated Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1209 3 -> Formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1210 comment: comment string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1211 units: Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1212 length: Length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1213 width: Width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1214 height: Height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1215 formula: Can be a formula or a empty string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1216 Valid Operator: '(', ')', '+', '-', '*', '/' and '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1217 Valid variable: 'a', 'b', 'c','d' and 'p' (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1218 type: type of action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1219 M: Set measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1220 A: Add measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1221 decimal: budget decimals object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1222
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1223 Sets the measurelines for a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1224 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1225 # TODO: calcutate measure from lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1226 _parcial = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1227 _total = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1228 _lines = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1229 for _line in list_lines:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1230 _type, _comment = _line[0], _line[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1231 _units, _length = _line[2], _line[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1232 _width, _height = _line[4], _line[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1233 _formula = _line[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1234 _measure_line = MeasureLine(decimals, _type, _comment, _units,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1235 _length, _width, _height, _formula)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1236 _lines.append(_measure_line)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1237
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1238 if type_ == "M":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1239 self.lines = _lines
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1240 elif type_ == "A":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1241 self.lines.extend(_lines)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1242 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1243 raise ValueError( utils.mapping(_("Type must be M or A. Type: $1"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1244 (str(type_),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1245 self.calculateMeasure(decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1246
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1247 def calculateMeasure(self, decimals, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1248 #TODO: round acumulated_subtotal and parcial_subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1249 if len(self.lines) > 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1250 _acumulated_total = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1251 _parcial_total = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1252 for line in self.lines:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1253 _parcial = line.parcial
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1254 _acumulated_total += _parcial
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1255 if line.lineType == 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1256 line.setAcumulatedSubtotal(_acumulated_total, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1257 elif line.lineType == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1258 _parcialSubtotal = _acumulated_total - _parcial_total
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1259 line.setParcialSubtotal(_parcialSubtotal, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1260 _parcial_total = _acumulated_total
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1261 self.setMeasure(_acumulated_total, decimals)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1262 _DR = abs(decimals.getDR(recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1263 self.updateYield(decimals, recordType)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1264
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1265 def updateYield(self, decimals, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1266 if not self.fixed:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1267 self.setYield(self.measure, decimals, recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1268
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1269 class MeasureLine(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1270 """base.MeasureLine:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1271
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1272 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1273 MeasureLine object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1274 Constructor:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1275 base.MeasureLine(budget, type_, comment, units, length, width, height,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1276 formula)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1277 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1278 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1279 +-- MeasureLine
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1280 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1281 "lineType": Line type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1282 #-#empty string -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1283 0 -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1284 1 -> Parcial Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1285 2 -> Accumulated Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1286 3 -> Formula, the comment is a formula.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1287 "comment": Descriptive text string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1288 "units": Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1289 "length": length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1290 "width": Width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1291 "height": Height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1292 "formula": can be a valid formula or a empty string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1293 Valid Operator: '(', ')', '+', '-', '*', '/' and '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1294 Valid variable: 'a', 'b', 'c','d'y 'p' (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1295 "partial" : result of measure line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1296 "parcial_subtotal"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1297 "acumulated_subtotal"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1298 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1299 {get/set}LineType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1300 {get/set}Comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1301 {get/set}Units
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1302 {get/set}Length
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1303 {get/set}Width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1304 {get/set}Height
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1305 {get/set}Formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1306 getParcial
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1307 {get/set}ParcialSubtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1308 {get/set}AcumulatedSubtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1309 calculateParcial
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1310 eval_formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1311 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1312
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1313 __slots__ = ["_MeasureLine__lineType",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1314 "_MeasureLine__comment",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1315 "_MeasureLine__units",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1316 "_MeasureLine__length",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1317 "_MeasureLine__width",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1318 "_MeasureLine__height",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1319 "_MeasureLine__formula",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1320 "_MeasureLine__parcial",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1321 "_MeasureLine__parcial_subtotal",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1322 "_MeasureLine__acumulated_subtotal",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1323 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1324
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1325 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1326 return (self.__lineType, self.__comment, self.__units,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1327 self.__length, self.__width, self.__height, self.__formula,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1328 self.__parcial)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1329
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1330 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1331 self.__lineType = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1332 self.__comment = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1333 self.__units = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1334 self.__length = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1335 self.__width = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1336 self.__height = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1337 self.__formula = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1338 self.__parcial = tuple[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1339 #self.calculateParcial()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1340
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1341 def __init__(self, decimals, type_, comment, units, length, width, height,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1342 formula):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1343 self.__parcial = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1344 self.__parcial_subtotal = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1345 self.__acumulated_subtotal = 0.0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1346 self.lineType = type_
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1347 self.comment = comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1348 self.setUnits(units, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1349 self.setLength(length, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1350 self.setWidth(width, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1351 self.setHeight(height, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1352 self.setFormula(formula, decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1353 #self.calculateParcial()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1354
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1355 def getLineType(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1356 return self.__lineType
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1357
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1358 def getComment(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1359 return self.__comment
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1360
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1361 def getUnits(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1362 return self.__units
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1363
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1364 def getLength(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1365 return self.__length
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1366
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1367 def getWidth(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1368 return self.__width
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1369
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1370 def getHeight(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1371 return self.__height
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1372
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1373 def getFormula(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1374 return self.__formula
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1375
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1376 def getParcial(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1377 return self.__parcial
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1378
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1379 def getParcialSubtotal(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1380 return self.__parcial_subtotal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1381
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1382 def getAcumulatedSubtotal(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1383 return self.__acumulated_subtotal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1384
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1385 def setParcialSubtotal(self, parcial_subtotal, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1386 if not isinstance(parcial_subtotal, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1387 raise ValueError( utils.mapping(_(" Parcial Subtotal must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1388 "float number. Parcial: $1"), (str(parcial_subtotal),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1389 _DS = abs(decimals.DS)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1390 parcial_subtotal = round(parcial_subtotal, _DS)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1391 self.__parcial_subtotal = parcial_subtotal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1392
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1393 def setAcumulatedSubtotal(self, acumulated_subtotal, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1394 if not isinstance(acumulated_subtotal, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1395 raise ValueError( utils.mapping(_(" Acumulated Subtotal must be "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1396 "a float number. Parcial: $1"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1397 (str(acumulated_subtotal),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1398 _DS = abs(decimals.DS)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1399 acumulated_subtotal = round(acumulated_subtotal, _DS)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1400 self.__acumulated_subtotal = acumulated_subtotal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1401
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1402 def calculateParcial(self, decimals):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1403 _DS = abs(decimals.DS)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1404 if self.lineType == 1 or self.lineType == 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1405 _parcial = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1406 elif self.lineType == 0: # self.formula == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1407 if isinstance(self.units, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1408 _a = self.units
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1409 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1410 _a = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1411 if isinstance(self.length, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1412 _b = self.length
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1413 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1414 _b = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1415 if isinstance(self.width, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1416 _c = self.width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1417 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1418 _c = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1419 if isinstance(self.height, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1420 _d = self.height
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1421 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1422 _d = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1423 _parcial = _a * _b * _c * _d
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1424 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1425 _parcial = self.eval_formula()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1426 _parcial = round(_parcial, _DS)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1427 self.__parcial = _parcial
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1428
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1429 def setLineType(self, type_):
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1430 if not type_ in [0, 1, 2, 3]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1431 raise ValueError( utils.mapping(_("Invalid measure line type ($1)"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1432 (str(type_),)) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
1433 self.__lineType = type_
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1434
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1435 def setComment(self, comment):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1436 if not isinstance(comment, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1437 raise ValueError( utils.mapping(_("Measure Comment must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1438 "string ($1)"), (str(comment),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1439 self.__comment = comment
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1440
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1441 def setUnits(self, units, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1442 if units != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1443 if not isinstance(units, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1444 raise ValueError( utils.mapping(_("Invalid Measure Units ($1)"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1445 (str(units),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1446 _DN = abs(decimals.DN)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1447 units = round(units, _DN)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1448 self.__units = units
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1449 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1450 self.calculateParcial(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1451 except AttributeError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1452 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1453
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1454 def setLength(self, length, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1455 if length != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1456 if not isinstance(length, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1457 raise ValueError( utils.mapping(_("Invalid Measure length ($1)"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1458 (str(units),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1459 _DD = abs(decimals.DD)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1460 length = round(length, _DD)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1461 self.__length = length
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1462 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1463 self.calculateParcial(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1464 except AttributeError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1465 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1466
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1467 def setWidth(self, width, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1468 if width != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1469 if not isinstance(width, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1470 raise ValueError( utils.mapping(_("Invalid Measure Width ($1)"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1471 (str(units),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1472 _DD = abs(decimals.DD)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1473 width = round(width, _DD)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1474 self.__width = width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1475 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1476 self.calculateParcial(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1477 except AttributeError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1478 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1479
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1480 def setHeight(self, height, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1481 if height != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1482 if not isinstance(height, float):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1483 raise ValueError( utils.mapping(_("Invalid Measure Height ($1)"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1484 (str(height),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1485 _DD = abs(decimals.DD)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1486 height = round(height, _DD)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1487 self.__height = height
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1488 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1489 self.calculateParcial(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1490 except AttributeError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1491 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1492
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1493 def setFormula(self, formula, decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1494 if not isinstance(formula, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1495 raise ValueError( utils.mapping(_("Formula must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1496 "string ($1)"), (str(formula),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1497 if re.match(".*[^0123456789\.()\+\-\*/\^abcdp ].*", formula):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1498 raise ValueError( utils.mapping(_("There is invalid characters"\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1499 "in formula ($1)"), (str(formula),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1500 self.__formula = formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1501 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1502 self.calculateParcial(decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1503 except AttributeError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1504 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1505
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1506 lineType = property(getLineType, setLineType, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1507 """Type of measure line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1508 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1509 comment = property(getComment, setComment, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1510 """Text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1511 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1512 units = property(getUnits, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1513 """Number of units
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1514 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1515 length = property(getLength, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1516 """Length measure
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 width = property(getWidth, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1519 """Width measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1520 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1521 height = property(getHeight, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1522 """Height measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1523 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1524 formula = property(getFormula, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1525 """Formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1526 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1527 parcial = property(getParcial, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1528 """result of measure line
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1529 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1530 acumulated_subtotal = property(getAcumulatedSubtotal,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1531 None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1532 """Acumulated subtotal
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 parcial_subtotal = property(getParcialSubtotal,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1535 None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1536 """Parcial subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1537 """)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1538
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1539 def eval_formula(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1540 """eval_formula()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1541
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1542 formula:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1543 Valid Operator: '(', ')', '+', '-', '*', '/' and '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1544 Valid variable: 'a', 'b', 'c','d'y 'p' (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1545 units: Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1546 length: Length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1547 width: Width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1548 height: Height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1549
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1550 Evals the formula and return the result
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1551 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1552 formula = self.formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1553 a = self.units
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1554 b = self.length
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1555 c = self.width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1556 d = self.height
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1557 if a == "": a = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1558 if b == "": b = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1559 if c == "": c = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1560 if d == "": d = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1561 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1562 a = float(a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1563 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1564 raise ValueError( _("'a' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1565 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1566 b = float(b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1567 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1568 raise ValueError( _("'b' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1569 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1570 c = float(c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1571 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1572 raise ValueError( _("'c' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1573 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1574 d = float(d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1575 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1576 raise ValueError( _("'d' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1577 # spaces are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1578 formula.replace(" ","")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1579 # operators and varibles are replaced
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1580 formula = formula.replace("+", " + ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1581 formula = formula.replace("-", " - ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1582 formula = formula.replace("*", " * ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1583 formula = formula.replace("/", " / ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1584 formula = formula.replace("^", " ** ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1585 formula = formula.replace("(", " ( ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1586 formula = formula.replace(")", " ) ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1587 formula = formula.replace("a", str(a))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1588 formula = formula.replace("b", str(b))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1589 formula = formula.replace("c", str(c))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1590 formula = formula.replace("d", str(d))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1591 formula = formula.replace("p", "3.1415926")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1592 _list_formula = formula.split(" ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1593 _formula2 = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1594 for oper in _list_formula:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1595 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1596 _float_oper= str(float(oper))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1597 _formula2 = _formula2 + _float_oper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1598 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1599 _formula2 = _formula2 + oper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1600 _g ={"__builtins__":{}}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1601 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1602 return eval(_formula2, _g)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1603 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1604 raise ValueError( _("Invalid formula") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1605
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1606
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1607 class Decimals(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1608 """base.Decimals:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1609
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1610 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1611 Decimals object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1612 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1613 base.Decimals(DN=2, DD=2, DSP=2, DS=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1614 DFC=3, DFPU=3, DFUO=3, DFA=3,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1615 DRP=3, DRC=3, DRUO=3, DRA=3,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1616 DP=2, DC=2, DPU=2, DUO=2, DEA=2, DES=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1617 DIR=2, DIM=2, DIRC=2, DIMC=2, DCD=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1618 DIVISA="EUR")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1619 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1620 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1621 +-- Decimals
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1622 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1623 "DN": Number of decimal places of the field "equal-size parts" in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1624 measure lines.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1625 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1626 "DD": Number of decimal places of the three dimensions in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1627 measure lines.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1628 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1629 "DSP": Number of decimal places of the subtotal of a measure.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1630 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1631 "DS": Number of decimal places of the total sum of a measure.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1632 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1633 "DFC": Number of decimal places of the yield factor in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1634 of a chapter or subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1635 Dafault: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1636 "DFPU": Number of decimal places of the yield factor in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1637 of a unitary budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1638 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1639 "DFUO": Number of decimal places of the yield factor in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1640 of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1641 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1642 "DFA": Number of decimal places of the yield factor in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1643 of a Auxiliary element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1644 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1645 "DRC": Number of decimal places of the yield in a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1646 decomposition of a chapter or subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1647 Number of decimal places of the result of the multiplictaion of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1648 the yield (or measure) and the factor in a decomposition of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1649 chapter or subcharter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1650 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1651 "DRPU": Number of decimal places of the yield in a decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1652 of a unitary budget record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1653 Number of decumal places of the result of the multiplication of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1654 the factor and the yield in a decompositon of a untitary budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1655 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1656 "DRUO": Number of decimal places of the yield in a decomposition of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1657 unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1658 Decimal places of the result of the multiplication of the yield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1659 and the factor in a descomposition of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1660 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1661 "DRA": Number of decimal places of the yield in a decompositon of a
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1662 auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1663 Number of decimal places of the result of the multiplication of
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1664 the yield and the factor in a descomposition of a auxilar element.Decimales
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1665 Default: 3 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1666 "DP": Number of decimal places of the price of a budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1667 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1668 "DC": Number of decimal places of the price of a chapter or subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1669 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1670 "DPU": Number of decimal places of the price of a unitary budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1671 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1672 "DUO": Number of decimal places of the price of a unit of work.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1673 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1674 "DEA": Number of decimal places of the price of a auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1675 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1676 "DES": Number of decimal places of the price of the simple elements.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1677 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1678 "DIR": Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1679 the total yield and the price of the elements of a unit of work or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1680 a auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1681 "DIRC": Number of decimal places of the resulting amount to multiply
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1682 the total yield and the price of the elements of a budget, chapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1683 or a subchapter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1684 "DCD": Number of decimal places ot the resulting amount to sum the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1685 direct costs of a unit of work (and auxiliar element).
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1686 Number of decimal places of the indirect costs.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1687 Default: 2 decimal places.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1688 "DIVISA": monetary unit.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1689 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1690 haskey(key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1691 getD(recordtype)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1692 getDF(recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1693 getDR(recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1694 getDI(recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1695 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1696 # TODO: get/set methods
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1697
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1698 def __init__(self,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1699 DN=2, DD=2, DSP=2, DS=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1700 DFC=3, DFPU=3, DFUO=3, DFA=3,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1701 DRC=3, DRPU=3, DRUO=3, DRA=3,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1702 DP=2, DC=2, DPU=2, DUO=2, DEA=2, DES=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1703 DIR=2, DIRC=2, DCD=2,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1704 DIVISA="EUR" ):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1705 self.DN = DN
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1706 self.DD = DD
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1707 self.DSP = DSP
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1708 self.DS = DS
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1709 self.DFP = 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1710 self.DFC = DFC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1711 self.DFPU = DFPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1712 self.DFUO = DFUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1713 self.DFA = DFA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1714 self.DRP = 3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1715 self.DRC = DRC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1716 self.DRPU = DRPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1717 self.DRUO = DRUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1718 self.DRA = DRA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1719 self.DP = DP
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1720 self.DC = DC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1721 self.DPU = DPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1722 self.DUO = DUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1723 self.DEA = DEA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1724 self.DES = DES
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1725 self.DIR = DIR
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1726 self.DIRC = DIRC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1727 self.DCD = DCD
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1728 self.DIVISA = DIVISA
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1729
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1730 def __getitem__(self, key):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1731 return self.__dict__[key]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1732
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1733 def haskey(self, key):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1734 return key in self.__dict__
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1735
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1736 def getD(self, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1737 # DP: budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1738 # DC: chapter and subcharter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1739 # DUO: unit.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1740 # DEA: auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1741 # DES: simple element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1742 _hierarchy = recordType.hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1743 if _hierarchy == 0: #budget, type 0, subtipe "OB"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1744 _decimal = self.DP
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1745 elif _hierarchy == 1: #chapter/subcharter, type 0, subtipe ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1746 _decimal = self.DC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1747 else: # other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1748 _type = recordType.type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1749 _subtype = recordType.subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1750 if _subtype == "EA": # auxiliar element type 0 subitype "EA"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1751 _decimal = self.DEA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1752 if _subtype == "PU": # unitary budget type 0 subitype "PU"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1753 _decimal = self.DPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1754 elif (_type in [1, 2, 3] or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1755 _subtype in ["H", "Q", "%", "MC", "MCr", "MM", "MS", "ME",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1756 "MCu", "Mal","ML", "M"]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1757 ): # simple element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1758 _decimal = self.DES
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1759 else: # unit type 0, subtipe ["EU", "EC", "EF", "PA"]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1760 _decimal = self.DUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1761 return _decimal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1762
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1763 def getDF(self, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1764 # Factor: DF
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1765 # ->DFP: Budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1766 # ->DFC: Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1767 # ->DFUO: Unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1768 # ->DFA: Auxiliar
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1769 # ->DFPU: Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1770 if recordType.hierarchy == 0: #budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1771 _decimal = self.DFP
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1772 elif recordType.hierarchy == 1: #chapter/subcharter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1773 _decimal = self.DFC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1774 else: # other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1775 if recordType.subtype == "EA": # auxiliar element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1776 _decimal = self.DFA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1777 if recordType.subtype == "PU": # unitary budget element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1778 _decimal = self.DFPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1779 else: # unit EU EC EF PA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1780 _decimal = self.DFUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1781 return _decimal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1782
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1783 def getDR(self, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1784 # Yield: DR
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1785 # ->DRP: Budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1786 # ->DRC: Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1787 # ->DRUO: Unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1788 # ->DRA: Auxiliar
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1789 # ->DRPU: Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1790 if recordType.hierarchy == 0: #budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1791 _decimal = self.DRP
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1792 elif recordType.hierarchy == 1: #chapter/subcharter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1793 _decimal = self.DRC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1794 else: # other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1795 if recordType.subtype == "EA": # auxiliar element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1796 _decimal = self.DRA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1797 if recordType.subtype == "PU": # unitary budget element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1798 _decimal = self.DRPU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1799 else: # unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1800 _decimal = self.DRUO
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1801 return _decimal
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1802
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1803 def getDI(self, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1804 # DIRC: budget, chapter and subcharter.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1805 # DIR: unit, auxiliar element.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1806 _hierarchy = recordType.hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1807 _subtype = recordType.subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1808 if _hierarchy == 0 or _hierarchy == 1 or _subtype == "PU":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1809 #budget, type 0, subtipe "OB"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1810 #chapter/subcharter, type 0, subtipe ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1811 #unitary budget, type 2, subtype "PU"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1812 _decimal = self.DIRC
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1813 else: # other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1814 # auxiliar element type 0 subitype "EA"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1815 # unit type 0, subtipe ["EU", "EC", "EF", "PA", "PU"]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1816 _decimal = self.DIR
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1817 return _decimal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1818
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1819
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1820 class Sheet(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1821 """base.Sheet:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1822 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1823 Sheet of conditions object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1824 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1825 base.Sheet(sheet_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1826 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1827 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1828 +-- Sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1829 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1830 "sheet_dict": { <Field key> : { <Section key> : <Paragraph key>}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1831 <Field key>: must be in Budget.SheetFields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1832 <Section key>: must be in Budget.SheetSections
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1833 <Paragraph key>: must be in Budget.SheetParagraph
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1834 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1835 {get/set}Sheet_dict
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1836 getFields
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1837 getSections
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1838 getParagraph
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1839 addField
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1840 addSection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1841 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1842 __slots__ = ["_Sheet__sheet_dict"]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1843
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1844 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1845 return (self.__sheet_dict,)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1846
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1847 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1848 self.__sheet_dict = tuple[0]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1849
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1850 def __init__(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1851 self.__sheet_dict = {}
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1852
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1853 def getSheet_dict(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1854 return self.__sheet_dict
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1855
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1856 def setSheet_dict(self, sheet_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1857 if not isinstance(sheet_dict, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1858 raise ValueError( _("sheet_dict must be a dictionay") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1859 self.__sheet_dict = sheet_dict
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1860
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1861 def getFields(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1862 return self.sheet_dict.keys()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1863
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1864 def getSections(self, field):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1865 if field in self.__sheet_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1866 return self.__sheet_dict[field].keys()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1867 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1868 return None
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1869
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1870 def getParagraph(self, field, section):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1871 if (field in self.__sheet_dict and
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1872 section in self.__sheet_dict[field]):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1873 return self.__sheet_dict[field][section]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1874 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1875 return None
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1876
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1877 def addField(self, field, section_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1878 if not isinstance(field, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1879 raise ValueError( _("sheet field must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1880 if not isinstance(section_dict, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1881 raise ValueError( _("section_dict must be a dictionary") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1882 self.__sheet_dict[field] = section_dict
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1883
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1884 def addSection(self, field, section, paragraph):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1885 if not isinstance(field, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1886 raise ValueError( _("sheet field must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1887 if not isinstance(section, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1888 raise ValueError( _("sheet section must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1889 if not isinstance(paragraph, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1890 raise ValueError( _("sheet paragraph must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1891 if not field in self.__sheet_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1892 self.addField(field, { })
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1893 _field = self.__sheet_dict[field]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1894 _field[section] = paragraph
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1895
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1896 sheet_dict = property(getSheet_dict, setSheet_dict, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1897 """Sheet dictionary { <Field key> : { <Section key> : <Paragraph key>}""")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1898
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1899
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1900 class Budget(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1901 """base.Budget:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1902
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1903 Description:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1904 Budget object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1905 +-- __records: dictionary records { code : Record }
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1906 +-- __synonyms: synonyms dictionary. TODO { "code" : ["synonym",],}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1907 Each record code can have synonym codes.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1908 +-- __root: the root record code
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1909 +-- __decimals: List with the decimal places used to round the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1910 - result of the calculations with prices and measures
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1911 - The values are Decimals objects
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1912 - The <0> objets is the default Decimals (seted in FIEBDC-3),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1913 - The others keys are for the diferent groups of Prices
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1914 +-- __percentages: percentages dictionary:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1915 { "CI" : "",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1916 "GG" : "",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1917 "BI" : "",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1918 "BAJA": "",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1919 "IVA" : ""}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1920 +-- __file_owner
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1921 +-- __title_list: titles list: [ "Header", ["Title1", "Title2", ... ] ]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1922 List with the Headers and list of Titles for prices and
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1923 decimal places.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1924 The Headers is the type of hierarchy of the prices
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1925 Each Title have a group of Prices and a Decimals definition
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1926 The records can have diferent prices for diferent ages, geografical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1927 places, ...
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1928 +-- __title_index: A integer. The active group of Prices and Decimals.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1929 +-- __sheet_sections: sheet sections dictionary { sheet_code : sheet_title }
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1930 +-- __sheet_fields: sheet fields dictionary { field_code : field_title }
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1931 +-- __sheet_paragraphs: sheet paragraphs dictionary
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1932 { paragraph_code : paragraph_text}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1933 +-- __companys: Dictionary whith companys object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1934 { company_code: company_object }
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1935
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1936 +-- __comment
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1937 - +-- __date
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1938 - +-- __budgetType" A integer. Type of data in budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1939 - 0 -> Undefined
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1940 - 1 -> Base data.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1941 - 2 -> Budget.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1942 - 3 -> Certificate.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1943 - 4 -> Base date update.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1944 - +-- __budgetCerficateOrder" Only valid if budgetType is 3.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1945 - +-- __budgetCerficateDate" Only valid if budgetType is 3
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1946 - +-- __tec_info": Dictionary whith tecnical information
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1947 - {ti_code : ["desciption text", "unit"]}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1948 - +-- __labels": Label dictionary { "label": [ "code", ], }
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1949
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1950
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1951 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1952 base.Budget()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1953 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1954 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1955 +-- Budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1956 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1957 No public Atributes
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1958 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1959 iter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1960 iterPreOrder
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1961 iterPostOrder
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1962 getRoot(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1963 hasPath(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1964 getchildren(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1965 setOwner(self, owner)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1966 setDate(self, date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1967 setComment(self, comment)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1968 setBudgetType(self, type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1969 setCertificateOrder(self, order)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1970 setCertificateDate(self, date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1971 setTitleList(self, title)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1972 getTitleList(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1973 getActiveTitle(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1974 setDecimals(self, dictionary)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1975 getDecimals(self, decimal="All", N=None)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1976 setPercentages(self, dictionary)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1977 getPercentages(self, percentage="All")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1978 getAllParents(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1979 getAllchildren(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1980 getNDecomposition(self, code, N)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1981 getDecomposition(self,code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1982 getMeasure(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1983 getStrYield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1984 getStrFactor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1985 setTree(sef, code, child_code, position, factor, yield_, total,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1986 list_lines, label, type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1987 eval_formula(self, formula, a, b, c, d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1988 getText(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1989 setText(self, code, text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1990 setRecord(self, code, synonyms, hierarchy, unit, sumary, ...
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1991 hasRecord(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1992 getRecord
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1993 addPriceToRecord
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1994 getStrPriceFromRecord
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1995 getCode(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1996 getAmount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1997 getStrAmount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1998 setSheetSection(self, sheet_code, sheet_title)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1999 hasSheetSection(self, section)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2000 setSheetSections(self,dictionary)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2001 setSheetField(self, field_code, field_title)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2002 hasSheetField(self, field)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2003 getSheetField(self, field)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2004 setSheetFields(self, field_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2005 setSheetParagraph(self, paragraph_code, paragraph_text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2006 hasSheetParagraph(self, paragraph)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2007 getSheetParagraph(self, paragraph)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2008 setSheetParagraphs(self, paragraph_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2009 setSheetRecord(self, record_code,field, section_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2010 addFile(self, record_code, filename)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2011 setCompany(self, code, summary, name, offices, cif, web, email )
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2012 getCompany
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2013 getCompanyKeys
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2014 addTecInfo(self, ti_code, text, unit)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2015 hasTecInfo(self, ti_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2016 getTecInfo(self, ti_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2017 setTecnicalInformation(self, _record_code, _ti_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2018 changeCode(self, record_code, new_rocord_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2019 addLabel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2020 setParametricSelectComment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2021 setParametricSummary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2022 setParametricText
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2023 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2024
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2025 def __init__(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2026 """__init__(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2027
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2028 Initialize the budget atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2029 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2030 # title_index: A integer. The active group of Prices and Decimals.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2031 # TODO: change title_index
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2032 self.__title_index = 0
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2033 # List with the decimal places used to round the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2034 # result of the calculations with prices and measures
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2035 # The values are Decimals objects
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2036 # The <0> objets is the default Decimals (seted in FIEBDC-3),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2037 # The others keys are for the diferent groups of Prices
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2038 self.__decimals = [Decimals(), Decimals()]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2039 # Dictionary with the percentages
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2040 # keys:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2041 # "CI" Indirect Cost
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2042 # "GG" General expenses
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2043 # "BI" Industrial benefit
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2044 # "BAJA" Low (what this do here?)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2045 # "IVA" Tax
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2046 self.__percentages = { "CI" : "" ,"GG": "", "BI": "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2047 "BAJA": "", "IVA" : ""}
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2048 # List with the Headers and list of Titles for prices and
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2049 # decimal places.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2050 # [ "Header", ["Title1", "Title2", ... ] ]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2051 # The records can have diferent prices for diferent ages, geografical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2052 # places, ...
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2053 # The Headers is the type of hierarchy of the prices
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2054 # Each Title have a group of Prices and a Decimals definition
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2055 self.__title_list = [ "", [ ] ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2056 # The root record code.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2057 self.__root = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2058 self.__file_owner = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2059 self.__comment = ""
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2060 self.__budgetCerficateOrder = None # Only valid if budgetType is 3.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2061 self.__budgetCerficateDate = None # Only valid if budgetType is 3.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2062 self.__date = (0,0,0)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2063 # budgetType: A integer. Type of data in budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2064 # 0 -> Undefined
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2065 # 1 -> Base data.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2066 # 2 -> Budget.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2067 # 3 -> Certificate.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2068 # 4 -> Base date update.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2069 self.__budgetType = 0
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2070 # Dictionary with the budget records: { "code" : Record object, }
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2071 self.__records = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2072 # Dictionary with the records synonyms.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2073 # { "code" : ["synonym",],}
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2074 # Each record code can have synonym codes.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2075 self.__synonyms = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2076 # sheet_sections: Dictionary whith de sheet sections
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2077 self.__sheet_sections = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2078 # sheet_fields: Dictionary whith sheet fields
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2079 self.__sheet_fields = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2080 # sheet_paragraphs: Dictionary whith sheet paragraphs
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2081 self.__sheet_paragraphs = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2082 # companys: Dictionary whith companys object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2083 # { company_code: company_object }
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2084 self.__companys = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2085 # tec_info: Dictionary whith tecnical information
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2086 # {ti_code : ["desciption text", "unit"]}
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2087 self.__tec_info = { }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2088 # labels: Label dictionary { "label": [ "code", ], }
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2089 self.__labels = { }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2090
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2091 def __getstate__(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2092 return (self.__title_index, self.__decimals, self.__percentages,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2093 self.__title_list, self.__root, self.__file_owner,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2094 self.__records, self.__synonyms, self.__sheet_sections,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2095 self.__sheet_fields, self.__sheet_paragraphs,self.__companys,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2096 self.__tec_info, self.__labels)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2097
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2098 def __setstate__(self, tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2099 self.__title_index = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2100 self.__decimals = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2101 self.__percentages = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2102 self.__title_list = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2103 self.__root = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2104 self.__file_owner = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2105 self.__records = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2106 self.__synonyms = tuple[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2107 self.__sheet_sections = tuple[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2108 self.__sheet_fields = tuple[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2109 self.__sheet_paragraphs = tuple[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2110 self.__companys = tuple[11]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2111 self.__tec_info = tuple[12]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2112 self.__labels = tuple[13]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2113
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2114 def iter(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2115 for record in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2116 yield record
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2117
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2118 def iterPreOrder(self, recordCode, codes=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2119 if codes is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2120 codes = []
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2121 _children = self.getchildren(recordCode)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2122 for _child in _children:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2123 if not _child in codes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2124 codes.append(_child)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2125 self.iterPreOrder(_child, codes)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2126 return codes
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2127
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2128 def iterPostOrder(self, recordCode, codes=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2129 if codes is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2130 codes = []
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2131 _children = self.getchildren(recordCode)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2132 for _child in _children:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2133 if not _child in codes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2134 self.iterPreOrder(_child, codes)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2135 codes.append(_child)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2136 return codes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2137
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2138 def getRoot(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2139 """getRoot(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2140
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2141 Returns the root record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2142 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2143 return self.__root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2144
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2145 def hasPath(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2146 """hasPath(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2147
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2148 path: The path of the record in the budget, It is a tuple.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2149 Tests if the path is valid in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2150 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2151 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2152 self.getCode(path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2153 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2154 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2155 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2156
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2157 def getchildren(self, code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2158 """getchildren(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2159
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2160 code: a record code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2161 Return a list whith the child codes of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2162 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2163 _record = self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2164 _children = _record.children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2165 _child_code = [ _child.code for _child in _children ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2166 return _child_code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2167
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2168 def setOwner(self, owner):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2169 """setOwner(self, owner)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2170
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2171 owner: data owner
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2172 Set the data owner.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2173 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2174 if isinstance(owner, basestring):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2175 self.__file_owner = owner
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2176 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2177 raise TypeError( _("Owner must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2178
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2179 def setDate(self, date):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2180 """setOwner(self, date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2181
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2182 date (_y, _m, _d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2183 Set the date when de file was generated
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2184 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2185 if isinstance(date, tuple) and len(date) == 3 and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2186 isinstance(date[0], int) and isinstance(date[1], int) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2187 isinstance(date[2], int) and date[1] in range(13) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2188 date[2] in range(32):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2189 if date[1] != 0 and date[2] != 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2190 datetime.date(*date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2191 self.__date = date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2192 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2193 raise TypeError( utils.mapping(_("Invalid Date: $1"),(str(date),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2194
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2195 def setComment(self, comment):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2196 """setOwner(self, comment)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2197
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2198 comment: text to comment the budged
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2199 Set the comment.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2200 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2201 if isinstance(comment, basestring):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2202 self.__comment = comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2203 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2204 raise TypeError( _("Comment must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2205
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2206 def setBudgeType(self, budget_type):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2207 """setOwner(self, budget_type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2208
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2209 budget_type: type of data in budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2210 0 -> Undefined
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2211 1 -> Base data.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2212 2 -> Budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2213 3 -> Budget certificate.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2214 4 -> Base date update.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2215 Set the budget type.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2216 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2217 if budget_type in [1, 2, 3, 4]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2218 self.__budgetType = budget_type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2219 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2220 raise ValueError( _("Budget type must be 1, 2, 3 or 4.") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2221
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2222 def setCertificateOrder(self, certificate_order, certificate_date):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2223 """setOwner(self, budget_type)
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 certificate_order: certificate number
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2226 certificate_date: certificate date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2227 Set the certificate order and date.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2228 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2229 if isinstance(certificate_order, int):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2230 self.__budgetCerficateOrder = certificate_order
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2231 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2232 raise ValueError( _("Certificate order must be a integer.") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2233
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2234 def setCertificateDater(self, certificate_date):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2235 """setCertidicateDate(self, certificate_date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2236
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2237 Set the certificate date.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2238 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2239 if isinstance(certificate_date, tuple) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2240 len(certificate_date) == 3 and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2241 isinstance(certificate_date[0], int) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2242 isinstance(certificate_date[1], int) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2243 isinstance(certificate_date[2], int):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2244 datetime.date(*certificate_date)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2245 self.__budgetCerficateDate = certificate_date
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2246 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2247 raise ValueError( _("Budget certificate Date must be a valid Date.") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2248
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2249 def setTitleList(self, title_list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2250 """setTitleList(self, title_list)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2251
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2252 title_list: [ "Header", ["Title1", "Title2", ... ] ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2253 Set the header and titles for the price groups and decimals.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2254 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2255 title_list[0] = str(title_list[0])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2256 if isinstance(title_list, list) and isinstance(title_list[1], list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2257 for i in range(len(title_list[1])):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2258 title_list[1][i] = str(title_list[1][i])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2259 self.__title_list = title_list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2260 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2261 raise TypeError( _("Invalid title list format") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2262
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2263 def getTitleList(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2264 """ getTitleList(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2265
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2266 Returns the header and titles for the price groups and decimals.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2267 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2268 return self.__title_list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2269
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2270 def getActiveTitle(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2271 """getActiveTitle(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2272
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2273 Returns the active Title of price group
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2274 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2275 return self.__title_index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2276
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2277 def setDecimals(self, dictionary, N):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2278 """setDecimals(self, dictionary, N)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2279
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2280 dictionay: the decimal dictionary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2281 N: the price group
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2282 Sets the Decimals for a price group.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2283 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2284 if N == -1 or N == len(self.__decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2285 _default_decimals = self.__decimals[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2286 self.__decimals.append(_default_decimals)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2287 elif N < len(self.__decimals):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2288 _default_decimals = self.__decimals[N]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2289 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2290 raise IndexError( _("Invalid Index Title") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2291 for _decimal in dictionary:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2292 if dictionary[_decimal] == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2293 dictionary[_decimal] = eval("_default_decimals." + _decimal)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2294 decimals = Decimals(dictionary["DN"], dictionary["DD"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2295 dictionary["DSP"], dictionary["DS"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2296 dictionary["DFC"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2297 dictionary["DFPU"], dictionary["DFUO"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2298 dictionary["DFA"], dictionary["DRC"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2299 dictionary["DRPU"], dictionary["DRUO"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2300 dictionary["DRA"], dictionary["DP"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2301 dictionary["DC"], dictionary["DPU"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2302 dictionary["DUO"], dictionary["DEA"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2303 dictionary["DES"], dictionary["DIR"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2304 dictionary["DIRC"], dictionary["DCD"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2305 dictionary["DIVISA"])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2306 self.__decimals[N] = decimals
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2307
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2308 def getDecimals(self, decimal=None, N=None):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2309 """getDecimals(self,decimal="All",N=None)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2310
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2311 decimal:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2312 "All": Return a Decimals objet for a price group
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2313 "keys": Return the keys of a Decimal object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2314 key: Return a Decimal value for a price group
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2315 N: the price group None,1,2,..
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2316 None: Return the active price group
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2317 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2318 if decimal is None: decimal = "All"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2319 if N is None: N = self.getActiveTitle()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2320 if decimal == "All":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2321 return self.__decimals[N+1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2322 elif decimal == "keys":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2323 return self.__decimals[N+1].keys
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2324 elif self.__decimals[N+1].haskey(decimal):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2325 return self.__decimals[N+1][decimal]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2326 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2327 raise KeyError( _("Decimal Key error") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2328
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2329 def setPercentages(self, dictionary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2330 """setPercentages(self, dictionary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2331
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2332 dictionary: the percentage dictionary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2333 Sets the percentage dictionary.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2334 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2335 _default_percentages = self.__percentages
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2336 for percentage in dictionary:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2337 if dictionary[percentage] == 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2338 dictionary[percentage] = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2339 elif dictionary[percentage] == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2340 dictionary[percentage] = _default_percentages[percentage]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2341 _percentages = { "CI": dictionary["CI"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2342 "GG": dictionary["GG"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2343 "BI": dictionary["BI"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2344 "BAJA": dictionary["BAJA"],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2345 "IVA" : dictionary["IVA"]}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2346 self.__percentages = _percentages
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2347
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2348 def getPercentages(self, key=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2349 """getPercentages(self, key=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2350
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2351 key:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2352 "All": Return the Percentages dictionary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2353 "keys": Return the keys of a Percentages object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2354 key: Return a Percentages value for the key
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2355 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2356 if Key is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 17
diff changeset
2357 key = "All"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2358 if key == "All":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2359 return self.__percentages
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2360 elif key == "keys":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2361 return self.__percentages.keys
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2362 elif key in self.__percentages:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2363 return self.__percentages[key]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2364 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2365 raise KeyError( _("Invalid Percentage key") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2366
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2367 def getAllParents(self,code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2368 """getAllParents(self,code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2369
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2370 code: a record code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2371 Returns a list with all the parents of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2372 All record which the record is in its descomposition list,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2373 including the parents of the parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2374 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2375 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2376 _parents = self.__records[code].parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2377 if len(_parents) == 0: return [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2378 for _antecesor in _parents[:]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2379 _parents = _parents + self.getAllParents(_antecesor)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2380 return _parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2381 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2382 return [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2383
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2384 def getAllchildren(self,code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2385 """getAllchildren(self,code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2386
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2387 code: a record code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2388 Returns a list with all the children of a record, including
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2389 the children of the children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2390 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2391 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2392 _children = self.__records[code].children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2393 _children = [ _child.code for _child in _children ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2394 for _child in _children[:]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2395 _children = _children + self.getAllchildren(_child)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2396 return _children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2397 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2398 return [ ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2399
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2400 def getNDecomposition(self, code, N):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2401 """getDecomposition(self,path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2402
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2403 path: the path for a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2404 Returns the Decomposition object of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2405 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2406 _record = self.getRecord(code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2407 _decomposition_list = _record.children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2408 _decomposition = _decomposition_list[N]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2409 return _decomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2410
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2411 def getDecomposition(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2412 """getDecomposition(self,path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2413
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2414 path: the path for a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2415 Returns the Decomposition object of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2416 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2417 if path == (0,):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2418 _type = self.getRecord(self.__root).recordType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2419 return Decomposition( 0, self.__root,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2420 [Measure(self.getDecimals(), _type,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2421 0.0, [], "", 1.0, 1.0)])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2422 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2423 return self.getNDecomposition(self.getCode(path[:-1]), path[-1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2424
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2425 def getMeasure(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2426 """getMeasure(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2427
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2428 path: the path for a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2429 Return the measute object of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2430 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2431 _decomposition = self.getDecomposition(path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2432 _measure = _decomposition.budgetMeasures[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2433 return _measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2434
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2435 def getStrYield(self, measure, recordType):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2436 #_DR = measure.getDR(self.getDecimals())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2437 _DR = abs(self.getDecimals().getDR(recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2438 _yield = ("%." + str(_DR) + "f" ) % measure.yield_
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2439 return _yield
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2440
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2441 def getStrFactor(self, measure, recorType):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2442 _DF = abs(self.getDecimals().getDF(recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2443 #_DF = measure.getDF(self.getDecimals())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2444 _factor = ("%." + str(_DF) + "f" ) % measure.factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2445 return _factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2446
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2447 def setTree(self, code, child_code, position, factor, yield_, total,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2448 list_lines, label, type_):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2449 """setTree(self, code, child_code, position, factor,yield_, total,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2450 list_lines, label, type_)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2451
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2452 code: the parent record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2453 child_code: child record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2454 position: position of child record in record parent record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2455 decomposition. Position == -1 -> new child
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2456 factor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2457 yield_:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2458 total: total measure (float)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2459 list_lines: list of measure lines
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2460 [ [linetype, comment, units, length, width, height], ... ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2461 linetype:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2462 empty string -> Normal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2463 1 -> Parcial Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2464 2 -> Accumulated Subtotal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2465 3 -> Formula, the comment is a formula.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2466 comment: Can be a descriptive text or a formula
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2467 Valid Operator: '(', ')', '+', '-', '*', '/' and '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2468 Valid variable: 'a', 'b', 'c','d'y 'p' (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2469 units: Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2470 length: Length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2471 width: Width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2472 height: Height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2473 label: Record Identifiers that are used by some measure programs.
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2474 type_: type of action
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2475 M: Set measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2476 A: Add measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2477 Sets the decomposition of a record in a child record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2478 """
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2479 if code is None: # No-estructured measures
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2480 code = self.getRoot()
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2481 if code == None: # No root
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2482 print( "No-estructured measures. Adding root record " +
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2483 str(self.setRecord("root", [], 0, "", "", [0.0,], [(1,1,1970)],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2484 0, "") ))
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2485 code = self.getRoot()
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2486
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2487 if not utils.is_valid_code(code)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2488 raise ValueError( utils.mapping(_("Invalid parent code: $1"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2489 (str(code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2490 if not utils.is_valid_code(child_code)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2491 raise ValueError( utils.mapping(_("Invalid child code: $1 $2"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2492 (str(code),str(child_code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2493 if not isinstance(position, int):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2494 raise ValueError( utils.mapping(_("Invalid position in measure "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2495 "$1, in code $2"), (str(parent_code), str(position))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2496 # Test circular references
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2497 _all_parent_list = self.getAllParents(code) + [ code ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2498 _all_child_list = self.getAllchildren(child_code) + [ child_code ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2499 for _parent_code in _all_parent_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2500 if _parent_code in _all_child_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2501 # TODO: change return to except
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2502 print(utils.mapping(_("Circular Decomposition, parent code: "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2503 "$1, child code: $2, repeated code: $3"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2504 (str(code), str(child_code), str(_parent_code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2505 return
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2506
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2507 # Creating reference to parent code in child record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2508 if child_code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2509 _child_record = self.__records[child_code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2510 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2511 _child_record = self.setRecord(child_code, [], -1, "", "", [], [],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2512 "", "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2513 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2514 code = self.__records[code].code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2515 _child_record.appendParent(code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2516 child_code = self.__records[child_code].code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2517 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2518 # if the code exits retake previous values.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2519 _record = self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2520 _child_number = len(_record.children)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2521 if position == -1: # New child
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2522 position = _child_number
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2523 if position == -2: # No-estructured measures or empty position (error in FIEBDC file)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2524 positions = _record.getChildPositions(child_code)
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2525 if len(positions) == 1:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2526 position = positions[0]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2527 print(utils.mapping(_("No-estructured measure or empty position. Parent Code: "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2528 "$1, Child code: $2, Position: $3"),(str(code), str(child_code), str(position))) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2529 else:
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2530 position = _child_number
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2531 print(utils.mapping(_("No-estructured measure or empty position. "\
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2532 "Repeated child in unspecified position. "\
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2533 "It is impossible to determine the position. "\
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2534 "New child is added in the decomposition. "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2535 "Parent code: $1, Child code: $2, Position: $3"),(str(code), str(child_code), str(position))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2536 if position == _child_number:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2537 # The record do not have the child
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2538 if not isinstance(factor, float): factor = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2539 if not isinstance(yield_, float): yield_ = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2540 if not isinstance(total, float): total = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2541 if not isinstance(list_lines, list): list_lines = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2542 _child = _record.appendChild(child_code, self.getDecimals(),
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2543 factor, yield_, total, list_lines, type_, label)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2544 elif position < _child_number:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2545 # The record have the child
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2546 _child = _record.children[position]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2547 if child_code != "" and child_code != _child.code:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2548 _child.code = child_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2549 if factor != "" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2550 if not isinstance(factor, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2551 factor == 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2552 _child.budgetMeasures[0].setFactor(factor,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2553 self.getDecimals(), _record.recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2554 if yield_ != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2555 if not isinstance(yield_, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2556 yield_ = 1.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2557 _child.budgetMeasures[0].setYield(yield_,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2558 self.getDecimals(), _record.recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2559 _measure = _child.budgetMeasures[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2560 if total != "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2561 if not isinstance(total, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2562 yield_ = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2563 _measure.setMeasure(total, self.getDecimals())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2564 if isinstance(list_lines, list) and len(list_lines) > 0:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2565 _measure.buildMeasure(list_lines, type_, self.getDecimals(),
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2566 _record.recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2567 if isinstance(label, str) and label != "" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2568 _measure.label = label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2569 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2570 # TODO: change return for except
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2571 print(utils.mapping(_("Error: Invalid child position in "
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2572 "decomposition. Parent code: $1 Child code: $2 "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2573 "Position: $3"), (str(code), str(child_code), str(position))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2574 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2575 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2576 if child_code == "" :
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2577 print(utils.mapping(_("Error: Empty child code. Parent code: "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2578 "$1 Position: $2"), (str(code), str(position))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2579 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2580 if position == -1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2581 position = 0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2582 elif position != 0:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2583 print(utils.mapping(_("Error: Invalid child position in "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2584 "decomposition. Parent code: $1 Child code: $2 "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2585 "Position: $3"), (str(code), str(child_code), str(position))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2586 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2587 if not isinstance(factor, float):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2588 factor = 1.0
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2589 if not isinstance(yield_, float):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2590 yield_ = 1.0
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2591 if not isinstance(total, float):
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2592 total = 1.0
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2593 _record = self.setRecord(code, [], "", "", "", [], [],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2594 "", "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2595 _child = _record.appendChild(child_code, self.getDecimals(),
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2596 factor, yield_, total, list_lines, type_, label)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2597
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2598 def eval_formula(self, formula, a, b, c, d):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2599 """eval_formula(self, formula, a, b, c, d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2600
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2601 formula:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2602 Valid Operator: '(', ')', '+', '-', '*', '/' and '^'
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2603 Valid variable: 'a', 'b', 'c','d'y 'p' (Pi=3.1415926)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2604 units: Number of Units (a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2605 length: Length (b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2606 width: Width (c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2607 height: Height (d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2608
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2609 Evals the formula and return the result
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2610 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2611 if a == "": a = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2612 if b == "": b = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2613 if c == "": c = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2614 if d == "": d = 0.0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2615 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2616 a = float(a)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2617 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2618 raise ValueError( _("'a' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2619 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2620 b = float(b)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2621 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2622 raise ValueError( _("'b' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2623 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2624 c = float(c)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2625 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2626 raise ValueError( _("'c' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2627 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2628 d = float(d)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2629 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2630 raise ValueError( _("'d' value must be a float number") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2631 # spaces are erased
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2632 sre.sub("[ ]","",formula)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2633 # operators and varibles are replaced
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2634 formula = formula.replace("+", " + ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2635 formula = formula.replace("-", " - ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2636 formula = formula.replace("*", " * ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2637 formula = formula.replace("/", " / ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2638 formula = formula.replace("^", " ** ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2639 formula = formula.replace("(", " ( ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2640 formula = formula.replace(")", " ) ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2641 formula = formula.replace("a", str(a))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2642 formula = formula.replace("b", str(b))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2643 formula = formula.replace("c", str(c))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2644 formula = formula.replace("d", str(d))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2645 formula = formula.replace("p", "3.1415926")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2646 _list_formula = formula.split(" ")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2647 _formula2 = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2648 for oper in _list_formula:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2649 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2650 _float_oper= str(float(oper))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2651 _formula2 = _formula2 + _float_oper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2652 except ValueError:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2653 _formula2 = _formula2 + oper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2654 _g = {"__builtins__":{}}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2655 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2656 return eval(_formula2, _g)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2657 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2658 raise ValueError( _("Invalid formula") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2659
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2660 def getText(self,code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2661 """getText(self,code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2662
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2663 code: the record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2664 Returns the description text of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2665 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2666 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2667 return self.__records[code].text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2668 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2669 raise IndexError( _("Invalid code") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2670
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2671 def setText(self,code,text):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2672 """setText(self,code,text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2673
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2674 code: the parent record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2675 text: the descripion text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2676 Sests the description text of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2677 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2678 if not utils.is_valid_code(code)[0]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2679 raise ValueError( utils.mapping(_("Invalid record: $1"), (str(code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2680 if not code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2681 _record = self.setRecord(code, [], "", "", "", [], [],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2682 "", "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2683 _record.text = text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2684 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2685 _record = self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2686 _record.text = text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2687
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2688 def setRecord(self, code, synonyms, hierarchy, unit, summary, price, date,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2689 type_, subtype):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2690 """setRecord(self, code, synonyms, hierarchy, unit, summary, price,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2691 date, type_, subtype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2692
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2693 code: Code string
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2694 synonyms: List of synonym codes of the record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2695 hierarchy:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2696 0 -> root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2697 1 -> Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2698 2 -> Other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2699 unit: unit of measure record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2700 summary: Short description of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2701 price: List of prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2702 date: List of dates
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2703 "type_" and "subtype":
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2704 0 Without classifying
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2705 EA Auxiliary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2706 EU Unitary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2707 EC Complex element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2708 EF Functional element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2709 OB Construction site
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2710 PA Cost overrun
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2711 PU Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2712 1 Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2713 H Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2714 2 Machinery and auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2715 Q Machinery
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2716 % Auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2717 3 Building materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2718 MC Cement
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2719 MCr Ceramic
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2720 MM Wood
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2721 MS Iron and steel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2722 ME Energy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2723 MCu Copper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2724 MAl Aluminium
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2725 ML Bonding agents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2726 M Others materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2727 Hierarchy type subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2728 0->root -> 0 -> None,OB
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2729 1->[sub]chapter -> 0 -> None,PU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2730 2->Other -> 0 -> None,EA,EU,EC,EF,PA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2731 1 -> None,H
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2732 2 -> None,Q,%
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2733 3 -> None,MC,MCr,MM,MS,ME,MCu,Mal,ML,M
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2734 Adds a record in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2735 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2736 # hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2737 if hierarchy == 0 :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2738 # is the root record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2739 if self.__root is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2740 self.__root = code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2741 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2742 print(_("Only can be one root record") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2743 return
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2744 # TODO: If the root is created in settree. No-estructured measures
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2745 # TODO Rewrite root values
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2746 # retake previous values.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2747 # TODO: test synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2748 _budget = self
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2749 if not code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2750 if code[-1] == "$":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2751 _record = ParametricRecord(_budget.getDecimals(), code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2752 synonyms, hierarchy,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2753 unit, summary, [], type_, subtype,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2754 [], "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2755 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2756 _record = Record(_budget.getDecimals(), code, synonyms,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2757 hierarchy, unit,
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2758 summary, [], type_, subtype,[], "")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2759 self.__records[code] = _record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2760 _prices = [[price[i], date[i]] for i in range(len(price))]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2761 _record.setPrices(_prices, self.getDecimals())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2762 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2763 _record = self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2764 code = _record.code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2765 if len(synonyms) != 0 and synonyms[0] == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2766 synonyms = _record.synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2767 if unit == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2768 unit = _record.unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2769 if summary == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2770 summary = _record.summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2771 #TODO: test empty price list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2772 if len(price) == 0 or price[0] == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2773 _prices = _record.prices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2774 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2775 _prices = [ [price[i], date[i]] for i in range(len(price))]
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2776 if type_ == "":
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2777 type_ = _record.recordType.type
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2778 _record.synonyms = synonyms
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2779 _record.unit = unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2780 _record.summary = summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2781 _record.setPrices(_prices, self.getDecimals())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2782 _record.recordType.hierarchy = hierarchy
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
2783 _record.recordType.type = type_
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2784 _record.recordType.subtype = subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2785 return _record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2786
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2787 def hasRecord(self,code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2788 """hasRecord(self,code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2789
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2790 code: Code record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2791 Return True if the budget have this record code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2792 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2793 if code in self.__records:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2794 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2795 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2796 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2797
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2798 def getRecord(self, code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2799 """getRecord(self, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2800
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2801 code: Code record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2802 Return the Record object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2803 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2804 return self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2805
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2806 def addPriceToRecord(self, price_date, record):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2807 """addPriceToRecord(self, price, record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2808
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2809 Add a price to the price list of the record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2810 price must fulfill:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2811 - must be a list with two items
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2812 - the first item: price must be a float
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2813 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2814 record.addPrice(price_date, self.getDecimals())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2815
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2816 def getStrPriceFromRecord(self, index_price, record, path):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2817 if record.isPercentage():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2818 _percentageMasq = record.percentageMasq()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2819 _parent_code = self.getCode(path[:-1])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2820 _N_record = path[-1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2821 _amount_sum = 0.0
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2822 for N,_code in enumerate(self.getchildren(_parent_code)[:_N_record]):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2823 _child_record = self.getRecord(_code)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2824 if _child_record.hasPercentageMasq(_percentageMasq):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2825 _path = path[:-1] + (N,)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2826 _amount = self.getAmount(_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2827 _amount_sum = _amount_sum + _amount
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2828 _price = _amount_sum
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2829 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2830 _price = record.getPrice(index_price)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2831 _D = abs(self.getDecimals().getD(record.recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2832 _price = ("%." + str(_D) + "f" ) % _price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2833 return _price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2834
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2835 def getCode(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2836 """getCode(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2837
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2838 path: path record in the budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2839 Return the code record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2840 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2841 if isinstance(path, tuple) and len(path)>= 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2842 if path[0] == 0:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2843 _code = self.__root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2844 for i in path[1:]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2845 if isinstance(i, int):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2846 _record = self.__records[_code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2847 _children_list = _record.children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2848 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2849 _child = _children_list[i]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2850 except:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2851 raise ValueError( _("This record does not exits") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2852 _code = _child.code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2853 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2854 raise ValueError( _("Path item must be a integer") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2855 return _code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2856 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2857 raise ValueError( _("This record does not exits") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2858 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2859 raise ValueError( utils.mapping(_("Path must be a not empty "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2860 "tuple: $1"), (str(path),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2861
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2862 def getAmount(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2863 """def getAmount(self,path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2864
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2865 path: record path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2866 Calculate the record amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2867 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2868
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2869 if len(path) == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2870 # root: amount is the root price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2871 _root = self.getRecord(self.getRoot())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2872 _amount = _root.getPrice(self.__title_index)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2873 return _amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2874 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2875 _parent_code = self.getCode(path[:-1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2876 _parent_record = self.getRecord(_parent_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2877 _child_number = path[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2878
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2879 _decomposition = _parent_record.children[_child_number]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2880 _factor = _decomposition.budgetMeasures[0].factor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2881 _yield = _decomposition.budgetMeasures[0].yield_
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2882 _child_code = _decomposition.code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2883 _child_record = self.getRecord(_child_code)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2884 _code = self.getCode(path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2885 _record = self.getRecord(_code)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2886 if _record.isPercentage():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2887 _percentageMasq = _record.percentageMasq()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2888 _N_record = path[-1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2889 _amount_sum = 0.0
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2890 for N,_code in enumerate(self.getchildren(_parent_code)[:_N_record]):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2891 _child_record = self.getRecord(_code)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2892 if _child_record.hasPercentageMasq(_percentageMasq):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2893 _path = path[:-1] + (N,)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2894 _amount = self.getAmount(_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2895 _amount_sum = _amount_sum + _amount
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2896 _price = _amount_sum
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2897 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2898 _price = _child_record.getPrice(self.getActiveTitle())
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2899
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2900 _DR = abs(self.getDecimals().getDR(_parent_record.recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2901 _total_yield = round(_factor * _yield, _DR)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2902 _DI = abs(self.getDecimals().getDI(_parent_record.recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2903 _amount = round(_total_yield * _price, _DI)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2904 return _amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2905
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2906 def getStrAmount(self, path):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2907 """def getStrAmount(self, path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2908
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2909 path: record path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2910 Calculate the string record amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2911 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2912 if len(path) == 1: #root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2913 _root = self.getRecord(self.getRoot())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2914 _amount = self.getStrPriceFromRecord(self.__title_index, _root, path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2915 return _amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2916 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2917 _parent_code = self.getCode(path[:-1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2918 _parent_record = self.getRecord(_parent_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2919 _amount = self.getAmount(path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2920 _DI = abs(self.getDecimals().getDI(_parent_record.recordType))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2921 _amount = ("%." + str(_DI) + "f") % _amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2922 return _amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2923
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2924 def setSheetSection(self,sheet_code,sheet_title):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2925 if not isinstance(sheet_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2926 raise ValueError( _("The sheet code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2927 if not isinstance(sheet_title, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2928 raise ValueError( _("The sheet title must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2929 self.__sheet_sections[sheet_code] = sheet_title
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2930
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2931 def hasSheetSection(self, section):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2932 return section in self.__sheet_sections
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2933
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2934 def getSheetSection(self, section):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2935 return self.__sheet_sections[section]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2936
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2937 def setSheetSections(self,dictionary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2938 if not isinstance(dictionary, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2939 raise ValueError( _("The sheet sections must be a dictionary") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2940 for sheet_code in dictionary.keys():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2941 self.setSheetSection(sheet_code, dictionary[sheet_code])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2942
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2943 def setSheetField(self, field_code, field_title):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2944 if not isinstance(field_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2945 raise ValueError( _("The field code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2946 if not isinstance(field_title, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2947 raise ValueError( _("The field title must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2948 self.__sheet_fields[field_code] = field_title
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2949
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2950 def hasSheetField(self, field):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2951 return field in self.__sheet_fields
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2952
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2953 def getSheetField(self, field):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2954 return self.__sheet_fields[field]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2955
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2956 def setSheetFields(self, field_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2957 if not isinstance(field_dict, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2958 raise ValueError( _("The sheet field must be a dictionary") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2959 for field_code in field_dict.keys():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2960 self.setSheetField( field_code, field_dict[field_code])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2961
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2962 def setSheetParagraph(self, paragraph_code, paragraph_text):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2963 if not isinstance(paragraph_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2964 raise ValueError( _("The paragraph code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2965 if not isinstance(paragraph_text, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2966 raise ValueError( _("The paragraph text must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2967 self.__sheet_paragraphs[paragraph_code] = paragraph_text
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2968
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2969 def hasSheetParagraph(self, paragraph):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2970 return paragraph in self.__sheet_paragraphs
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2971
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2972 def getSheetParagraph(self, paragraph):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2973 return self.__sheet_paragraphs[paragraph]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2974
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2975 def setSheetParagraphs(self, paragraph_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2976 if not isinstance(paragraph_dict, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2977 raise ValueError( _("The paragraph dict must be a dictionary") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2978 for paragraph_code in paragraph_dict.keys():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2979 self.setSheetParagraph( paragraph_code, paragraph_dict[paragraph_code])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2980
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2981 def setSheetRecord(self, record_code, field, section_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2982 if not isinstance(record_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2983 raise ValueError( _("The record_code code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2984 if not isinstance(field, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2985 raise ValueError( _("The field must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2986 if not isinstance(section_dict, dict):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2987 raise ValueError( _("The section dict must be a dictionary") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2988 #-#
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2989 # TODO: Add a empty record?
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2990 if not self.hasRecord(record_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2991 print(utils.mapping(_("Error: The budget do not have this record "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2992 "code and can not be added the sheet text in the field $1. "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2993 "Record Code: $2"), ( str(field), str(record_code))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2994 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2995 #-#
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2996 if not self.hasSheetField(field):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2997 self.setSheetField(field, "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2998 for section, paragraph in section_dict.iteritems():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2999 if not self.hasSheetParagraph(paragraph):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3000 self.setSheetParagraph(paragraph,"")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3001 if not self.hasSheetSection(section):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3002 self.setSheetSection(section, "")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3003 _sheet = self.getRecord(record_code).getSheet()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3004 _sheet.addSection(field, section, paragraph)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3005
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3006 def addFile(self, record_code, filepath, type_, description):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3007 if not isinstance(record_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3008 raise ValueError( _("The record_code code must be a string") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3009 #-# str and unicode
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3010 if not isinstance(filepath, str) and not isinstance(filepath, unicode):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3011 raise ValueError( _("The filename must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3012 #-#
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3013 # TODO: Add a empty record?
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3014 if not self.hasRecord(record_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3015 print(utils.mapping(_("Error: The budget do not have the record "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3016 "code $1 and can not be added the file: $2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3017 (str(record_code), str(filepath))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3018 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3019 #-#
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3020 _record = self.getRecord(record_code)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3021 _record.addFile(filepath, type_, description)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3022
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3023 def setCompany(self, company_code, sumamary, name, offices,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3024 cif, web, email):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3025 if not isinstance(company_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3026 raise ValueError( _("The company code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3027 if not isinstance(sumamary, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3028 raise ValueError( _("The summary must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3029 if not isinstance(name, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3030 raise ValueError( _("The name must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3031 if not isinstance(offices, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3032 raise ValueError( _("The name must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3033 _offices = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3034 for _office in offices:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3035 if not isinstance(_office, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3036 raise ValueError( _("The office must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3037 if not len(_office) == 10:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3038 raise ValueError( _("The office must be a 10 items list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3039 for _item in _office[:7] + _office[9:10]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3040 if not isinstance(_item, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3041 raise ValueError( _("This office item must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3042 "string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3043 for _item in _office[7:8]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3044 if not isinstance(_item, list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3045 raise ValueError( _("This office item must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3046 "list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3047 _offices.append(Office(_office[0],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3048 _office[1],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3049 _office[2],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3050 _office[3],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3051 _office[4],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3052 _office[5],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3053 _office[6],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3054 _office[7],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3055 _office[8],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3056 _office[9]))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3057 if not isinstance(cif, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3058 raise ValueError( _("The name must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3059 if not isinstance(web, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3060 raise ValueError( _("The web must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3061 if not isinstance(email, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3062 raise ValueError( _("The email must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3063
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3064 self.__companys[company_code] = Company(company_code, sumamary, name,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3065 _offices, cif, web, email)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3066 def getCompany(self, company_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3067 return self.__companys[company_code]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3068
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3069 def getCompanyKeys(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3070 return self.__companys.keys()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3071
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3072 def addTecInfo(self, ti_code, text, unit):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3073 if not isinstance(ti_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3074 raise ValueError( _("The tecnical info code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3075 if not isinstance(text, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3076 raise ValueError( _("The tecnical info description must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3077 "string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3078 if not isinstance(unit, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3079 raise ValueError( _("The tecnical info unit must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3080 self.__tec_info[ti_code] = [text, unit]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3081
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3082 def hasTecInfo(self, ti_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3083 return ti_code in self.__tec_info
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3084
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3085 def getTecInfo(self, ti_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3086 return self.__tec_info[ti_code]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3087
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3088 def setTecnicalInformation(self, record_code, ti_dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3089 """setTecnicalInformation(record_code, ti_dict)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3090
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3091 Sets the tecnical information to a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3092 record_code: the record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3093 ti_dict: {ti_code : ti_value}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3094 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3095 # TODO: setTecnicalInformation
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3096 pass
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3097
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3098 def changeCode(self, record_code, new_record_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3099 """changeCode(self, record_code, new_record_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3100
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3101 Change the record code for a new recor code.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3102 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3103 if self.hasRecord(record_code) and not self.hasRecord(new_record_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3104 _record = self.__records[code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3105 _record.code = new_record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3106 _parents = _record.parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3107 for _parent in _parents:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3108 _decomposition_list = self.__records[_parent].children
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3109 for _decomposition in _decomposition_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3110 if _decomposition.code == record_code:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3111 _decomposition.code = new_record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3112 break
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3113 _children = self.getchildren(record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3114 for _child in _children:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3115 _parents_list = self.__records[_child].parents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3116 for index in range(len(_parents_list)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3117 if _parents_list[index] == record_code:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3118 _parents_list[index] = new_record_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3119 break
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3120 self.__records[new_record_code] = _record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3121 del self.__records[record_code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3122 # TODO: attachment files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3123
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3124 def addLabel(self, record_code, label):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3125 """addLabel(self, record_code, label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3126
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3127 Add a label to a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3128 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3129 if not isinstance(label,str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3130 raise ValueError( _("The label must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3131 if self.hasRecord(record_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3132 _record = self.__records[record_code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3133 _record.addLabel(label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3134 if not label in self.__labels:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3135 self.__labels[label] = [record_code]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3136 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3137 _codes = self.__labels[label]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3138 if not record_code in _codes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3139 _codes.append(record_code)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3140
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3141 def setParametricSelectComment(self, record_code, comment):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3142 """setParametricSelectComment(self, record_code, comment)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3143
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3144 Sets Paramtric Record Select Comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3145 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3146 if not isinstance(record_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3147 raise ValueError( _("The record_code code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3148 if not isinstance(comment, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3149 raise ValueError( _("The parametric select comment must be a "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3150 "string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3151 if not self.hasRecord(record_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3152 print(utils.mapping(_("Error: The budget do not have the record "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3153 "code $1 and can not be added the Parametric select comment: "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3154 "$2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3155 (str(record_code), str(comment))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3156 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3157 _record = self.getRecord(record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3158 if not isinstance(_record, ParametricRecord):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3159 print(utils.mapping(_("Error: The Record $1 is not a "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3160 "Parametric Record and can not have Parametric comment"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3161 (str(record_code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3162 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3163 _record.select_comment = comment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3164
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3165 def setParametricSummary(self, record_code, summary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3166 """setParametricSummary(self, record_code, summary)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3167
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3168 Sets parametric record summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3169 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3170 if not isinstance(record_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3171 raise ValueError( _("The record_code code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3172 if not isinstance(summary, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3173 raise ValueError( _("The summary record must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3174 if not self.hasRecord(record_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3175 print(utils.mapping(_("Error: The budget do not have the record "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3176 "code $1 and can not be seted the summary: $2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3177 (str(record_code), str(summary))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3178 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3179 _record = self.getRecord(record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3180 if not isinstance(_record, ParametricRecord):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3181 print(utils.mapping(_("Error: The Record $1 is not a "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3182 "Parametric Record and can not have Parametric summary"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3183 (str(record_code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3184 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3185 self.getRecord(record_code).parametric_summary = summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3186
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3187 def setParametricText(self, record_code, text):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3188 """setParametricText(self, record_code, text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3189
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3190 Sets parametric record text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3191 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3192 if not isinstance(record_code, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3193 raise ValueError( _("The record_code code must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3194 if not isinstance(text, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3195 raise ValueError( _("The text record must be a string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3196 if not self.hasRecord(record_code):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3197 print(utils.mapping(_("Error: The budget do not have the record "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3198 "code $1 and can not be seted the text: $2"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3199 (str(record_code), str(text))) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3200 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3201 _record = self.getRecord(record_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3202 if not isinstance(_record, ParametricRecord):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3203 print(utils.mapping(_("Error: The Record $1 is not a "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3204 "Parametric Record and can not have Parametric text"),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3205 (str(record_code),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3206 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3207 self.getRecord(record_code).parametric_text = text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3208
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3209
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3210 class Office(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3211 """base.Office:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3212
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3213 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3214 Office of a company
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3215 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3216 base.Office(type, subname, address, postal_code, town, province,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3217 country, phone, fax, contact_person)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3218 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3219 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3220 +-- Office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3221 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3222 "officeType" : type of Office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3223 are defined:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3224 "C" Central.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3225 "D" Local Office.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3226 "R" performer.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3227 "subname" : name of Office or Performer
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3228 "address" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3229 "postal_code" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3230 "town" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3231 "province" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3232 "country" :
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3233 "phone" : list of phone numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3234 "fax" : list of fax numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3235 "contact_person" : name of contact person
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3236 "values":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3237 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3238 __getstate__(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3239 __setstate__(self, tuple)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3240 __init__(self, measure, lines, label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3241 {get/set}OfficeType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3242 {get/set}Subname
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3243 {get/set}Address
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3244 {get/set}PostalCode
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3245 {get/set}Town
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3246 {get/set}Province
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3247 {get/set}Country
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3248 {get/set}Phone
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3249 {get/set}Fax
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3250 {get/set}ContactPerson
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3251 getValues
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3252 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3253
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3254 __slots__ = ["_Office__officeType",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3255 "_Office__subname",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3256 "_Office__address",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3257 "_Office__postal_code",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3258 "_Office__town",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3259 "_Office__province",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3260 "_Office__country",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3261 "_Office__phone",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3262 "_Office__fax",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3263 "_Office__contact_person",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3264 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3265
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3266 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3267 return ( self.__officeType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3268 self.__subname,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3269 self.__address,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3270 self.__postal_code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3271 self.__town,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3272 self.__province,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3273 self.__country,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3274 self.__phone,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3275 self.__fax,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3276 self.__contact_person)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3277
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3278 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3279 self.__officeType = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3280 self.__subname = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3281 self.__address = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3282 self.__postal_code = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3283 self.__town = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3284 self.__province = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3285 self.__country = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3286 self.__phone = tuple[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3287 self.__fax = tuple[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3288 self.__contact_person = tuple[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3289
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3290 def __init__(self, type_, subname, address, postal_code, town, province,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3291 country, phone, fax, contact_person):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3292 self.officeType = type_
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3293 self.subname = subname
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3294 self.address = address
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3295 self.postal_code = postal_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3296 self.town = town
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3297 self.province = province
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3298 self.country = country
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3299 self.phone = phone
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3300 self.fax = fax
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3301 self.contact_person = contact_person
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3302
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3303 def getOfficeType(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3304 return self.__officeType
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3305
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3306 def setOfficeType(self, type_):
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3307 self.__officeType = type_
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3308
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3309 def getSubname(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3310 return self.__subname
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3311
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3312 def setSubname(self, subname):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3313 self.__subname = subname
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3314
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3315 def getAddress(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3316 return self.__address
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3317
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3318 def setAddress(self, address):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3319 self.__address = address
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3320
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3321 def getPostalCode(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3322 return self.__postal_code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3323
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3324 def setPostalCode(self, postal_code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3325 self.__postal_code = postal_code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3326
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3327 def getTown(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3328 return self.__town
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3329
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3330 def setTown(self, town):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3331 self.__town = town
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3332
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3333 def getProvince(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3334 return self.__province
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3335
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3336 def setProvince(self, province):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3337 self.__province = province
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3338
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3339 def getCountry(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3340 return self.__country
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3341
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3342 def setCountry(self, country):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3343 self.__country = country
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3344
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3345 def getPhone(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3346 return self.__phone
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3347
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3348 def setPhone(self, phone):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3349 self.__phone = phone
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3350
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3351 def getFax(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3352 return self.__fax
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3353
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3354 def setFax(self, fax):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3355 self.__fax = fax
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3356
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3357 def getContactPerson(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3358 return self.__contact_person
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3359
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3360 def setContactPerson(self, contact_person):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3361 self.__contact_person = contact_person
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3362
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3363 def getValues(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3364 return {"officeType": self.officeType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3365 "subname": self.subname,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3366 "address": self.address,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3367 "postal code": self.postal_code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3368 "town": self.town,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3369 "province": self.province,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3370 "country": self.country,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3371 "phone": self.phone,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3372 "fax": self.fax,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3373 "contact person": self.contact_person,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3374 }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3375
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3376 officeType = property(getOfficeType, setOfficeType, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3377 """Type of office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3378 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3379 subname = property(getSubname, setSubname, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3380 """Name of office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3381 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3382 address = property(getAddress, setAddress, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3383 """Adress
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3384 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3385 postal_code = property(getPostalCode, setPostalCode, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3386 """Postal code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3387 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3388 town = property(getTown, setTown, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3389 """Town
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3390 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3391 province = property(getProvince, setProvince, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3392 """Province
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3393 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3394 country = property(getCountry, setCountry, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3395 """Country
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3396 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3397 phone = property(getPhone, setPhone, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3398 """Phone numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3399 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3400 fax = property(getFax, setFax, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3401 """Fax numbers
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3402 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3403 contact_person = property(getContactPerson, setContactPerson, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3404 """Contact Person
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3405 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3406 values = property(getValues, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3407 """Dictionary with comapany values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3408 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3409
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3410
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3411 class Company(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3412 """base.Company:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3413
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3414 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3415 Company object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3416 __slots__ attribute, __getstate__ and __setstate__ method are defined
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3417 to use less ram memory.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3418 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3419 base.Company(code, summary, name, offices, cif, web, email)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3420 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3421 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3422 +-- Company
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3423 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3424 "code": code to indentifie the company in the buget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3425 "summary": short name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3426 "name": long name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3427 "offices": List of Offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3428 "cif": CIF
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3429 "web": web page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3430 "email": email
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3431 "values":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3432 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3433 __getstate__(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3434 __setstate__(self, tuple)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3435 __init__(self, measure, lines, label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3436 {get/set}Code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3437 {get/set}Summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3438 {get/set}Name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3439 {get/set}Offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3440 {get/set}Cif
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3441 {get/set}Web
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3442 {get/set}Email
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3443 getValues
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3444 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3445
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3446 __slots__ = ["_Company__code",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3447 "_Company__summary",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3448 "_Company__name",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3449 "_Company__offices",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3450 "_Company__cif",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3451 "_Company__web",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3452 "_Company__email",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3453 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3454
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3455 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3456 return ( self.__code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3457 self.__summary,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3458 self.__name,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3459 self.__offices,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3460 self.__cif,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3461 self.__web,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3462 self.__email)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3463
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3464 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3465 self.__code = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3466 self.__summary = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3467 self.__name = tuple[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3468 self.__offices = tuple[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3469 self.__cif = tuple[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3470 self.__web = tuple[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3471 self.__email = tuple[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3472
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3473 def __init__(self, code, summary, name, offices, cif, web, email):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3474 self.code = code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3475 self.summary = summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3476 self.name = name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3477 self.offices = offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3478 self.cif = cif
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3479 self.web = web
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3480 self.email = email
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3481
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3482 def getCode(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3483 return self.__code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3484
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3485 def setCode(self, code):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3486 self.__code = code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3487
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3488 def getSummary(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3489 return self.__summary
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3490
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3491 def setSummary(self, summary):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3492 self.__summary = summary
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3493
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3494 def getName(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3495 return self.__name
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3496
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3497 def setName(self, name):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3498 self.__name = name
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3499
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3500 def getOffices(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3501 return self.__offices
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3502
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3503 def setOffices(self, offices):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3504 self.__offices = offices
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3505
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3506 def getCif(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3507 return self.__cif
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3508
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3509 def setCif(self, cif):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3510 self.__cif = cif
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3511
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3512 def getWeb(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3513 return self.__web
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3514
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3515 def setWeb(self, web):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3516 self.__web = web
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3517
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3518 def getEmail(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3519 return self.__email
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3520
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3521 def setEmail(self, email):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3522 self.__email = email
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3523
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3524 def getValues(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3525 return {"code": self.code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3526 "summary": self.summary,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3527 "name": self.name,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3528 "cif": self.cif,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3529 "web": self.web,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3530 "email": self.email}
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3531
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3532 code = property(getCode, setCode, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3533 """Company code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3534 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3535 summary = property(getSummary, setSummary, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3536 """Company summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3537 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3538 name = property(getName, setName, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3539 """Company name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3540 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3541 offices = property(getOffices, setOffices, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3542 """List of Offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3543 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3544 cif = property(getCif, setCif, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3545 """CIF
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3546 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3547 web = property(getWeb, setWeb, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3548 """Web page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3549 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3550 email = property(getEmail, setEmail, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3551 """Email
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3552 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3553 values = property(getValues, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3554 """Dictionary with comapany values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3555 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3556
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3557
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3558 class File(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3559 """base.Company:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3560
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3561 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3562 File object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3563 Constructor:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3564 base.File(name, type_, description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3565 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3566 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3567 +-- File
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3568 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3569 "name": name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3570 "fileType": type of file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3571 "description": description file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3572 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3573 __getstate__(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3574 __setstate__(self, tuple)
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3575 __init__(self, path,type_, description)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3576 {get/set}Name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3577 {get/set}FileType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3578 {get/set}Description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3579 getValues
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3580 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3581
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3582 __slots__ = ["_File__name",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3583 "_File__fileType",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3584 "_File__description",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3585 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3586
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3587 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3588 return (self.__name,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3589 self.__description,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3590 self.__fileType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3591 )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3592
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3593 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3594 self.__name = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3595 self.__fileType = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3596 self.__description = tuple[2]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3597
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3598 def __init__(self, name, type_, description):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3599 self.name = name
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3600 self.fileType = type_
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3601 self.description = description
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3602
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3603 def getName(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3604 return self.__name
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3605
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3606 def setName(self, name):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3607 self.__name = name
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3608
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3609 def getFileType(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3610 return self.__fileType
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3611
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3612 def setFileType(self, type_):
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3613 self.__fileType = type_
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3614
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3615 def getDescription(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3616 return self.__description
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3617
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3618 def setDescription(self, description):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3619 self.__description = description
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3620
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3621 def getValues(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3622 return {"name": self.name,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3623 "fileType": self.fileType,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3624 "description": self.description,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3625 }
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3626
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3627 name = property(getName, setName, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3628 """File name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3629 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3630 fileType = property(getFileType, setFileType, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3631 """FileType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3632 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3633 description = property(getDescription, setDescription, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3634 """File description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3635 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3636 values = property(getValues, None, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3637 """Dictionary with file values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3638 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3639
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3640
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3641 class RecordType(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3642 """base.RecordType:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3643
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3644 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3645 Record Type object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3646 "hierarchy":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3647 -1 -> temporarily unfixed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3648 0 -> root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3649 1 -> Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3650 2 -> Other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3651 "type" and "subtype":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3652 0 Without classifying
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3653 EA Auxiliary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3654 EU Unitary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3655 EC Complex element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3656 EF Functional element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3657 OB Construction site
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3658 PA Cost overrun
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3659 PU Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3660 1 Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3661 H Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3662 2 Machinery and auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3663 Q Machinery
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3664 % Auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3665 3 Building materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3666 MC Cement
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3667 MCr Ceramic
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3668 MM Wood
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3669 MS Iron and steel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3670 ME Energy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3671 MCu Copper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3672 MAl Aluminium
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3673 ML Bonding agents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3674 M Others materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3675 Hierarchy type subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3676 0->root -> 0 -> None,OB
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3677 1->[sub]chapter -> 0 -> None,PU
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3678 2->Other -> 0 -> None,EA,EU,EC,EF,PA
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3679 1 -> None,H
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3680 2 -> None,Q,%
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3681 3 -> None,MC,MCr,MM,MS,ME,MCu,Mal,ML,M
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3682 Constructor:
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3683 base.File(hierarchy,type_,subtype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3684 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3685 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3686 +-- RecordType
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3687 Atributes:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3688 "hierarchy": hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3689 "type": type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3690 "subtype": subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3691 Methods:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3692 __getstate__(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3693 __setstate__(self, tuple)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3694 __init__(self, hierarchy, type, subtype)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3695 {get/set}Hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3696 {get/set}Type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3697 {get/set}Subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3698 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3699
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3700 __slots__ = ["_RecordType__hierarchy",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3701 "_RecordType__type",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3702 "_RecordType__subtype",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3703 ]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3704
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3705 def __getstate__ (self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3706 return (self.__hierarchy,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3707 self.__type,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3708 self.__subtype,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3709 )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3710
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3711 def __setstate__(self,tuple):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3712 self.__hierarchy = tuple[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3713 self.__type = tuple[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3714 self.__subtype = tuple[2]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3715
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3716 def __init__(self, hierarchy, type_, subtype):
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3717 self.hierarchy = hierarchy
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3718 self.type = type_
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3719 self.subtype = subtype
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3720
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3721 def getHierarchy(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3722 return self.__hierarchy
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3723
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3724 def setHierarchy(self, hierarchy):
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3725 if not hierarchy in [-1, 0 , 1 ,2, ""]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3726 raise ValueError( utils.mapping(_("Invalid Hierarchy ($1) "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3727 "The hierarchy must be -1, 0, 1, 2"), (str(hierarchy),)) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3728 elif hierarchy == "":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3729 print("Hierarchy temporarily set to an empty string")
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3730 #TODO Check empty Hierarchy in Generic.fiebdc.Read._testBudget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3731 self.__hierarchy = hierarchy
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3732
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3733 def getType(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3734 return self.__type
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3735
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3736 def setType(self, type_):
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3737 if not type_ in ["", 0, 1, 2, 3] :
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3738 raise ValueError( utils.mapping(_("Invalid type ($1),"\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3739 "the type must be (empty string,0,1,2,3)"),(str(type_)),) )
17
a7b9f7e7dfa4 Improvements importing FIEBDC files
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3740 self.__type = type_
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3741
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3742 def getSubtype(self):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3743 return self.__subtype
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3744
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3745 def setSubtype(self, subtype):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3746 if not subtype in ["", "OB", "PU", "EA", "EU", "EC", "EF", "PA", "H",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3747 "Q", "%", "MC", "MCr", "MM", "MS", "ME", "MCu",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3748 "Mal","ML","M"]:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3749 raise ValueError( utils.mapping(_("Invalid subtype ($1), The "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3750 "subtype must one in (empty string, EA, "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3751 "EU, EC, EF, OB, PA, PU, H, Q, %, MC, MCr, "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3752 "MM, MS, ME, MCu, MAl, ML, M)"), (str(subtype),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3753 self.__subtype = subtype
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3754
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3755 hierarchy = property(getHierarchy, setHierarchy, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3756 """Record Hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3757 -1 -> temporarily unfixed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3758 0 -> root
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3759 1 -> Chapter/Subchapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3760 2 -> Other
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3761 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3762 type = property(getType, setType, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3763 """Record Type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3764 0 Without classifying
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3765 1 Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3766 2 Machinery and auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3767 3 Building materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3768 """)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3769 subtype = property(getSubtype, setSubtype, None,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3770 """Record Subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3771 None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3772 EA Auxiliary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3773 EU Unitary element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3774 EC Complex element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3775 EF Functional element
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3776 OB Construction site
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3777 PA Cost overrun
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3778 PU Unitary budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3779 H Labourforce
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3780 Q Machinery
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3781 % Auxiliary equipment
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3782 MC Cement
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3783 MCr Ceramic
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3784 MM Wood
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3785 MS Iron and steel
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3786 ME Energy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3787 MCu Copper
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3788 MAl Aluminium
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3789 ML Bonding agents
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3790 M Others materials
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3791 """)