Skip to content

Commit 5b0adce

Browse files
Move imports inside methods
1 parent 9c6ef88 commit 5b0adce

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

pandas/io/excel/_odswriter.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
import datetime
33
from typing import DefaultDict
44

5-
from odf.config import (
6-
ConfigItem,
7-
ConfigItemMapEntry,
8-
ConfigItemMapIndexed,
9-
ConfigItemMapNamed,
10-
ConfigItemSet,
11-
)
12-
from odf.opendocument import OpenDocumentSpreadsheet
13-
from odf.style import ParagraphProperties, Style, TableCellProperties, TextProperties
14-
from odf.table import Table, TableCell, TableRow
15-
from odf.text import P
16-
175
import pandas._libs.json as json
186

197
from pandas.io.excel._base import ExcelWriter
@@ -25,6 +13,8 @@ class _ODSWriter(ExcelWriter):
2513
supported_extensions = (".ods",)
2614

2715
def __init__(self, path, engine=None, encoding=None, mode="w", **engine_kwargs):
16+
from odf.opendocument import OpenDocumentSpreadsheet
17+
2818
engine_kwargs["engine"] = engine
2919

3020
if mode == "a":
@@ -46,6 +36,9 @@ def save(self):
4636
def write_cells(
4737
self, cells, sheet_name=None, startrow=0, startcol=0, freeze_panes=None
4838
):
39+
from odf.table import Table, TableCell, TableRow
40+
from odf.text import P
41+
4942
# Write the frame cells using odf
5043
# assert startrow == 0
5144
# assert startcol == 0
@@ -90,6 +83,8 @@ def _make_table_cell_attributes(self, cell):
9083
return attributes
9184

9285
def _make_table_cell(self, cell):
86+
from odf.table import TableCell
87+
9388
attributes = self._make_table_cell_attributes(cell)
9489
val, fmt = self._value_with_fmt(cell.val)
9590
pvalue = value = val
@@ -131,6 +126,13 @@ def _make_table_cell(self, cell):
131126
)
132127

133128
def _process_style(self, style):
129+
from odf.style import (
130+
ParagraphProperties,
131+
Style,
132+
TableCellProperties,
133+
TextProperties,
134+
)
135+
134136
if style is None:
135137
return None
136138
style_key = json.dumps(style)
@@ -164,6 +166,14 @@ def _process_style(self, style):
164166
return name
165167

166168
def _create_freeze_panes(self, sheet_name, freeze_panes):
169+
from odf.config import (
170+
ConfigItem,
171+
ConfigItemMapEntry,
172+
ConfigItemMapIndexed,
173+
ConfigItemMapNamed,
174+
ConfigItemSet,
175+
)
176+
167177
config_item_set = ConfigItemSet(name="ooo:view-settings")
168178
self.book.settings.addElement(config_item_set)
169179

0 commit comments

Comments
 (0)