Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# @TODO fit the minimum rectangle than whole array
values = [[None for x in range(self.cols)] for y in range(self.rows)]
for cell in cell_list:
values[cell.col-1][cell.row-1] = cell.value
body = dict()
estimate_size = False
if type(crange) == str:
if crange.find(':') == -1:
estimate_size = True
elif type(crange) == tuple:
estimate_size = True
else:
raise InvalidArgumentValue
if estimate_size:
start_r_tuple = Worksheet.get_addr(crange, output='tuple')
if majordim == 'ROWS':
end_r_tuple = (start_r_tuple[0]+len(values), start_r_tuple[1]+len(values[0]))
else:
end_r_tuple = (start_r_tuple[0] + len(values[0]), start_r_tuple[1] + len(values))
body['range'] = self._get_range(crange, Worksheet.get_addr(end_r_tuple))
else:
body['range'] = self._get_range(*crange.split(':'))
body['majorDimension'] = majordim
body['values'] = values
self.client.sh_update_range(self.spreadsheet.id, body, self.spreadsheet.batch_mode)
def __init__(self, pos, val='', worksheet=None):
self.worksheet = worksheet
if type(pos) == str:
pos = Worksheet.get_addr(pos, 'tuple')
self._row, self._col = pos
self._label = Worksheet.get_addr(pos, 'label')
self._value = val # formated vlaue
self._unformated_value = val # @TODO
self._formula = ''
# self.format = FormatType.CUSTOM # @TODO
self.parse_value = True # if the value will be parsed to corsp types
self._parse_formula = False # should value parse formula
self._comment = '' # @TODO
def _get_range(self, start_label, end_label):
"""get range in A1 notation, given start and end labels
"""
return self.title + '!' + ('%s:%s' % (Worksheet.get_addr(start_label, 'label'),
Worksheet.get_addr(end_label, 'label')))
def __init__(self, pos, val='', worksheet=None):
self.worksheet = worksheet
if type(pos) == str:
pos = Worksheet.get_addr(pos, 'tuple')
self._row, self._col = pos
self._label = Worksheet.get_addr(pos, 'label')
self._value = val # formated vlaue
self._unformated_value = val # @TODO
self._formula = ''
# self.format = FormatType.CUSTOM # @TODO
self.parse_value = True # if the value will be parsed to corsp types
self._parse_formula = False # should value parse formula
self._comment = '' # @TODO