Skip to content

Commit

Permalink
Merge pull request #224 from tristan-ranff/master
Browse files Browse the repository at this point in the history
use importlib for compatibility with python 3.12
  • Loading branch information
whitews authored Nov 5, 2024
2 parents cd649f1 + a37e7f2 commit 385236a
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/flowkit/_resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
"""
Contains non-code resources used in FlowKit
"""
from pkg_resources import resource_filename

from importlib import resources
from lxml import etree
import os
import pathlib

resource_path = resource_filename('flowkit', '_resources')
# force POSIX-style path, even on Windows
resource_path = pathlib.Path(resource_path).as_posix()
resource_dir = resources.files("flowkit")
xsd_file = resource_dir / "_resources" / "Gating-ML.v2.0.xsd"

# We used to edit the import paths for Transformations & DataTypes,
# but it still caused an XMLSchemaParseError when FlowKit was
# installed in a location where the path contained "special"
# characters (i.e. accented letters). Instead, we now change
# directories temporarily to the XSD location, read in the files,
# and then change back to the original CWD.
orig_dir = os.getcwd()
os.chdir(resource_path)
gml_tree = etree.parse('Gating-ML.v2.0.xsd')
with xsd_file.open("rb") as file:
gml_tree = etree.parse(file)
gml_schema = etree.XMLSchema(gml_tree)
os.chdir(orig_dir)

0 comments on commit 385236a

Please sign in to comment.