Skip to content

Commit

Permalink
saxon: fix little transform script
Browse files Browse the repository at this point in the history
  • Loading branch information
mokko committed May 12, 2024
1 parent f2fcaeb commit d6c467f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 2 additions & 4 deletions zml2lido/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
21 changes: 16 additions & 5 deletions zml2lido/lidoTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d6c467f

Please sign in to comment.