From 306d20f7c8ba1cf78972ef7e070c29ff8ec49d47 Mon Sep 17 00:00:00 2001 From: Robert French Date: Tue, 25 Nov 2025 17:01:15 -0800 Subject: [PATCH 1/2] Add FCPath support --- .github/workflows/run-tests.yml | 2 +- README.md | 2 ++ pyproject.toml | 4 ++-- requirements.txt | 1 + textkernel/__init__.py | 8 +++++--- 5 files changed, 11 insertions(+), 6 deletions(-) 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..7f9c328 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='latin8') return from_text(text, tkdict=tkdict, commented=True, contin=contin) From 484555dbe752db46129613a4385e668012425a16 Mon Sep 17 00:00:00 2001 From: Robert French Date: Tue, 2 Dec 2025 11:21:33 -0800 Subject: [PATCH 2/2] Fix latin1 encoding --- textkernel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textkernel/__init__.py b/textkernel/__init__.py index 7f9c328..2781b9d 100644 --- a/textkernel/__init__.py +++ b/textkernel/__init__.py @@ -374,7 +374,7 @@ def from_file(path, tkdict=None, *, contin=''): ID. """ - text = filecache.FCPath(path).read_text(encoding='latin8') + text = filecache.FCPath(path).read_text(encoding='latin1') return from_text(text, tkdict=tkdict, commented=True, contin=contin)