Skip to content

Commit 500883b

Browse files
committed
🔨 code refactoring
1 parent 2541ef1 commit 500883b

File tree

7 files changed

+15
-27
lines changed

7 files changed

+15
-27
lines changed

pyexcel_xlsxr/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pyexcel_io.io import get_data as read_data
99
from pyexcel_io.io import isstream
1010
from pyexcel_io.plugins import IOPluginInfoChainV2
11-
1211
from pyexcel_xlsxr._version import __author__, __version__ # noqa
1312

1413
__FILE_TYPE__ = "xlsx"

pyexcel_xlsxr/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '0.6.0'
2-
__author__ = 'chfw'
1+
__version__ = "0.6.0"
2+
__author__ = "chfw"

pyexcel_xlsxr/xlsxr.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from io import BytesIO
33

44
import pyexcel_io.service as service
5-
from pyexcel_io.plugin_api.abstract_reader import IReader
6-
from pyexcel_io.plugin_api.abstract_sheet import ISheet
7-
5+
from pyexcel_io.plugin_api import IReader, ISheet, NamedContent
86
from pyexcel_xlsxr.messy_xlsx import XLSXBookSet
97

108

@@ -15,20 +13,14 @@ def __init__(
1513
auto_detect_int=True,
1614
auto_detect_float=True,
1715
auto_detect_datetime=True,
18-
**keywords
1916
):
20-
self._native_sheet = sheet
17+
self.xlsx_sheet = sheet
2118
self.__auto_detect_int = auto_detect_int
2219
self.__auto_detect_float = auto_detect_float
2320
self.__auto_detect_datetime = auto_detect_datetime
24-
self._keywords = keywords
25-
26-
@property
27-
def name(self):
28-
return self._native_sheet.name
2921

3022
def row_iterator(self):
31-
return self._native_sheet.raw()
23+
return self.xlsx_sheet.raw()
3224

3325
def column_iterator(self, row):
3426
for cell in row:
@@ -57,30 +49,24 @@ def __convert_cell(self, cell):
5749

5850
class XLSXBook(IReader):
5951
def __init__(self, file_alike_object, _, **keywords):
60-
self._native_book = XLSXBookSet(file_alike_object)
52+
self.xlsx_book = XLSXBookSet(file_alike_object)
6153
self._keywords = keywords
62-
tables = self._native_book.make_tables()
54+
tables = self.xlsx_book.make_tables()
6355
self.content_array = [
64-
NameObject(table.name, table) for table in tables
56+
NameContent(table.name, table) for table in tables
6557
]
6658

6759
def read_sheet(self, sheet_index):
6860
"""read a sheet at a specified index"""
69-
table = self.content_array[sheet_index].sheet
61+
table = self.content_array[sheet_index].payload
7062
sheet = XLSXSheet(table, **self._keywords)
7163
return sheet
7264

7365
def close(self):
74-
self._native_book.close()
66+
self.xlsx_book.close()
7567

7668

7769
class XLSXBookInContent(XLSXBook):
7870
def __init__(self, file_content, file_type, **keywords):
7971
file_stream = BytesIO(file_content)
8072
super().__init__(file_stream, file_type, **keywords)
81-
82-
83-
class NameObject(object):
84-
def __init__(self, name, sheet):
85-
self.name = name
86-
self.sheet = sheet

tests/test_bug_fixes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import MagicMock
33

44
from nose.tools import eq_
5+
56
from pyexcel_io.reader import EncapsulatedSheetReader
67
from pyexcel_xlsxr import get_data
78

tests/test_filter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
from nose.tools import eq_
4+
45
from pyexcel_io import get_data, save_data
56

67

tests/test_reading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from datetime import datetime, time
33

44
from nose.tools import eq_
5-
from pyexcel_io._compact import OrderedDict
65

6+
from pyexcel_io._compact import OrderedDict
77
from pyexcel_xlsxr import get_data
88

99

tests/test_stringio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import os
22

33
import pyexcel
4-
from base import create_sample_file1
54
from nose.tools import eq_
65

6+
from base import create_sample_file1
7+
78

89
class TestStringIO:
910
def test_xlsx_stringio(self):

0 commit comments

Comments
 (0)