Skip to content

Commit

Permalink
Fix crash if only one direction
Browse files Browse the repository at this point in the history
  • Loading branch information
marioba committed Apr 7, 2019
1 parent 1a213aa commit aec201a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions comptages/report/report_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def _set_data_count(self, workbook, count_data, start_day, end_day):
if type(count_data.attributes['remarks']) == str else '')

ws['B13'] = count_data.attributes['dir1']
ws['B14'] = count_data.attributes['dir2']

if 'dir2' in count_data.attributes:
ws['B14'] = count_data.attributes['dir2']

def _set_data_day(self, workbook, count_data, start_day, end_day):
ws = workbook['Data_day']
Expand Down Expand Up @@ -153,10 +155,11 @@ def _set_data_speed(self, workbook, count_data, start_day, end_day):
dir1 = count_data.speed_cumulus(0, days=days_idx)
dir2 = count_data.speed_cumulus(1, days=days_idx)

if not count_data.attributes['aggregate']:
for i, hour in enumerate(dir1):
for j, speed in enumerate(hour):
ws['{}{}'.format(speed_cols[j], i+dir1_start_cell)] = speed
for i, hour in enumerate(dir1):
for j, speed in enumerate(hour):
ws['{}{}'.format(speed_cols[j], i+dir1_start_cell)] = speed

if not count_data.attributes['aggregate']:
# Average and characteristic speed
char_speed = self.layers.get_characteristic_speeds(
self.count_id, i, 1)
Expand All @@ -165,9 +168,11 @@ def _set_data_speed(self, workbook, count_data, start_day, end_day):
ws['R{}'.format(i+dir1_start_cell)] = char_speed[2]
ws['S{}'.format(i+dir1_start_cell)] = char_speed[3]

for i, hour in enumerate(dir2):
for j, speed in enumerate(hour):
ws['{}{}'.format(speed_cols[j], i+dir2_start_cell)] = speed
for i, hour in enumerate(dir2):
for j, speed in enumerate(hour):
ws['{}{}'.format(speed_cols[j], i+dir2_start_cell)] = speed

if not count_data.attributes['aggregate']:
# Average and characteristic speed
char_speed = self.layers.get_characteristic_speeds(
self.count_id, i, 2)
Expand Down
Binary file modified comptages/report/template.xlsx
Binary file not shown.

0 comments on commit aec201a

Please sign in to comment.