8000 fix unit test failures · pyexcel/pyexcel@293f4e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 293f4e8

Browse files
committed
fix unit test failures
1 parent 4e71a34 commit 293f4e8

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

pyexcel/_compact.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from textwrap import dedent
2323
from itertools import zip_longest
2424
from collections import OrderedDict
25+
from pathlib import Path
2526

2627
PY2 = sys.version_info[0] == 2
2728
PY26 = PY2 and sys.version_info[1] < 7
@@ -72,3 +73,9 @@ def _doc(func):
7273
return func
7374

7475
return _doc
76+
77+
78+
def get_string_file_name(file_name):
79+
if isinstance(file_name, Path):
80+
file_name = str(file_name.resolve())
81+
return file_name

pyexcel/plugins/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
"""
1010

1111
import types
12-
from pathlib import Path
1312
from itertools import product
1413

1514
from pyexcel import constants
1615
from lml.plugin import PluginInfo, PluginInfoChain
17-
from pyexcel._compact import is_string
16+
from pyexcel._compact import is_string, get_string_file_name
1817
from pyexcel.exceptions import FileTypeNotSupported
1918
from pyexcel.internal.plugins import PARSER, RENDERER
2019

@@ -46,8 +45,7 @@ def is_my_business(self, action, **keywords):
4645
status = SourceInfo.is_my_business(self, action, **keywords)
4746
if status:
4847
file_name = keywords.get("file_name", None)
49-
if isinstance(file_name, Path):
50-
file_name = str(file_name.resolve())
48+
file_name = get_string_file_name(file_name)
5149
if file_name:
5250
file_type = keywords.get("force_file_type")
5351

pyexcel/plugins/sources/file_input.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212

1313
from pyexcel.source import AbstractSource
1414
from pyexcel.internal import PARSER
15+
from pyexcel._compact import get_string_file_name
1516

1617

1718
# pylint: disable=W0223
1819
class ReadExcelFromFile(AbstractSource):
1920
"""Pick up 'file_name' field and do single sheet based read and write"""
2021

2122
def __init__(self, file_name=None, parser_library=None, **keywords):
22-
self.__file_name = file_name
23+
self.__file_name = get_string_file_name(file_name)
2324

2425
if "force_file_type" in keywords:
2526
file_type = keywords.get("force_file_type")

0 commit comments

Comments
 (0)
0