Skip to content

Commit 7e29088

Browse files
authored
Merge pull request #12 from EnverMT/master
Resolving of correct parsing of locale number format
2 parents d3e691c + c5f3635 commit 7e29088

File tree

7 files changed

+59
-55
lines changed

7 files changed

+59
-55
lines changed

xerparser/model/classes/activitycode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
from xerparser.model.acttypes import ActTypes
21+
import locale
2122

2223
class ActivityCode:
2324
obj_list = []
@@ -36,7 +37,7 @@ def __init__(self, params):
3637
# Sequence number for sorting.
3738
self.seq_num = int(params.get('seq_num').strip()) if params.get('seq_num') else None
3839
self.color = params.get('color').strip() if params.get('color') else None
39-
self.total_assignments = int(float(params.get('total_assignments').strip())) if params.get('total_assignments') else None
40+
self.total_assignments = int(locale.atof(params.get('total_assignments').strip())) if params.get('total_assignments') else None
4041
ActivityCode.obj_list.append(self)
4142

4243
def get_id(self):

xerparser/model/classes/acttype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with PyP6XER. If not, see <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html>.
1818

19-
19+
import locale
2020
class ActType:
2121
obj_list =[]
2222

2323
def __init__(self, params):
2424
# Unique ID generated by the system.
2525
self.actv_code_type_id = int(params.get('actv_code_type_id').strip()) if params.get('actv_code_type_id') else None
2626
# The maximum number of characters allowed for values of this Activity Code.
27-
self.actv_short_len = float(params.get('actv_short_len').strip()) if params.get('actv_short_len') else None
27+
self.actv_short_len = locale.atof(params.get('actv_short_len').strip()) if params.get('actv_short_len') else None
2828
# Sequence number for sorting.
2929
self.seq_num = int(params.get('seq_num').strip()) if params.get('seq_num') else None
3030
# Each Activity Code has a list of possible values, any of which can be assigned to an activity. Activity

xerparser/model/classes/calendar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from xerparser.model.classes.calendar_data import CalendarData
2121

22-
22+
import locale
2323
class Calendar:
2424
obj_list = []
2525

@@ -41,16 +41,16 @@ def __init__(self, params):
4141
self.clndr_type = params.get('clndr_type').strip() if params.get('clndr_type') else None
4242
# The number of work hours per day. This conversion factor is used for displaying time units and durations in
4343
# the user's selected display formats.
44-
self.day_hr_cnt = float(params.get('day_hr_cnt')) if params.get('day_hr_cnt') else None
44+
self.day_hr_cnt = locale.atof(params.get('day_hr_cnt')) if params.get('day_hr_cnt') else None
4545
# The number of work hours per week. This conversion factor is used for displaying time units and durations
4646
# in the user's selected display formats.
47-
self.week_hr_cnt = float(params.get('week_hr_cnt')) if params.get('week_hr_cnt') else None
47+
self.week_hr_cnt = locale.atof(params.get('week_hr_cnt')) if params.get('week_hr_cnt') else None
4848
# The number of work hours per month. This conversion factor is used for displaying time units and durations
4949
# in the user's selected display formats.
50-
self.month_hr_cnt = float(params.get('month_hr_cnt')) if params.get('month_hr_cnt') else None
50+
self.month_hr_cnt = locale.atof(params.get('month_hr_cnt')) if params.get('month_hr_cnt') else None
5151
# The number of work hours per year. This conversion factor is used for displaying time units and durations
5252
# in the user's selected display formats.
53-
self.year_hr_cnt = float(params.get('year_hr_cnt')) if params.get('year_hr_cnt') else None
53+
self.year_hr_cnt = locale.atof(params.get('year_hr_cnt')) if params.get('year_hr_cnt') else None
5454
#
5555
self.rsrc_private = params.get('rsrc_private').strip() if params.get('rsrc_private') else None
5656

xerparser/model/classes/rolerate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with PyP6XER. If not, see <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html>.
1818

19+
import locale
1920

2021
class RoleRate:
2122
obj_list = []
2223

