Skip to content

Commit f332f46

Browse files
committed
2 parents 2af3059 + 3afcd69 commit f332f46

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1+
root = true
2+
13
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
210
max_line_length = 120
11+
tab_width = 4
12+
13+
[{*.cfg, *.ini, *.html, *.yaml, *.yml}]
14+
indent_size = 2
15+
16+
[*.json]
17+
indent_size = 2
18+
insert_final_newline = true
19+
20+
# trailing spaces in markdown indicate word wrap
21+
[*.md]
22+
trim_trailing_whitespace = false
23+
24+
[*.py]
25+
multi_line_output = 3
26+
include_trailing_comma = True
27+
force_grid_wrap = 0
28+
use_parentheses = True
29+
ensure_newline_before_comments = True

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ repos:
1616
- id: black
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.11.13
19+
rev: v0.12.7
2020
hooks:
2121
- args:
2222
- --fix
2323
- --exit-non-zero-on-fix
2424
id: ruff-check
2525

2626
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
27-
rev: v0.7.0
27+
rev: v0.8.0
2828
hooks:
2929
- id: pre-commit-update
3030

README-DEV.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ To run a test with profiling:
1616
pytest --profile-svg -k test_page_info
1717
```
1818

19+
To directly test the CLIs using our test data, run:
20+
21+
```
22+
mods4pandas src/mods4pandas/tests/data/mets-mods
23+
alto4pandas src/mods4pandas/tests/data/alto
24+
```
25+
26+
1927
# How to use pre-commit
2028

2129
This project optionally uses [pre-commit](https://pre-commit.com) to check commits. To use it:

src/mods4pandas/mods4pandas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ def get_mets_file(*, ID):
449449
def get_mets_div(*, ID):
450450
if ID:
451451
return structMap_LOGICAL.findall(f'.//mets:div[@ID="{ID}"]', ns)
452+
else:
453+
return []
452454

453455
for page in div_physSequence:
454456
# TODO sort by ORDER?
@@ -591,6 +593,8 @@ def process(mets_files: list[str], output_file: str, output_page_info: str, mets
591593
with contextlib.suppress(FileNotFoundError):
592594
os.remove(output_page_info_sqlite3)
593595
con_page_info = sqlite3.connect(output_page_info_sqlite3)
596+
else:
597+
con_page_info = None
594598

595599
# Process METS files
596600
with open(output_file + ".warnings.csv", "w") as csvfile:

src/mods4pandas/tests/test_alto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def check_types(df):
135135
assert dt == edt, f"Unexpected dtype {dt} for column {c} (expected {edt})"
136136

137137
if edt == "object":
138+
assert einner_types is not None
138139
inner_types = set(type(v).__name__ for v in df[c])
139140
assert all(
140141
it in einner_types for it in inner_types

src/mods4pandas/tests/test_mods4pandas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def test_originInfo_no_event_type():
153153
assert d == {} # empty
154154

155155
assert len(ws) == 1
156+
assert isinstance(ws[0].message, Warning)
156157
assert (
157158
ws[0].message.args[0]
158159
== "Filtered {http://www.loc.gov/mods/v3}originInfo element (has no eventType)"

0 commit comments

Comments
 (0)