diff --git a/test/test_file.py b/test/test_file.py index 80b36da..b614103 100644 --- a/test/test_file.py +++ b/test/test_file.py @@ -1,9 +1,9 @@ from pathlib import Path -from zml2lido.file import per_chunk, unzip +from zml2lido.file import per_chunk def test_per_chunk(): p = Path(r"C:\m3\zml2lido\sdata\GG\20240307\query516069-chunk1.lido.xml") if not p.exists(): - raise FileNotFound("p not found!") + raise FileNotFoundError("p not found!") assert 2 == len(list(per_chunk(p))) diff --git a/zml2lido/__init__.py b/zml2lido/__init__.py index 65ad22c..da4f04a 100644 --- a/zml2lido/__init__.py +++ b/zml2lido/__init__.py @@ -8,7 +8,6 @@ import argparse -import sys from zml2lido.lidoTool import LidoTool from zml2lido.linkChecker import LinkChecker from zml2lido.vocmap import Vocmap diff --git a/zml2lido/lidoTool.py b/zml2lido/lidoTool.py index 51838a6..317dfd0 100644 --- a/zml2lido/lidoTool.py +++ b/zml2lido/lidoTool.py @@ -33,8 +33,7 @@ import os import re import subprocess -import sys -from typing import Iterable, Optional +from typing import Iterable from zipfile import ZipFile from zml2lido.linkChecker import LinkChecker @@ -102,7 +101,7 @@ def execute(self, job: str) -> None: raise SyntaxError("ERROR: Unknown job name!") def lfilter(self, *, split: bool = False, Type: str) -> None: - if not Type in xsl: + if Type not in xsl: raise TypeError(f"Error: Unknown type '{Type}'") new_fn = self.src.stem + f"-no{Type}.xml" @@ -315,7 +314,7 @@ def saxon(self, *, src: str | Path, output: str | Path, xsl: str | Path) -> None raise SyntaxError(f"ERROR: src {src} does not exist!") if not Path(xsl).exists(): - raise SyntaxError(f"ERROR: xsl file does not exist!") + raise SyntaxError("ERROR: xsl file does not exist!") cmd = f"java -Xmx1450m -jar {saxLib} -s:{src} -xsl:{xsl} -o:{output}" print(cmd) @@ -399,7 +398,7 @@ def _sanitize(self, *, src: str | Path) -> Path: if not Path(saxLib).is_file(): raise SyntaxError( - f"ERROR: Saxon not found, check environment variable saxLib" + "ERROR: Saxon not found, check environment variable saxLib" ) # check src diff --git a/zml2lido/lidoscript.py b/zml2lido/lidoscript.py deleted file mode 100644 index b5d2341..0000000 --- a/zml2lido/lidoscript.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -lidos - lido script -""" - -import argparse -from zml2lido.lidoTool import LidoTool -from pathlib import Path - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Little LIDO toolchain") - parser.add_argument( - "-f", "--force", help="force mode", action="store_true", default=False - ) - parser.add_argument( - "-j", - "--job", - help="location of jobs.dsl", - required=True, - ) - parser.add_argument( - "-v", "--validate", help="validate lido", action="store_true", default=False - ) - args = parser.parse_args() - - ls = LidoScript(job_fn=args["job"]) - - -class LidoScript: - def __init__(self, job_fn): - self.load_dsl(job_fn=job_fn) - # load dsl file at default location "jobs.dsl" - # then we r in project_dir we're not in zml2lido dir - - def load_dsl(self, job_fn): - with open(job.fn, mode="r") as file: - for line in file: - uncomment = line.split("#", 1)[0].strip() - if uncomment.isspace() or not uncomment: - continue - parts: list[str] = uncomment.split() - try: - parts[1] - except: - chunks = False - else: - if parts[1] == "chunk": - chunks = True - else: - chunks = False - - lidoTool( - Input=parts[0], force=force, validation=validation, chunks=chunks - ) diff --git a/zml2lido/linkChecker.py b/zml2lido/linkChecker.py index 871609f..688d719 100644 --- a/zml2lido/linkChecker.py +++ b/zml2lido/linkChecker.py @@ -22,10 +22,7 @@ from lxml import etree from mpapi.constants import get_credentials from mpapi.client import MpApi -from mpapi.module import Module -from mpapi.search import Search from pathlib import Path -import re from typing import Any import urllib.request from zml2lido.relWorksCache import RelWorksCache diff --git a/zml2lido/qc.py b/zml2lido/qc.py index 99ee000..caa34bc 100644 --- a/zml2lido/qc.py +++ b/zml2lido/qc.py @@ -9,7 +9,6 @@ """ import argparse -from pathlib import Path parser = argparse.ArgumentParser(description="Quality control for LIDO files") parser.add_argument( diff --git a/zml2lido/vocmap.py b/zml2lido/vocmap.py index a561363..dc54184 100644 --- a/zml2lido/vocmap.py +++ b/zml2lido/vocmap.py @@ -7,7 +7,7 @@ """ from lxml import etree -from openpyxl import Workbook, load_workbook +from openpyxl import Workbook from openpyxl.styles import Font from pathlib import Path