Skip to content

Commit 117a258

Browse files
black reformatting
1 parent 620affd commit 117a258

File tree

1 file changed

+52
-31
lines changed

1 file changed

+52
-31
lines changed

pandas/io/excel/_odswriter.py

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
from odf.style import Style, TextProperties, TableCellProperties, ParagraphProperties
1212
from odf.table import Table, TableRow, TableCell
1313
from odf.text import P
14-
from odf.config import ConfigItemSet, ConfigItemMapEntry, ConfigItemMapNamed, ConfigItem, ConfigItemMapIndexed
14+
from odf.config import (
15+
ConfigItemSet,
16+
ConfigItemMapEntry,
17+
ConfigItemMapNamed,
18+
ConfigItem,
19+
ConfigItemMapIndexed,
20+
)
1521

1622

1723
class _ODSWriter(ExcelWriter):
@@ -37,8 +43,9 @@ def save(self):
3743
self.book.spreadsheet.addElement(sheet)
3844
return self.book.save(self.path)
3945

40-
def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0,
41-
freeze_panes=None):
46+
def write_cells(
47+
self, cells, sheet_name=None, startrow=0, startcol=0, freeze_panes=None
48+
):
4249
# Write the frame cells using odf
4350
# assert startrow == 0
4451
# assert startcol == 0
@@ -96,22 +103,32 @@ def _make_table_cell(self, cell):
96103
else:
97104
value = val.strftime("%Y-%m-%d")
98105
pvalue = val.strftime("%x")
99-
return pvalue, TableCell(valuetype="date", datevalue=value,
100-
attributes=attributes)
106+
return (
107+
pvalue,
108+
TableCell(valuetype="date", datevalue=value, attributes=attributes),
109+
)
101110
elif isinstance(val, datetime.date):
102111
value = val.strftime("%Y-%m-%d")
103112
pvalue = val.strftime("%x")
104-
return pvalue, TableCell(valuetype="date", datevalue=value,
105-
attributes=attributes)
113+
return (
114+
pvalue,
115+
TableCell(valuetype="date", datevalue=value, attributes=attributes),
116+
)
106117
else:
107118
class_to_cell_type = {
108119
str: "string",
109120
int: "float",
110121
float: "float",
111122
bool: "boolean",
112123
}
113-
return pvalue, TableCell(valuetype=class_to_cell_type[type(val)],
114-
value=value, attributes=attributes)
124+
return (
125+
pvalue,
126+
TableCell(
127+
valuetype=class_to_cell_type[type(val)],
128+
value=value,
129+
attributes=attributes,
130+
),
131+
)
115132

116133
def _process_style(self, style):
117134
if style is None:
@@ -129,12 +146,12 @@ def _process_style(self, style):
129146
if "borders" in style:
130147
borders = style["borders"]
131148
for side, thickness in borders.items():
132-
thickness_translation = {
133-
"thin": "0.75pt solid #000000"
134-
}
149+
thickness_translation = {"thin": "0.75pt solid #000000"}
135150
odf_style.addElement(
136151
TableCellProperties(
137-
attributes={f"border{side}": thickness_translation[thickness]}))
152+
attributes={f"border{side}": thickness_translation[thickness]}
153+
)
154+
)
138155
if "alignment" in style:
139156
alignment = style["alignment"]
140157
horizontal = alignment.get("horizontal")
@@ -162,21 +179,25 @@ def _create_freeze_panes(self, sheet_name, freeze_panes):
162179
config_item_map_entry = ConfigItemMapEntry(name=sheet_name)
163180
config_item_map_named.addElement(config_item_map_entry)
164181

165-
config_item_map_entry.addElement(ConfigItem(name="HorizontalSplitMode",
166-
type="short",
167-
text="2"))
168-
config_item_map_entry.addElement(ConfigItem(name="VerticalSplitMode",
169-
type="short",
170-
text="2"))
171-
config_item_map_entry.addElement(ConfigItem(name="HorizontalSplitPosition",
172-
type="int",
173-
text=str(freeze_panes[0])))
174-
config_item_map_entry.addElement(ConfigItem(name="VerticalSplitPosition",
175-
type="int",
176-
text=str(freeze_panes[1])))
177-
config_item_map_entry.addElement(ConfigItem(name="PositionRight",
178-
type="int",
179-
text=str(freeze_panes[0])))
180-
config_item_map_entry.addElement(ConfigItem(name="PositionBottom",
181-
type="int",
182-
text=str(freeze_panes[1])))
182+
config_item_map_entry.addElement(
183+
ConfigItem(name="HorizontalSplitMode", type="short", text="2")
184+
)
185+
config_item_map_entry.addElement(
186+
ConfigItem(name="VerticalSplitMode", type="short", text="2")
187+
)
188+
config_item_map_entry.addElement(
189+
ConfigItem(
190+
name="HorizontalSplitPosition", type="int", text=str(freeze_panes[0])
191+
)
192+
)
193+
config_item_map_entry.addElement(
194+
ConfigItem(
195+
name="VerticalSplitPosition", type="int", text=str(freeze_panes[1])
196+
)
197+
)
198+
config_item_map_entry.addElement(
199+
ConfigItem(name="PositionRight", type="int", text=str(freeze_panes[0]))
200+
)
201+
config_item_map_entry.addElement(
202+
ConfigItem(name="PositionBottom", type="int", text=str(freeze_panes[1]))
203+
)

0 commit comments

Comments
 (0)