2324
def __init__(self, params):
2425
self.role_rate_id = int(params.get('role_rate_id').strip()) if params.get('role_rate_id') else None
2526
self.role_id = int(params.get('role_id').strip()) if params.get('role_id') else None
26-
self.cost_per_qty = float(params.get('cost_per_qty').strip()) if params.get('cost_per_qty') else None
27-
self.cost_per_qty2 = float(params.get('cost_per_qty2').strip())if params.get('cost_per_qty2') else None
28-
self.cost_per_qty3 = float(params.get('cost_per_qty3').strip()) if params.get('cost_per_qty3') else None
29-
self.cost_per_qty4 = float(params.get('cost_per_qty4').strip()) if params.get('cost_per_qty4') else None
30-
self.cost_per_qty5 = float(params.get('cost_per_qty5').strip()) if params.get('cost_per_qty5') else None
27+
self.cost_per_qty = locale.atof(params.get('cost_per_qty').strip()) if params.get('cost_per_qty') else None
28+
self.cost_per_qty2 = locale.atof(params.get('cost_per_qty2').strip())if params.get('cost_per_qty2') else None
29+
self.cost_per_qty3 = locale.atof(params.get('cost_per_qty3').strip()) if params.get('cost_per_qty3') else None
30+
self.cost_per_qty4 = locale.atof(params.get('cost_per_qty4').strip()) if params.get('cost_per_qty4') else None
31+
self.cost_per_qty5 = locale.atof(params.get('cost_per_qty5').strip()) if params.get('cost_per_qty5') else None
3132

3233
RoleRate.obj_list.append(self)
3334

xerparser/model/classes/rsrccurv.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@
1515
#
1616
# You should have received a copy of the GNU General Public License
1717
# along with PyP6XER. If not, see <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html>.
18-
18+
import locale
1919

2020
class ResourceCurve:
2121
obj_list = []
2222

23-
def __init__(self, params):
23+
def __init__(self, params):
2424
self.curv_id = int(params.get('curv_id')) if params.get('curv_id') else None
2525
self.curv_name = params.get('curv_name').strip() if params.get('curv_id') else None
2626
self.default_flag = params.get('default_flag') if params.get('default_flag') else None
27-
self.pct_usage_0 = float(params.get('pct_usage_0')) if params.get('pct_usage_0') else None
28-
self.pct_usage_1 = float(params.get('pct_usage_1')) if params.get('pct_usage_1') else None
29-
self.pct_usage_2 = float(params.get('pct_usage_2')) if params.get('pct_usage_2') else None
30-
self.pct_usage_3 = float(params.get('pct_usage_3')) if params.get('pct_usage_3') else None
31-
self.pct_usage_4 = float(params.get('pct_usage_4')) if params.get('pct_usage_4') else None
32-
self.pct_usage_5 = float(params.get('pct_usage_5')) if params.get('pct_usage_5') else None
33-
self.pct_usage_6 = float(params.get('pct_usage_6')) if params.get('pct_usage_6') else None
34-
self.pct_usage_7 = float(params.get('pct_usage_7')) if params.get('pct_usage_7') else None
35-
self.pct_usage_8 = float(params.get('pct_usage_8')) if params.get('pct_usage_8') else None
36-
self.pct_usage_9 = float(params.get('pct_usage_9')) if params.get('pct_usage_9') else None
37-
self.pct_usage_10 = float(params.get('pct_usage_10')) if params.get('pct_usage_10') else None
38-
self.pct_usage_11 = float(params.get('pct_usage_11')) if params.get('pct_usage_11') else None
39-
self.pct_usage_12 = float(params.get('pct_usage_12')) if params.get('pct_usage_12') else None
40-
self.pct_usage_13 = float(params.get('pct_usage_13')) if params.get('pct_usage_13') else None
41-
self.pct_usage_14 = float(params.get('pct_usage_14')) if params.get('pct_usage_14') else None
42-
self.pct_usage_15 = float(params.get('pct_usage_15')) if params.get('pct_usage_15') else None
43-
self.pct_usage_16 = float(params.get('pct_usage_16')) if params.get('pct_usage_16') else None
44-
self.pct_usage_17 = float(params.get('pct_usage_17')) if params.get('pct_usage_17') else None
45-
self.pct_usage_18 = float(params.get('pct_usage_18')) if params.get('pct_usage_18') else None
46-
self.pct_usage_19 = float(params.get('pct_usage_19')) if params.get('pct_usage_19') else None
47-
self.pct_usage_20 = float(params.get('pct_usage_20')) if params.get('pct_usage_20') else None
27+
self.pct_usage_0 = locale.atof(params.get('pct_usage_0')) if params.get('pct_usage_0') else None
28+
self.pct_usage_1 = locale.atof(params.get('pct_usage_1')) if params.get('pct_usage_1') else None
29+
self.pct_usage_2 = locale.atof(params.get('pct_usage_2')) if params.get('pct_usage_2') else None
30+
self.pct_usage_3 = locale.atof(params.get('pct_usage_3')) if params.get('pct_usage_3') else None
31+
self.pct_usage_4 = locale.atof(params.get('pct_usage_4')) if params.get('pct_usage_4') else None
32+
self.pct_usage_5 = locale.atof(params.get('pct_usage_5')) if params.get('pct_usage_5') else None
33+
self.pct_usage_6 = locale.atof(params.get('pct_usage_6')) if params.get('pct_usage_6') else None
34+
self.pct_usage_7 = locale.atof(params.get('pct_usage_7')) if params.get('pct_usage_7') else None
35+
self.pct_usage_8 = locale.atof(params.get('pct_usage_8')) if params.get('pct_usage_8') else None
36+
self.pct_usage_9 = locale.atof(params.get('pct_usage_9')) if params.get('pct_usage_9') else None
37+
self.pct_usage_10 = locale.atof(params.get('pct_usage_10')) if params.get('pct_usage_10') else None
38+
self.pct_usage_11 = locale.atof(params.get('pct_usage_11')) if params.get('pct_usage_11') else None
39+
self.pct_usage_12 = locale.atof(params.get('pct_usage_12')) if params.get('pct_usage_12') else None
40+
self.pct_usage_13 = locale.atof(params.get('pct_usage_13')) if params.get('pct_usage_13') else None
41+
self.pct_usage_14 = locale.atof(params.get('pct_usage_14')) if params.get('pct_usage_14') else None
42+
self.pct_usage_15 = locale.atof(params.get('pct_usage_15')) if params.get('pct_usage_15') else None
43+
self.pct_usage_16 = locale.atof(params.get('pct_usage_16')) if params.get('pct_usage_16') else None
44+
self.pct_usage_17 = locale.atof(params.get('pct_usage_17')) if params.get('pct_usage_17') else None
45+
self.pct_usage_18 = locale.atof(params.get('pct_usage_18')) if params.get('pct_usage_18') else None
46+
self.pct_usage_19 = locale.atof(params.get('pct_usage_19')) if params.get('pct_usage_19') else None
47+
self.pct_usage_20 = locale.atof(params.get('pct_usage_20')) if params.get('pct_usage_20') else None
4848

