Skip to content

Commit 4ad6171

Browse files
authored
Merge branch 'main' into performance-enhancements
2 parents d3d0cd5 + 565ab64 commit 4ad6171

6 files changed

Lines changed: 34 additions & 12 deletions

File tree

.github/workflows/coverage_readme.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ jobs:
5959
run: |
6060
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
6161
62-
- name: Commit & Push changes to README
63-
run: |
64-
git config --global user.name 'github-actions[bot]'
65-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
66-
git add README.md
67-
git commit -m 'Update coverage badge in README'
68-
git push
62+
- name: Commit & Push changes to Readme
63+
if: ${{ github.ref == 'refs/heads/main' }}
64+
uses: actions-js/push@master
65+
with:
66+
message: Update coverage on Readme
67+
github_token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# python-edtf
22

33
<!-- Pytest Coverage Comment:Begin -->
4-
<!-- Pytest Coverage Comment:End -->
4+
\n<!-- Pytest Coverage Comment:End -->
55

66
An implementation of EDTF format in Python, together with utility functions for parsing natural language date texts, and converting EDTF dates to related Python `date` or `struct_time` objects.
77

88
See <http://www.loc.gov/standards/datetime/> for the final draft specification.
99

10-
This project is based on python-edtf and was developed to include the newest specification
11-
1210
## To install
1311

1412
```shell

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
django>=4.2,<5.0
33
pytest
44
pytest-benchmark
5+
pytest-cov
56
pytest-django
67
ruff
78
pre-commit

edtf/parser/parser_classes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ def __init__( # noqa
874874

875875
uas = [
876876
year_ua,
877+
year_ua_b,
877878
month_ua,
878879
day_ua,
879880
year_month_ua,
@@ -902,7 +903,10 @@ def __str__(self) -> str:
902903
else:
903904
y = f"{self.year_ua_b}{self.year}" if self.year_ua_b else str(self.year)
904905

905-
m = f"{self.month_ua}{self.month}" if self.month_ua else str(self.month)
906+
if self.month:
907+
m = f"{self.month_ua}{self.month}" if self.month_ua else str(self.month)
908+
else:
909+
m = None
906910

907911
if self.day:
908912
d = f"{self.day_ua}{self.day}" if self.day_ua else str(self.day)
@@ -918,7 +922,12 @@ def __str__(self) -> str:
918922
else:
919923
result = f"{y}-({m}-{d}){self.month_day_ua}"
920924
else:
921-
result = f"{y}-{m}-{d}" if d else f"{y}-{m}"
925+
if d:
926+
result = f"{y}-{m}-{d}"
927+
elif m:
928+
result = f"{y}-{m}"
929+
else:
930+
result = y
922931

923932
if self.all_ua:
924933
result = f"({result}){self.all_ua}"

edtf/parser/tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,18 @@
257257
("2011-~06-~04", (False, True, False)),
258258
("2004-06-~01/2004-06-~20", (False, True, False)),
259259
("156X~", (False, True, False)),
260+
("?1945/1959", (True, False, False)),
261+
("?1945", (True, False, False)),
262+
("?1945-01", (True, False, False)),
263+
("?1945-01-01", (True, False, False)),
264+
("~1945/1959", (False, True, False)),
265+
("~1945", (False, True, False)),
266+
("~1945-01", (False, True, False)),
267+
("~1945-01-01", (False, True, False)),
268+
("%1945/1959", (False, False, True)),
269+
("%1945", (False, False, True)),
270+
("%1945-01", (False, False, True)),
271+
("%1945-01-01", (False, False, True)),
260272
)
261273

262274
BAD_EXAMPLES = (

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ classifiers = [
3636
"Programming Language :: Python :: 3.10",
3737
"Programming Language :: Python :: 3.11",
3838
"Programming Language :: Python :: 3.12",
39+
"Programming Language :: Python :: 3.13",
3940
]
4041

4142
[project.optional-dependencies]
@@ -147,4 +148,6 @@ ignore = [
147148
"E501",
148149
# Ignore McCabe complexity (for now).
149150
"C901",
151+
# Ignore percent format -> format specifier rule for now (pending merge of #73 which resolves them)
152+
"UP031",
150153
]

0 commit comments

Comments
 (0)