Skip to content

Commit

Permalink
Add HPM Alalakh to Fragment External Numbers (#521)
Browse files Browse the repository at this point in the history
* Bump cryptography from 41.0.6 to 42.0.0 (#518)

Bumps [cryptography](https://github.com/pyca/cryptography) from 41.0.6 to 42.0.0.
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](pyca/cryptography@41.0.6...42.0.0)

---
updated-dependencies:
- dependency-name: cryptography
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pillow from 10.0.1 to 10.2.0 (#509)

Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.0.1 to 10.2.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](python-pillow/Pillow@10.0.1...10.2.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pycryptodomex from 3.18.0 to 3.19.1 (#505)

Bumps [pycryptodomex](https://github.com/Legrandin/pycryptodome) from 3.18.0 to 3.19.1.
- [Release notes](https://github.com/Legrandin/pycryptodome/releases)
- [Changelog](https://github.com/Legrandin/pycryptodome/blob/master/Changelog.rst)
- [Commits](Legrandin/pycryptodome@v3.18.0...v3.19.1)

---
updated-dependencies:
- dependency-name: pycryptodomex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Date fixes (#510)

* Implement date

* Fix Seleucid issue

* Date paleography

* 'Refactored by Sourcery' (#444)

Co-authored-by: Sourcery AI <>

* Update test

* Implement date deleting

* Format

* Implement dates in text

* Add tests

* Implement eponyms

* Extend eponym

* Add `broken` & `uncertain` to king and eponym

* Update url

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Update king schema (#520)

* Update kings schema

* Update tests

* Remove unused

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ilya Khait <[email protected]>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 14, 2024
1 parent 6c34e11 commit 45aa8e0
Show file tree
Hide file tree
Showing 8 changed files with 3,868 additions and 3,776 deletions.
7,296 changes: 3,654 additions & 3,642 deletions ebl/chronology/brinkmanKings.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions ebl/chronology/chronology.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class King:
date: str
total_of_years: str
notes: str
is_not_in_brinkman: Optional[bool]


@attr.s(auto_attribs=True, frozen=True)
Expand All @@ -40,6 +41,9 @@ class KingSchema(Schema):
date = fields.String()
total_of_years = fields.String(data_key="totalOfYears")
notes = fields.String(allow_none=True, load_default=None)
is_not_in_brinkman = fields.Boolean(
allow_none=True, load_default=None, data_key="isNotInBrinkman"
)

@post_load
def make_king(self, data: dict, **kwargs) -> King:
Expand Down
42 changes: 38 additions & 4 deletions ebl/fragmentarium/domain/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@ class Day:
is_uncertain: Optional[bool] = attr.ib(default=None)


@attr.s(auto_attribs=True)
class DateKing(King):
is_broken: Optional[bool] = attr.ib(default=None)
is_uncertain: Optional[bool] = attr.ib(default=None)


@attr.s(auto_attribs=True)
class DateEponym(Eponym):
is_broken: Optional[bool] = attr.ib(default=None)
is_uncertain: Optional[bool] = attr.ib(default=None)


@attr.s(auto_attribs=True, frozen=True)
class Date:
year: Year
month: Month
day: Day
king: Optional[King] = attr.ib(default=None)
eponym: Optional[Eponym] = attr.ib(default=None)
king: Optional[DateKing] = attr.ib(default=None)
eponym: Optional[DateEponym] = attr.ib(default=None)
is_seleucid_era: Optional[bool] = attr.ib(default=None)
is_assyrian_date: Optional[bool] = attr.ib(default=None)
ur3_calendar: Ur3Calendar = attr.ib(default=Ur3Calendar.NONE)
Expand Down Expand Up @@ -85,15 +97,37 @@ def make_day(self, data, **kwargs) -> Day:
return Day(**data)


class DateKingSchema(KingSchema):
is_broken = fields.Boolean(data_key="isBroken", allow_none=True)
is_uncertain = fields.Boolean(data_key="isUncertain", allow_none=True)

@post_load
def make_king(self, data: dict, **kwargs) -> DateKing:
return DateKing(**data)

@post_dump
def remove_skip_values(self, data: dict, **kwargs):
return {key: value for key, value in data.items() if value is not None}


class DateEponymSchema(EponymSchema):
is_broken = fields.Boolean(data_key="isBroken", allow_none=True)
is_uncertain = fields.Boolean(data_key="isUncertain", allow_none=True)

@post_load
def make_eponym(self, data: dict, **kwargs) -> DateEponym:
return DateEponym(**data)


class DateSchema(Schema):
class Meta:
unknown = EXCLUDE

year = fields.Nested(YearSchema())
month = fields.Nested(MonthSchema())
day = fields.Nested(DaySchema())
king = fields.Nested(KingSchema(), allow_none=True)
eponym = fields.Nested(EponymSchema(), allow_none=True)
king = fields.Nested(DateKingSchema(), allow_none=True)
eponym = fields.Nested(DateEponymSchema(), allow_none=True)
is_assyrian_date = fields.Boolean(data_key="isAssyrianDate", allow_none=True)
is_seleucid_era = fields.Boolean(data_key="isSeleucidEra", allow_none=True)
ur3_calendar = ValueEnumField(Ur3Calendar, data_key="ur3Calendar", allow_none=True)
Expand Down
2 changes: 1 addition & 1 deletion ebl/fragmentarium/web/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def create_fragmentarium_routes(api: falcon.App, context: Context):
("/fragments/{number}/genres", fragment_genre),
("/fragments/{number}/script", fragment_script),
("/fragments/{number}/date", fragment_date),
("/fragments/{number}/dates_in_text", fragment_dates_in_text),
("/fragments/{number}/dates-in-text", fragment_dates_in_text),
("/fragments/{number}", fragments),
("/fragments/{number}/pager", fragment_pager),
("/fragments/{number}/lemmatization", lemmatization),
Expand Down
18 changes: 9 additions & 9 deletions ebl/tests/chronology/test_chronology.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def test_king_creation():
king = King(
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes"
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes", None
)

assert king.order_global == 1
Expand All @@ -20,10 +20,10 @@ def test_king_creation():

def test_chronology_creation():
king_a = King(
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes"
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes", None
)
king_b = King(
2, 2, "dyn2", "Dynasty 2", "2", "King B", "2000", "5 years", "Other notes"
2, 2, "dyn2", "Dynasty 2", "2", "King B", "2000", "5 years", "Other notes", True
)
chronology = Chronology([king_a, king_b])

Expand All @@ -32,10 +32,10 @@ def test_chronology_creation():

def test_find_king_by_name():
king_a = King(
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes"
1, 2, "dyn1", "Dynasty 1", "1", "King A", "1999", "10 years", "Some notes", None
)
king_b = King(
2, 2, "dyn2", "Dynasty 2", "2", "King B", "2000", "5 years", "Other notes"
2, 2, "dyn2", "Dynasty 2", "2", "King B", "2000", "5 years", "Other notes", True
)
chronology = Chronology([king_a, king_b])

Expand Down Expand Up @@ -73,8 +73,8 @@ def test_chronology_schema_deserialization():
with open("ebl/chronology/brinkmanKings.json", "r", encoding="utf-8") as file:
data = json.load(file)
chronology = ChronologySchema().load({"kings": data})
assert len(chronology.kings) == 364
assert len(chronology.kings) == 365
assert chronology.kings[0].name == "Sargon"
assert chronology.kings[363].name == "Aššur-uballiṭ II"
assert chronology.kings[50].order_global == 51
assert chronology.kings[363].order_global == 364
assert chronology.kings[363].name == "Sin-šar-iškun"
assert chronology.kings[50].order_global == 50
assert chronology.kings[363].order_global == 363
18 changes: 16 additions & 2 deletions ebl/tests/factories/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@
Year,
Month,
Day,
DateKing,
DateKingSchema,
Ur3Calendar,
)
from ebl.chronology.chronology import chronology
from ebl.chronology.chronology import chronology, King, KingSchema


class JoinFactory(factory.Factory):
Expand Down Expand Up @@ -144,14 +146,26 @@ class Meta:
is_uncertain = factory.Faker("boolean")


def create_date_king(king: King) -> DateKing:
return DateKingSchema().load(
{
**KingSchema().dump(king),
"isBroken": random.choice([True, False]),
"isUncertain": random.choice([True, False]),
}
)


class DateFactory(factory.Factory):
class Meta:
model = Date

year = factory.SubFactory(YearFactory)
month = factory.SubFactory(MonthFactory)
day = factory.SubFactory(DayFactory)
king = factory.Iterator(chronology.kings)
king = factory.Iterator(
chronology.kings, getter=lambda king: create_date_king(king)
)
is_seleucid_era = factory.Faker("boolean")
ur3_calendar = factory.Iterator(Ur3Calendar)

Expand Down
4 changes: 2 additions & 2 deletions ebl/tests/fragmentarium/test_dates_in_text_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_update_date(client, fragmentarium, user, currentDate, updatedDate):
fragment_number = fragmentarium.create(fragment)
update = {"datesInText": [DateSchema().dump(updatedDate)]}
post_result = client.simulate_post(
f"/fragments/{fragment_number}/dates_in_text",
f"/fragments/{fragment_number}/dates-in-text",
body=json.dumps(update) if updatedDate else '{"datesInText": []}',
)
expected_json = create_response_dto(
Expand All @@ -64,7 +64,7 @@ def test_update_invalid_dates_in_text(client, fragmentarium, user, database):
updates = {"datesInText": ["nonsense date"]}

post_result = client.simulate_post(
f"/fragments/{fragment_number}/dates_in_text", body=json.dumps(updates)
f"/fragments/{fragment_number}/dates-in-text", body=json.dumps(updates)
)

expected_json = {
Expand Down
Loading

0 comments on commit 45aa8e0

Please sign in to comment.