Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"cryptography>=42",
"gunicorn>=25.2.0",
"mako>=1.3.10",
"pyconfig>=3.2.3,<3.3.0",
"pyconfig>=3.3.0",
"pydantic>=2.8",
"pyramid>=2.0.2",
"pytz>=2025.2",
Expand All @@ -34,7 +34,6 @@ dependencies = [
"requests>=2.32.3",
"requests-cache==1.2.1",
"requests-file==2.1.0",
"setuptools>=78.1.1,<81",
"str2bool>=1.1",
"whoosh>=2.7.4",
"wsgi-intercept>=1.13.1",
Expand Down
6 changes: 2 additions & 4 deletions src/pyff/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import tempfile
from unittest import TestCase

from pyff import __version__ as pyffversion

# range of ports where available ports can be found
PORT_RANGE = [33000, 60000]

Expand Down Expand Up @@ -52,13 +50,13 @@ def run_cmdline(script, *args):
import sys
import coverage
import os
from pkg_resources import load_entry_point
from importlib.metadata import distribution
if __name__ == '__main__':
cov = coverage.coverage(cover_pylib=False, source=['pyff'], omit=['test'])
cov.start()
rv = 0
try:
rv = load_entry_point('pyFF=={pyffversion}', 'console_scripts', '{script}')()
rv = distribution('pyFF').entry_points.select(group='console_scripts', name='{script}')['{script}'].load()()
except Exception as ex:
raise ex
finally:
Expand Down
23 changes: 13 additions & 10 deletions src/pyff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
from datetime import datetime, timedelta, timezone
from email.utils import parsedate
from itertools import chain
from pathlib import Path
from threading import local
from time import gmtime, strftime
from typing import Any, BinaryIO, Callable, Optional, Union
from urllib.parse import urlparse

import pkg_resources
import pybergshamra
import requests
from apscheduler.executors.pool import ThreadPoolExecutor
Expand Down Expand Up @@ -66,6 +66,9 @@

log = get_log(__name__)

# Directory holding the files distributed with the package (XSLT, XSD, ...).
PACKAGE_DIR = Path(__file__).resolve().parent

thread_data = local()


Expand Down Expand Up @@ -119,10 +122,10 @@ def resource_string(name: str, pfx: Optional[str] = None) -> Optional[Union[str,
elif pfx and os.path.exists(os.path.join(pfx, name)):
with open(os.path.join(pfx, name)) as fd:
data = fd.read()
elif pkg_resources.resource_exists(__name__, name):
data = pkg_resources.resource_string(__name__, name)
elif pfx and pkg_resources.resource_exists(__name__, f"{pfx}/{name}"):
data = pkg_resources.resource_string(__name__, f"{pfx}/{name}")
elif (PACKAGE_DIR / name).exists():
data = (PACKAGE_DIR / name).read_bytes()
elif pfx and (PACKAGE_DIR / pfx / name).exists():
data = (PACKAGE_DIR / pfx / name).read_bytes()

return data

Expand All @@ -148,10 +151,10 @@ def resource_filename(name, pfx=None):
return name
elif pfx and os.path.exists(os.path.join(pfx, name)):
return os.path.join(pfx, name)
elif pkg_resources.resource_exists(__name__, name):
return pkg_resources.resource_filename(__name__, name)
elif pfx and pkg_resources.resource_exists(__name__, f"{pfx}/{name}"):
return pkg_resources.resource_filename(__name__, f"{pfx}/{name}")
elif (PACKAGE_DIR / name).exists():
return str(PACKAGE_DIR / name)
elif pfx and (PACKAGE_DIR / pfx / name).exists():
return str(PACKAGE_DIR / pfx / name)

return None

Expand Down Expand Up @@ -234,7 +237,7 @@ def schema():
# "geo:lat, lon", "mailto: user@host"). Strict/spec XSD rejects those
# per RFC 3987, which would wrongly drop large numbers of otherwise
# valid entities; lenient mode accepts them exactly as lxml did.
schema_path = pkg_resources.resource_filename(__name__, "schema/schema.xsd")
schema_path = str(PACKAGE_DIR / "schema" / "schema.xsd")
thread_data.schema = etree.XMLSchema(file=schema_path, lenient=True)
except etree.XMLSchemaParseError as ex:
traceback.print_exc()
Expand Down
12 changes: 5 additions & 7 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading