Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @classmethod
- def load(cls, sheet):
- '''Return configuration in dict-list like:'''
- config_list = []
- for row in range(3, sheet.max_row+1):
- row_str = str(row)
- for col in range(ord('A'), ord('I')):
- col_str = chr(col)
- if(sheet[col_str + row_str].value):
- # if (sheet['A'+row_str].value and
- # sheet['B'+row_str].value and
- # sheet['C'+row_str].value and
- # sheet['D'+row_str].value and
- # sheet['E'+row_str].value and
- # sheet['F'+row_str].value and
- # sheet['G'+row_str].value):
- polling_config = {
- 'endPoint': {
- 'host': sheet["A"+row_str].value,
- 'port': sheet["B"+row_str].value
- },
- 'pollingPeriodMS': sheet["C"+row_str].value,
- 'requestTimeoutMS':sheet["D"+row_str].value,
- 'equipments': [{
- 'id': sheet["E"+row_str].value,
- 'templateId': sheet["F"+row_str].value,
- 'equipmentId': sheet["G"+row_str].value,
- 'equipmentName':sheet["H"+row_str].value
- }]
- }
- row += 1
- for equ_row in range(row, sheet.max_row+1):
- equ_row_str = str(equ_row)
- if (sheet['A'+equ_row_str].value or
- sheet['B'+equ_row_str].value or
- sheet['C'+equ_row_str].value or
- sheet['D'+equ_row_str].value):
- break
- equipment = {
- 'id': sheet["E"+equ_row_str].value,
- 'templateId':sheet["F"+equ_row_str].value,
- 'equipmentId':sheet["G"+equ_row_str].value,
- 'equipmentName':sheet["H"+equ_row_str].value
- }
- polling_config["equipments"].append(equipment)
- row += 1
- config_list.append(polling_config)
- else:
- # TODO log warning here
- continue
- return config_list
- ```
- like
- polling_config = {
- 'endPoint': {
- 'host': sheet["A"+row_str].value,
- 'port': sheet["B"+row_str].value
- },
- 'pollingPeriodMS': sheet["C"+row_str].value,
- 'requestTimeoutMS': sheet["D"+row_str].value,
- 'equipments': [{
- 'id': sheet["E"+row_str].value,
- 'templateId': sheet["F"+row_str].value,
- 'equipmentId': sheet["G"+row_str].value,
- 'equipmentName': sheet["H"+row_str].value
- },
- {
- 'id': sheet["E"+row_str].value,
- 'templateId': sheet["F"+row_str].value,
- 'equipmentId': sheet["G"+row_str].value,
- 'equipmentName': sheet["H"+row_str].value
- },
- {
- 'id': sheet["E"+row_str].value,
- 'templateId': sheet["F"+row_str].value,
- 'equipmentId': sheet["G"+row_str].value,
- 'equipmentName': sheet["H"+row_str].value
- }]
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement