adjusted filehandle conditional type
This commit is contained in:
parent
ffa80f6bef
commit
b4088b666e
|
@ -1,13 +1,15 @@
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
from typing import Union, Optional, Tuple, List, TextIO, Set
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from typing import Union, Optional, Tuple, List, TextIO, Set
|
||||||
|
from _io import TextIOWrapper
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
class Table:
|
class Table:
|
||||||
"""Manipulate multi-dimensional spreadsheet-like data."""
|
"""Manipulate multi-dimensional spreadsheet-like data."""
|
||||||
|
|
||||||
|
@ -239,7 +241,7 @@ class Table:
|
||||||
Table data from file.
|
Table data from file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(fname, TextIO):
|
if isinstance(fname, TextIOWrapper):
|
||||||
f = fname
|
f = fname
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
elif isinstance(fname, (str, pathlib.Path)):
|
elif isinstance(fname, (str, pathlib.Path)):
|
||||||
|
@ -298,7 +300,7 @@ class Table:
|
||||||
Table data from file.
|
Table data from file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(fname, TextIO):
|
if isinstance(fname, TextIOWrapper):
|
||||||
f = fname
|
f = fname
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
elif isinstance(fname, (str, pathlib.Path)):
|
elif isinstance(fname, (str, pathlib.Path)):
|
||||||
|
@ -569,7 +571,7 @@ class Table:
|
||||||
labels += [f'{util.srepr(self.shapes[l],"x")}:{i+1}_{l}' \
|
labels += [f'{util.srepr(self.shapes[l],"x")}:{i+1}_{l}' \
|
||||||
for i in range(np.prod(self.shapes[l]))]
|
for i in range(np.prod(self.shapes[l]))]
|
||||||
|
|
||||||
if isinstance(fname, TextIO):
|
if isinstance(fname, TextIOWrapper):
|
||||||
fhandle = fname
|
fhandle = fname
|
||||||
elif isinstance(fname, (str, pathlib.Path)):
|
elif isinstance(fname, (str, pathlib.Path)):
|
||||||
fhandle = open(fname,'w',newline='\n')
|
fhandle = open(fname,'w',newline='\n')
|
||||||
|
|
Loading…
Reference in New Issue