Skip to content

Commit 99b7d82

Browse files
committed
Rename reading subpackage to deserialization
1 parent 657ea44 commit 99b7d82

4 files changed

Lines changed: 28 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
## 0.11.0 (unreleased)
55

6+
- Renamed `reading` subpackage to `deserialization`, and adjusted function
7+
names.
8+
69
- Renamed `writing` subpackage to `serialization`.
710

811
- Implemented serialization of series.
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
lanpartydb.reading
3-
~~~~~~~~~~~~~~~~~~
2+
lanpartydb.deserialization
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~
44
5-
Data reading
5+
TOML deserialization to objects
66
77
:Copyright: 2024-2025 Jochen Kupperschmidt
88
:License: MIT
@@ -19,40 +19,40 @@
1919
# series
2020

2121

22-
def read_series_list_from_toml_file(filename: Path) -> list[Series]:
23-
"""Read list of series from a TOML file."""
22+
def deserialize_series_list_from_toml_file(filename: Path) -> list[Series]:
23+
"""Deserialize list of series from a TOML file."""
2424
toml = filename.read_text()
25-
return read_series_list_from_toml(toml)
25+
return deserialize_series_list(toml)
2626

2727

28-
def read_series_list_from_toml(toml: str) -> list[Series]:
29-
"""Read list of series from a TOML document."""
28+
def deserialize_series_list(toml: str) -> list[Series]:
29+
"""Deserialize list of series from a TOML document."""
3030
data = _load_toml(toml)
31-
return _read_series_list_from_dict(data)
31+
return _deserialize_series_list_from_dict(data)
3232

3333

34-
def _read_series_list_from_dict(data: dict[str, Any]) -> list[Series]:
35-
"""Read list of series from a dictionary."""
34+
def _deserialize_series_list_from_dict(data: dict[str, Any]) -> list[Series]:
35+
"""Build list of series from a dictionary."""
3636
return [Series(**item) for item in data.get('series', [])]
3737

3838

3939
# party
4040

4141

42-
def read_party_from_toml_file(filename: Path) -> Party:
43-
"""Read party from a TOML file."""
42+
def deserialize_party_from_toml_file(filename: Path) -> Party:
43+
"""Deserialize party from a TOML file."""
4444
toml = filename.read_text()
45-
return read_party_from_toml(toml)
45+
return deserialize_party(toml)
4646

4747

48-
def read_party_from_toml(toml: str) -> Party:
49-
"""Read party from a TOML document."""
48+
def deserialize_party(toml: str) -> Party:
49+
"""Deserialize party from a TOML document."""
5050
data = _load_toml(toml)
51-
return _read_party_from_dict(data)
51+
return _deserialize_party_from_dict(data)
5252

5353

54-
def _read_party_from_dict(party_dict: dict[str, Any]) -> Party:
55-
"""Read party from a dictionary."""
54+
def _deserialize_party_from_dict(party_dict: dict[str, Any]) -> Party:
55+
"""Build party from a dictionary."""
5656
location_dict = party_dict.pop('location', None)
5757
if location_dict:
5858
party_dict['location'] = Location(**location_dict)

tests/reading/test_read_party_from_toml.py renamed to tests/deserialization/test_deserialize_party.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import pytest
1010

11+
from lanpartydb.deserialization import deserialize_party
1112
from lanpartydb.models import Location, Party, PartyLinks, Resource
12-
from lanpartydb.reading import read_party_from_toml
1313

1414

1515
@pytest.mark.parametrize(
@@ -88,5 +88,5 @@
8888
),
8989
],
9090
)
91-
def test_read_party_from_toml(toml: str, expected: Party):
92-
assert read_party_from_toml(toml) == expected
91+
def test_deserialize_party(toml: str, expected: Party):
92+
assert deserialize_party(toml) == expected

tests/reading/test_read_series_list_from_toml.py renamed to tests/deserialization/test_deserialize_series_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import pytest
77

8+
from lanpartydb.deserialization import deserialize_series_list
89
from lanpartydb.models import Series
9-
from lanpartydb.reading import read_series_list_from_toml
1010

1111

1212
@pytest.mark.parametrize(
@@ -62,5 +62,5 @@
6262
),
6363
],
6464
)
65-
def test_read_series_list_from_toml(toml: str, expected: list[Series]):
66-
assert read_series_list_from_toml(toml) == expected
65+
def test_deserialize_series_list(toml: str, expected: list[Series]):
66+
assert deserialize_series_list(toml) == expected

0 commit comments

Comments
 (0)