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
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ and the release date, in year-month-day format (see examples below).
Not Yet Released
----------------

Fixed
+++++
* If there was a bare token in the PVL-text (i.e. a parameter with no value assignment),
the returned error message was difficult to understand, should now be clear that
it was looking for an equals sign, and didn't find one (Issue 108).
* Just importing the pvl library would emit the PendingDeprecationWarning about the Units
class, even if a user did not import or instantiate the Units class.
The warn() was not properly issued from the __init__() function, it now is (Issue 109).


1.3.2 (2022-02-05)
------------------
Expand Down
6 changes: 3 additions & 3 deletions docs/quantities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In order to avoid optional dependencies, the ``pvl`` library provides
the :class:`pvl.collections.Quantity` class, implemented as a
:class:`collections.namedtuple` with a ``value`` and a ``unit``
parameter. However, the ``unit`` parameter is just a string and
so the ``pvl`` quantity objects doesn't have the super-powers that
so the ``pvl`` quantity object doesn't have the super-powers that
the ``astropy`` and ``pint`` quntity objects do.

By default, this means that when PVL text is parsed by :func:`pvl.load`
Expand Down Expand Up @@ -191,7 +191,7 @@ would prefer to use those objects. Here is an example::
('length', <Quantity(42, 'meter / second')>)
])
>>> print(type(w_pint['length']))
<class 'pint.quantity.Quantity'>
<class 'pint.util.Quantity'>

Just as with :class:`astropy.units.Quantity`, :class:`pint.Quantity` doesn't recognize
the upper case units, and will raise an error like this::
Expand Down Expand Up @@ -220,7 +220,7 @@ a registry on-the-fly, you must use the registry's Quantity to the
('INT_UNIT', <Quantity(4, 'meter')>)
])
>>> print(type(label['FLOAT_UNIT']))
<class 'pint.quantity.build_quantity_class.<locals>.Quantity'>
<class 'pint.util.Quantity'>

Similarly, :class:`pint.Quantity` objects can be encoded to PVL text
by :func:`pvl.dump` or :func:`pvl.dumps`::
Expand Down
3 changes: 0 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ dependencies:
- bump2version
- cookiecutter
- flake8
- pypy3.6
- python=3.6
- pytest
- pytest-cov
- sphinx
- sphinxcontrib
- sphinxcontrib-apidoc
- sphinxcontrib-autoprogram
- tox
- twine
# These are optional dependencies, and pvl should pass all its tests without them.
- python-dateutil
Expand Down
2 changes: 1 addition & 1 deletion pvl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

__author__ = "The pvl Developers"
__email__ = "rbeyer@rossbeyer.net"
__version__ = "1.3.2"
__version__ = "1.3.3-dev"
__all__ = [
"load",
"loads",
Expand Down
14 changes: 9 additions & 5 deletions pvl/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,12 @@ def __float__(self):


class Units(Quantity):
warnings.warn(
"The pvl.collections.Units object is deprecated, and may be removed at "
"the next major patch. Please use pvl.collections.Quantity instead.",
PendingDeprecationWarning,
)

def __init__(self, *args, **kwargs):
warnings.warn(
"The pvl.collections.Units object is deprecated, and may be "
"removed at the next major patch. Please use "
"pvl.collections.Quantity instead.",
PendingDeprecationWarning,
stacklevel=2
)
19 changes: 13 additions & 6 deletions pvl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ def parse_aggregation_block(self, tokens: abc.Generator): # noqa: C901
present in the End-Aggregation-Statement.
"""
(begin, block_name) = self.parse_begin_aggregation_statement(tokens)
# print(f"parsed begin agg: {begin} {block_name}")

agg = self.aggregation_cls(begin)

while True:
self.parse_WSC_until(None, tokens)
try:
# print("about to see if these tokens can be an agg block.")
agg.append(*self.parse_aggregation_block(tokens))
except LexerError:
raise
Expand All @@ -337,16 +338,21 @@ def parse_aggregation_block(self, tokens: abc.Generator): # noqa: C901
# tokens.send(t)
except LexerError:
raise
except ValueError:
except ValueError as err:
# print(f"Had a ValueError: {err}")
# t = next(tokens)
# print(f'parsing agg block, next token is: {t}')
# tokens.send(t)
if 'Expecting "="' in str(err):
tokens.throw(ValueError, str(err))

try:
self.parse_end_aggregation(begin, block_name, tokens)
break
except LexerError:
raise
except ValueError as ve:
# print(f"In ve: {ve}")
try:
(agg, keep_parsing) = self.parse_module_post_hook(
agg, tokens
Expand Down Expand Up @@ -390,7 +396,7 @@ def parse_begin_aggregation_statement(
the name Block Name as a ``str``.

<Begin-Aggregation-Statement-block> ::=
<Begin-Aggegation-Statement> <WSC>* '=' <WSC>*
<Begin-Aggregation-Statement> <WSC>* '=' <WSC>*
<Block-Name> [<Statement-Delimiter>]

Where <Block-Name> ::= <Parameter-Name>
Expand All @@ -399,15 +405,16 @@ def parse_begin_aggregation_statement(
try:
begin = next(tokens)
if not begin.is_begin_aggregation():
# print(f"{begin} is not a begin aggregation raise ValueError")
tokens.send(begin)
raise ValueError(
"Expecting a Begin-Aggegation-Statement, but "
"Expecting a Begin-Aggregation-Statement, but "
f"found: {begin}"
)
except StopIteration:
raise ValueError(
"Ran out of tokens before starting to parse "
"a Begin-Aggegation-Statement."
"a Begin-Aggregation-Statement."
)

try:
Expand Down Expand Up @@ -623,7 +630,7 @@ def _parse_set_seq(self, delimiters, tokens: abc.Generator) -> list:
tokens.send(t)
tokens.throw(
ValueError,
"While parsing, expected a comma (,)" f'but found: "{t}"',
f'While parsing, expected a comma (,) but found: "{t}"',
)

def parse_set(self, tokens: abc.Generator) -> frozenset:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.3.2
current_version = 1.3.3-dev
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='pvl',
version='1.3.2',
version='1.3.3-dev',
description=(
'Python implementation for PVL (Parameter Value Language) '
'parsing and encoding.'
Expand Down
Loading