4949
ResourceCurve.obj_list.append(self)
5050

xerparser/model/classes/task.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from xerparser.model.classes.calendar import Calendar
2626
from xerparser.model.activitiyresources import ActivityResources
2727
from xerparser.model.taskprocs import TaskProcs
28+
import locale
2829

2930
class Task:
3031
obj_list = []
@@ -40,7 +41,7 @@ def __init__(self, params, data):
4041
self.clndr_id = int(params.get('clndr_id')) if params.get('clndr_id') else None
4142
# The physical percent complete can either be user entered or calculated from the activity's weighted steps.
4243
# There is a project setting specifying this.
43-
self.phys_complete_pct = float(params.get('phys_complete_pct')) if 'phys_complete_pct' in params.keys() else None
44+
self.phys_complete_pct = locale.atof(params.get('phys_complete_pct')) if 'phys_complete_pct' in params.keys() else None
4445
# Indicates that the primary resource has sent feedback notes about this activity which have not been
4546
# reviewed yet.
4647
self.rev_fdbk_flag = params.get('rev_fdbk_flag') if params.get('rev_fdbk_flag') else None
@@ -49,7 +50,7 @@ def __init__(self, params, data):
4950
# the same WBS. Top-down estimation distributes estimated units in a top-down manner to activities using the
5051
# WBS hierarchy.
5152

