Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
matrix = values
if returnas == 'matrix':
return matrix
else:
cells = []
for k in range(len(matrix)):
row = []
for i in range(len(matrix[k])):
if majdim == 'COLUMNS':
row.append(Cell((start[0]+i, start[1]+k), matrix[k][i], self))
elif majdim == 'ROWS':
row.append(Cell((start[0]+k, start[1]+i), matrix[k][i], self))
else:
raise InvalidArgumentValue('majdim')
cells.append(row)
return cells
def indexes(self, value):
if type(value) is not tuple:
raise InvalidArgumentValue("Please provide a tuple")
self._start, self._end = Address(value[0], True), Address(value[1], True)
self._apply_index_constraints()
self._calculate_label()
:keyword transferOwnership: Whether to transfer ownership to the specified user and downgrade
the current owner to a writer. This parameter is required as an acknowledgement
of the side effect. (Default: False)
:keyword useDomainAdminAccess: Whether the request should be treated as if it was issued by a
domain administrator; if set to true, then the requester will be granted
access if they are an administrator of the domain to which the item belongs.
(Default: False)
:return: `Permission Resource `_
"""
if 'supportsTeamDrives' not in kwargs and self.team_drive_id:
kwargs['supportsTeamDrives'] = True
if 'emailAddress' in kwargs and 'domain' in kwargs:
raise InvalidArgumentValue('A permission can only use emailAddress or domain. Do not specify both.')
if role not in PERMISSION_ROLES:
raise InvalidArgumentValue('A permission role can only be one of ' + str(PERMISSION_ROLES) + '.')
if type not in PERMISSION_TYPES:
raise InvalidArgumentValue('A permission role can only be one of ' + str(PERMISSION_TYPES) + '.')
body = {
'kind': 'drive#permission',
'type': type,
'role': role
}
if 'emailAddress' in kwargs:
body['emailAddress'] = kwargs['emailAddress']
del kwargs['emailAddress']
elif 'domain' in kwargs:
body['domain'] = kwargs['domain']
del kwargs['domain']
# self._end = self._start
# return
# if not self._end:
# self._start = self._end
# return
# # if range is not single celled, and one index is unbounded make it single celled
# if not self._end:
# self._end = self._start
# if not self._start:
# self._start = self._end
# Check if unbound on different axes
if ((self._start[0] and not self._start[1]) and (not self._end[0] and self._end[1])) or \
(not self._start[0] and self._start[1]) and (self._end[0] and not self._end[1]):
self._start, self._end = Address(None, True), Address(None, True)
raise InvalidArgumentValue('Invalid indexes set. Indexes should be unbounded at same axes.')
# If one axes is unbounded on an index, make other index also unbounded on same axes
if self._start[0] is None or self._end[0] is None:
self._start[0], self._end[0] = None, None
elif self._start[1] is None or self._end[1] is None:
self._start[1], self._end[1] = None, None
# verify
# if (self._start[0] and not self._end[0]) or (not self._start[0] and self._end[0]) or \
# (self._start[1] and not self._end[1]) or (not self._start[1] and self._end[1]):
# self._start, self._end = Address(None, True), Address(None, True)
# raise InvalidArgumentValue('Invalid start and end set for this range')
if self._start and self._end:
if self._start[0]:
assert self._start[0] <= self._end[0]
def _validate(self):
if not self.allow_non_single and (self._value[0] is None or self._value[0] is None):
raise InvalidArgumentValue("Address cannot be unbounded if allow_non_single is not set.")
if self._value[0]:
row = int(self._value[0])
if row < 1:
raise InvalidArgumentValue('Address coordinates may not be below zero: ' + repr(self._value))
if self._value[1]:
col = int(self._value[1])
if col < 1:
raise InvalidArgumentValue('Address coordinates may not be below zero: ' + repr(self._value))
def label(self, value):
if type(value) is not str:
raise InvalidArgumentValue('non string value for label')
self._calculate_addresses(value)
def _validate(self):
if not self.allow_non_single and (self._value[0] is None or self._value[0] is None):
raise InvalidArgumentValue("Address cannot be unbounded if allow_non_single is not set.")
if self._value[0]:
row = int(self._value[0])
if row < 1:
raise InvalidArgumentValue('Address coordinates may not be below zero: ' + repr(self._value))
if self._value[1]:
col = int(self._value[1])
if col < 1:
raise InvalidArgumentValue('Address coordinates may not be below zero: ' + repr(self._value))
elif type(addr) == str:
if output == 'tuple' or output == 'flip':
_cell_addr_re = re.compile(r'([A-Za-z]+)(\d+)')
m = _cell_addr_re.match(addr)
if m:
column_label = m.group(1).upper()
row, col = int(m.group(2)), 0
for i, c in enumerate(reversed(column_label)):
col += (ord(c) - _MAGIC_NUMBER) * (26 ** i)
else:
raise IncorrectCellLabel(addr)
return int(row), int(col)
elif output == 'label':
return addr
else:
raise InvalidArgumentValue("addr of type " + str(type(addr)))