diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c8dc292..a6e13d3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] fail-fast: false steps: - name: Checkout diff --git a/README.md b/README.md index 0a72514..8368638 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ import textkernel tkdict = textkernel.from_file('path/to/kernel/file') ``` +(The file path can be any URL accepted by [`FCPath`](https://rms-filecache.readthedocs.io/en/latest/module.html#filecache.file_cache_path.FCPath).) + The returned dictionary `tkdict` is keyed by all the parameter names (on the left side of an equal sign) in the text kernel, and each associated dictionary value is that found on the right side. Values are Python ints, floats, strings, datetime objects, or lists of diff --git a/pyproject.toml b/pyproject.toml index 13f3026..cfc8dcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,10 +7,11 @@ name = "rms-textkernel" dynamic = ["version"] description = "Routines for parsing SPICE text kernels" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ "numpy", "pyparsing", + "rms-filecache", "rms-julian" ] license = {text = "Apache-2.0"} @@ -27,7 +28,6 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/requirements.txt b/requirements.txt index ec14ea2..14bb4e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ myst-parser numpy pyparsing pytest +rms-filecache rms-julian sphinx sphinxcontrib-napoleon diff --git a/textkernel/__init__.py b/textkernel/__init__.py index 2e0ba6d..2781b9d 100644 --- a/textkernel/__init__.py +++ b/textkernel/__init__.py @@ -23,9 +23,10 @@ __all__ = ['from_text', 'from_file', 'continued_value', 'update_dict'] -import pathlib import re +import filecache + from textkernel._DATA_GRAMMAR import _DATA_GRAMMAR from textkernel._NAME_GRAMMAR import _NAME_GRAMMAR from textkernel._PREDEFINED_BODY_INFO import _PREDEFINED_BODY_INFO @@ -306,7 +307,8 @@ def from_file(path, tkdict=None, *, contin=''): Parse the contents of a text kernel, returning a dict of the values found. Args: - path (str or Path): The path to a kernel file as a string or `pathlib.Path`. + path (str or Path or FCPath): The path to a kernel file as a string, + `pathlib.Path`, or `filecache.FCPath`. tkdict (dict, optional): An optional starting dictionary. If provided, the new content is merged into the one provided; otherwise, a new dictionary is returned. @@ -372,7 +374,7 @@ def from_file(path, tkdict=None, *, contin=''): ID. """ - text = pathlib.Path(path).read_text(encoding='latin8') + text = filecache.FCPath(path).read_text(encoding='latin1') return from_text(text, tkdict=tkdict, commented=True, contin=contin)