52-
self.est_wt = float(params.get('est_wt').strip()) if 'est_wt' in params.keys() else None
53+
self.est_wt = locale.atof(params.get('est_wt').strip()) if 'est_wt' in params.keys() else None
5354
# Indicates that the planned labor and nonlabor units for the activity will not be modified by top-down
5455
# estimation.
5556
self.lock_plan_flag = params.get('lock_plan_flag') if params.get('lock_plan_flag') else None
@@ -94,37 +95,37 @@ def __init__(self, params, data):
9495
# The amount of time the wbs can be delayed before delaying the project finish date. Total int can be
9596
# computed as Late Start - Early Start or as Late Finish - Early Finish; this option can be set when running
9697
# the project scheduler.
97-
self.total_float_hr_cnt = float(params.get('total_float_hr_cnt').strip()) if params.get('total_float_hr_cnt') and \
98+
self.total_float_hr_cnt = locale.atof(params.get('total_float_hr_cnt').strip()) if params.get('total_float_hr_cnt') and \
9899
params.get('total_float_hr_cnt') != '' else None
99100
# The amount of time the activity can be delayed before delaying the start date of any successor activity.
100-
self.free_float_hr_cnt = float(params.get('free_float_hr_cnt')) if params.get('free_float_hr_cnt') else None
101+
self.free_float_hr_cnt = locale.atof(params.get('free_float_hr_cnt')) if params.get('free_float_hr_cnt') else None
101102
# Remaining duration is the total working time from the activity remaining start date to the remaining finish
102103
# date. The remaining working time is computed using the activity's calendar. Before the activity is
103104
# started, the remaining duration is the same as the Original Duration. After the activity is completed the
104105
# remaining duration is zero.
105-
self.remain_drtn_hr_cnt = float(params.get('remain_drtn_hr_cnt').strip()) if params.get('remain_drtn_hr_cnt') else 0
106+
self.remain_drtn_hr_cnt = locale.atof(params.get('remain_drtn_hr_cnt').strip()) if params.get('remain_drtn_hr_cnt') else 0
106107
# The total actual labor units for all child activities
107-
self.act_work_qty = float(params.get('act_work_qty')) if params.get('act_work_qty') else None
108+
self.act_work_qty = locale.atof(params.get('act_work_qty')) if params.get('act_work_qty') else None
108109
# The remaining units for all labor resources assigned to the activity. The remaining units reflects the work
109110
# remaining to be done for the activity. Before the activity is started, the remaining units are the same as
110111
# the planned units. After the activity is completed, the remaining units are zero.
111-
self.remain_work_qty = float(params.get('remain_work_qty')) if params.get('remain_work_qty') else None
112+
self.remain_work_qty = locale.atof(params.get('remain_work_qty')) if params.get('remain_work_qty') else None
112113
# The planned units for all labor resources assigned to the activity.
113-
self.target_work_qty = float(params.get('target_work_qty')) if params.get('target_work_qty') else None
114+
self.target_work_qty = locale.atof(params.get('target_work_qty')) if params.get('target_work_qty') else None
114115
# Original Duration is the planned working time for the resource assignment on the activity,
115116
# from the resource's planned start date to the planned finish date. The planned working time is computed
116117
# using the calendar determined by the Activity Type. Resource Dependent activities use the resource's
117118
# calendar; other activity types use the activity's calendar. This is the duration that Timesheets users
118119
# follow and the schedule variance is measured against.
119-
self.target_drtn_hr_cnt = float(params.get('target_drtn_hr_cnt').strip()) if params.get('target_drtn_hr_cnt') else None
120+
self.target_drtn_hr_cnt = locale.atof(params.get('target_drtn_hr_cnt').strip()) if params.get('target_drtn_hr_cnt') else None
120121
# The planned units for all nonlabor resources assigned to the activity.
121-
self.target_equip_qty = float(params.get('target_equip_qty')) if params.get('target_equip_qty') else None
122+
self.target_equip_qty = locale.atof(params.get('target_equip_qty')) if params.get('target_equip_qty') else None
122123
# The actual units for all nonlabor resources assigned to the activities under the WBS.
123-
self.act_equip_qty = float(params.get('act_equip_qty')) if params.get('act_equip_qty') else None
124+
self.act_equip_qty = locale.atof(params.get('act_equip_qty')) if params.get('act_equip_qty') else None
124125
# The remaining units for all nonlabor resources assigned to the activity. The remaining units reflects the
125126
# work remaining to be done for the activity. Before the activity is started, the remaining units are the
126127
# same as the planned units. After the activity is completed, the remaining units are zero.
127-
self.remain_equip_qty = float(params.get('remain_equip_qty')) if params.get('remain_equip_qty') else None
128+
self.remain_equip_qty = locale.atof(params.get('remain_equip_qty')) if params.get('remain_equip_qty') else None
128129
# The constraint date for the activity, if the activity has a constraint. The activity's constraint type
129130
# determines whether this is a start date or finish date. Activity constraints are used by the project
130131
# scheduler.
@@ -192,9 +193,9 @@ def __init__(self, params, data):
192193
self.cstr_type2 = params.get('cstr_type2').strip() if params.get('cstr_type2') else None
193194
self.driving_path_flag = params.get('driving_path_flag') if params.get('driving_path_flag') else None
194195
# The actual this period units for all labor resources assigned to the activity.
195-
self.act_this_per_work_qty = float(params.get('act_this_per_work_qty')) if params.get('act_this_per_work_qty') else None
196+
self.act_this_per_work_qty = locale.atof(params.get('act_this_per_work_qty')) if params.get('act_this_per_work_qty') else None
196197
# The actual this period units for all nonlabor resources assigned to the activity.
197-
self.act_this_per_equip_qty = float(params.get('act_this_per_equip_qty')) if params.get('act_this_per_equip_qty') else None
198+
self.act_this_per_equip_qty = locale.atof(params.get('act_this_per_equip_qty')) if params.get('act_this_per_equip_qty') else None
198199
# The External Early Start date is the date the external relationship was scheduled to finish. This date may
199200
# be used to calculate the start date of the current activity during scheduling. This field is populated on
200201
# import when an external relationship is lost.

0 commit comments

Comments
 (0)