From fbf7bcc2cc7b4ab0df9bc539fcdee519c852d1b5 Mon Sep 17 00:00:00 2001 From: Steffen Brinckmann Date: Tue, 31 Oct 2023 15:06:19 +0100 Subject: [PATCH] validator test 1 --- .github/workflows/validator_pypi_rocrate.yml | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/validator_pypi_rocrate.yml diff --git a/.github/workflows/validator_pypi_rocrate.yml b/.github/workflows/validator_pypi_rocrate.yml new file mode 100644 index 0000000..b5ec71a --- /dev/null +++ b/.github/workflows/validator_pypi_rocrate.yml @@ -0,0 +1,46 @@ +name: pypi_rocrate +# Validate if rocrate of pypi can open and parse it +# https://pypi.org/project/rocrate/ + +on: [ push ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.10" ] + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install rocrate + - name: Test with pytest + run: | + from zipfile import ZIP_DEFLATED + from zipfile import Path as ZPath + from zipfile import ZipFile + from rocrate.rocrate import ROCrate + from rocrate.model.entity import Entity + from rocrate.model.contextentity import ContextEntity + + for fileName in cwd.glob('*.eln'): + print(f'Try to parse: {fileName.name}') + with ZipFile(fileName, 'r', compression=ZIP_DEFLATED) as elnFile: + p = ZPath(elnFile) + dirName = sorted(p.iterdir())[0] + try: + dirpath = Path(tempfile.mkdtemp()) + elnFile.extractall(dirpath) + temppath= dirpath.joinpath(dirName.name) + crate = ROCrate(temppath) + print('\nList content according to https://pypi.org/project/rocrate/') + for e in crate.get_entities(): + print(e.id, e.type) + except ValueError: + print("**ERROR: Could not parse content\n"+traceback.format_exc()+'\n\n') + shell: python + +