Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ myst-parser
numpy
pyparsing
pytest
rms-filecache
rms-julian
sphinx
sphinxcontrib-napoleon
Expand Down
8 changes: 5 additions & 3 deletions textkernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)


Expand Down