diff --git a/zml2lido/__init__.py b/zml2lido/__init__.py index f66be83..cb501c5 100644 --- a/zml2lido/__init__.py +++ b/zml2lido/__init__.py @@ -100,10 +100,8 @@ def saxon(): "-x", "--xsl", help="(xslt) transformation filename", required=True ) args = parser.parse_args() - m = LidoTool(src=args.source) # just to run saxon... - - m.saxon(Input=args.source, xsl=args.xsl, output=args.output) - m.saxon(Input=args.source, xsl=args.xsl, output=args.output) + m = LidoTool(src=args.source) + m.saxon(xsl=args.xsl, output=args.output) def validate(): diff --git a/zml2lido/lidoTool.py b/zml2lido/lidoTool.py index fbb3464..7722001 100644 --- a/zml2lido/lidoTool.py +++ b/zml2lido/lidoTool.py @@ -311,7 +311,17 @@ def firstChunkName(self, *, src: str | Path): # print(f"***firstChunkName {firstFn}") return firstFn - def saxon(self, *, src: str | Path, output: str | Path, xsl: str | Path) -> None: + def saxon(self, *, output: str | Path, xsl: str | Path, src: str | Path | None = None) -> None: + """ + New: src is optional. + + lc = LidoTool(src="ere.xml") + lc.saxon(xsl="test.xsl", output="out.xml") + lc.saxon(src="other.xml", xsl="test.xsl", output="out.xml") + """ + if src is None: + src = self.src + if not Path(src).exists(): raise SyntaxError(f"ERROR: src {src} does not exist!") @@ -384,10 +394,11 @@ def _prepareOutdir(self) -> Path: if re.match(r"\d\d\d\d\d\d", self.src.parent.name): outdir = sdataP / self.src.parents[1].name / self.src.parent.name elif self.src.parent.name == "sdata": - raise SyntaxError( - """ERROR: Don't use an src file inside of sdata. - Use a subdirectory instead!""" - ) + outdir = sdataP + #raise SyntaxError( + # """ERROR: Don't use an src file inside of sdata. + # Use a subdirectory instead!""" + #) else: outdir = sdataP / self.src.parent.name