-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathss_attr.py
22 lines (19 loc) · 865 Bytes
/
ss_attr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AttrSheet:
def __init__(self, helper, spreadsheet_id, sheet, col_key):
self.helper = helper
self.sheet = sheet
self.col_key = col_key
self.data_table = self.helper.get_data_table(spreadsheet_id, self.sheet, self.col_key, cached=False)
def get_all_attributes(self, key):
key = str(key)
row_with_team_id = self.data_table.get_values_where_header_equals(self.col_key, str(key))
ret = { k.replace('ATTR_', ''): v for k, v in row_with_team_id.items() if k.startswith('ATTR_') }
return ret
def get_attribute(self, key, attribute):
key = str(key)
row_with_team_id = self.data_table.get_values_by_key(key)
return row_with_team_id[f'ATTR_{attribute}']
def set_attribute(self, key, attribute, value):
key = str(key)
self.data_table.set_value_by_key_header(key, f'ATTR_{attribute}', value)
return value