Skip to content

Commit ba45665

Browse files
committed
enable reading sheet references from meta variables
1 parent 2927ac8 commit ba45665

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

refinery/units/formats/office/xlxtr.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import codecs
34
import enum
45
import functools
56
import io
@@ -13,7 +14,7 @@
1314

1415
from refinery.lib.structures import MemoryFile
1516
from refinery.lib.tools import NoLogging
16-
from refinery.lib.types import Param
17+
from refinery.lib.types import buf, Param
1718
from refinery.units import Arg, Unit
1819

1920
if TYPE_CHECKING:
@@ -298,17 +299,12 @@ class xlxtr(ExcelUnit):
298299
"""
299300
def __init__(
300301
self,
301-
*references: Param[SheetReference, Arg(
302-
metavar='reference',
303-
type=SheetReference,
304-
help=(
305-
'A sheet reference to be extracted. '
306-
'If no sheet references are given, the unit lists all sheet names.'
307-
)
308-
)]
302+
*references: Param[buf, Arg(metavar='reference', help=(
303+
'A sheet reference to be extracted. '
304+
'If no sheet references are given, the unit lists all sheet names.'))]
309305
):
310306
if not references:
311-
references = SheetReference('*'),
307+
references = b'*',
312308
super().__init__(references=references)
313309

314310
def process(self, data):
@@ -318,8 +314,8 @@ def process(self, data):
318314
raise
319315
except Exception as E:
320316
raise ValueError('Input not recognized as Excel document.') from E
321-
for ref in self.args.references:
322-
ref: SheetReference
317+
references = [SheetReference(codecs.decode(r, self.codec)) for r in self.args.references]
318+
for ref in references:
323319
for k, name in enumerate(wb.sheets()):
324320
if not ref.match(k, name):
325321
continue

0 commit comments

Comments
 (0)