Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _binary_operation(self, other, operation):
return Style( \
font=operation(self.font, other.font), \
fill=operation(self.fill, other.fill), \
format=operation(self.format, other.format), \
alignment=operation(self.alignment, other.alignment), \
borders=operation(self.borders, other.borders) \
)
def get_row_style(self, row):
if row not in self._row_styles:
self.set_row_style(row, Style.Style())
return self._row_styles[row]
def get_col_style(self, col):
if col not in self._col_styles:
self.set_col_style(col, Style.Style())
return self._col_styles[col]
def __set_attr(self, method, data):
if self.is_cell:
for merge in self.worksheet.merges:
if self in merge:
method(merge._start[0], merge._start[1], data)
return
method(self.x, self.y, data)
elif self.is_row and isinstance(data, Style.Style):
# Applying a row style
self.worksheet.set_row_style(self.x, data)
elif DataTypes.DataTypes.get_type(data) != DataTypes.DataTypes.ERROR:
# Attempt to apply in batch
for cell in self:
cell.__set_attr(method, data)
else:
if len(data) <= self.height:
for row in data:
if len(row) > self.width:
raise Exception(
"Row too large for range, row has %s columns, but range only has %s"
% (len(row), self.width))
for x, row in enumerate(data):
for y, value in enumerate(row):
method(x + self._start[0], y + self._start[1], value)
def get_cell_style(self, x, y):
if y not in self._styles[x]:
self.set_cell_style(x, y, Style.Style())
return self._styles[x][y]