Skip to content

Commit 7d81e1a

Browse files
committed
readme and test update
1 parent 78ed849 commit 7d81e1a

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

README.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,37 @@ This small section outlines the steps to adapt **pyexcel-webio** for your favour
4545
extension = filename.split(".")[1]
4646
return extension, filehandle
4747
48-
def load_single_sheet(self, field_name=None, sheet_name=None, **keywords):
48+
def load_single_sheet(self, field_name=None, sheet_name=None,
49+
**keywords):
4950
file_type, file_handle = self._get_file_tuple(field_name)
50-
return pe.load_from_memory(file_type, file_handle.read(), sheet_name, **keywords)
51+
return pe.get_sheet(file_type=file_type,
52+
content=file_handle.read(),
53+
sheet_name=sheet_name,
54+
**keywords)
5155
5256
def load_book(self, field_name=None, **keywords):
5357
file_type, file_handle = self._get_file_tuple(field_name)
54-
return pe.load_book_from_memory(file_type, file_handle.read(), **keywords)
58+
return pe.get_book(file_type=file_type,
59+
content=file_handle.read(),
60+
**keywords)
5561

5662
2. Plugin in a response method that has the following signature::
5763

58-
def your_func(content, content_type=None, status=200):
59-
....
64+
def your_func(content, content_type=None, status=200):
65+
....
6066

61-
or a response class has the same signature::
67+
or a response class has the same signature::
6268

63-
class YourClass:
64-
def __init__(self, content, content_type=None, status=200):
65-
....
69+
class YourClass:
70+
def __init__(self, content, content_type=None, status=200):
71+
....
6672

67-
For example, with **Flask**, it is just a few lines::
73+
For example, with **Flask**, it is just a few lines::
6874

69-
from flask import Response
75+
from flask import Response
7076

7177

72-
webio.ExcelResponse = Response
78+
webio.ExcelResponse = Response
7379

7480

7581
3. Then make the proxy for **make_response** series by simply copying the following lines to your extension::

pyexcel_webio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ def save_book_to_database(self, session, tables, **keywords):
140140
book.save_to_database(session, tables)
141141

142142

143-
def dumpy_func(content, content_type=None, status=200):
143+
def dummy_func(content, content_type=None, status=200):
144144
return None
145145

146146

147-
ExcelResponse = dumpy_func
147+
ExcelResponse = dummy_func
148148

149149

150150
def make_response(pyexcel_instance, file_type, status=200, **keywords):

tests/test_webio.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ def test_get_book_dict(self):
7676
result = myinput.get_book_dict(unrelated="foo bar")
7777
assert result == None
7878

79+
def test_dummy_function(self):
80+
result = webio.dummy_func(None, None)
81+
assert result == None
82+
83+
7984
# excel inputs
8085

8186
class TestExcelInput:

0 commit comments

Comments
 (0)