Compare commits
No commits in common. "master" and "release" have entirely different histories.
@ -3,7 +3,6 @@ Functionality for reading/writing elements (geometry, text labels,
|
|||||||
structure references) and associated properties.
|
structure references) and associated properties.
|
||||||
"""
|
"""
|
||||||
from typing import IO, TypeVar
|
from typing import IO, TypeVar
|
||||||
from collections.abc import Mapping
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ def read_properties(stream: IO[bytes]) -> dict[int, bytes]:
|
|||||||
return properties
|
return properties
|
||||||
|
|
||||||
|
|
||||||
def write_properties(stream: IO[bytes], properties: Mapping[int, bytes]) -> int:
|
def write_properties(stream: IO[bytes], properties: dict[int, bytes]) -> int:
|
||||||
"""
|
"""
|
||||||
Write element properties.
|
Write element properties.
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ class Reference(Element):
|
|||||||
colrow: tuple[int, int] | NDArray[numpy.int16] | None
|
colrow: tuple[int, int] | NDArray[numpy.int16] | None
|
||||||
""" Number of columns and rows (AREF) or None (SREF) """
|
""" Number of columns and rows (AREF) or None (SREF) """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties associated with this reference. """
|
""" Properties associated with this reference. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -230,7 +229,7 @@ class Boundary(Element):
|
|||||||
xy: NDArray[numpy.int32]
|
xy: NDArray[numpy.int32]
|
||||||
""" Ordered vertices of the shape. First and last points should be identical. """
|
""" Ordered vertices of the shape. First and last points should be identical. """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties for the element. """
|
""" Properties for the element. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -276,7 +275,7 @@ class Path(Element):
|
|||||||
xy: NDArray[numpy.int32]
|
xy: NDArray[numpy.int32]
|
||||||
""" Path centerline coordinates """
|
""" Path centerline coordinates """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties for the element. """
|
""" Properties for the element. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -341,7 +340,7 @@ class Box(Element):
|
|||||||
xy: NDArray[numpy.int32]
|
xy: NDArray[numpy.int32]
|
||||||
""" Box coordinates (5 pairs) """
|
""" Box coordinates (5 pairs) """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties for the element. """
|
""" Properties for the element. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -375,7 +374,7 @@ class Node(Element):
|
|||||||
xy: NDArray[numpy.int32]
|
xy: NDArray[numpy.int32]
|
||||||
""" 1-50 pairs of coordinates. """
|
""" 1-50 pairs of coordinates. """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties for the element. """
|
""" Properties for the element. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -435,7 +434,7 @@ class Text(Element):
|
|||||||
string: bytes
|
string: bytes
|
||||||
""" Text content """
|
""" Text content """
|
||||||
|
|
||||||
properties: Mapping[int, bytes]
|
properties: dict[int, bytes]
|
||||||
""" Properties for the element. """
|
""" Properties for the element. """
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -142,7 +142,7 @@ class NoDataRecord(Record[None, None]):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def pack_data(cls: type[Self], data: None) -> bytes:
|
def pack_data(cls: type[Self], data: None) -> bytes:
|
||||||
if data is not None:
|
if data is not None:
|
||||||
raise KlamathError('?? Packing {data!r} into NoDataRecord??')
|
raise KlamathError('?? Packing {data} into NoDataRecord??')
|
||||||
return b''
|
return b''
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ def test_pack_ascii() -> None:
|
|||||||
assert pack_ascii(b'321') == b'321\0'
|
assert pack_ascii(b'321') == b'321\0'
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_date() -> None:
|
def test_invalid_date():
|
||||||
default = [datetime(1900, 1, 1, 0, 0, 0)]
|
default = [datetime(1900, 1, 1, 0, 0, 0)]
|
||||||
assert parse_datetime(pack_int2((0, 0, 0, 0, 0, 0))) == default
|
assert parse_datetime(pack_int2((0, 0, 0, 0, 0, 0))) == default
|
||||||
assert parse_datetime(pack_int2((0, 1, 32, 0, 0, 0))) == default
|
assert parse_datetime(pack_int2((0, 1, 32, 0, 0, 0))) == default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user