Repository navigation
Write the loader's repeated pieces once: log collecting, the check tables, author resolution, record accessors - #144
Merged
Conversation
…bles, author resolution, record accessors "Collect the package logger's records for a block" was written five times: the loader's error counter, two handler classes in the scripts, one in the test fixtures and a stream handler in the test support. One `collecting()` in `load.py` yields a `Collector` with the records, the errors and the warning set; `load` counts from it, the claims script holds and replays through it (the one place that still swaps handlers), the expected-warnings script and the fixtures read it. The per-node integrity checks were listed by hand in three places, so a check added to the loader could be forgotten by the draft checker. `phylohist/loader/checks.py` holds the file, material, nomenclature and draft tables over one per-node scope; `load.py` and `check_draft.py` iterate them, `draft_nulls` moves beside `null_material`, the two `source_year`s become one rule, and a contract test holds the draft's tables to the loader's but for the three checks only a draft needs. The loader's output is unchanged; the drafts' is too. Author keys were resolved by three loops that differed on `et al.` and on a capitalised surname; `resolve_authors` in `research.py` serves the authorities, the sources and the aliases with each one's own wording, and the warning for a capitalised author whose key form is registered now names the record it is on. `implied_rank` and `Authority.qualified_keys` replace the three spellings of "species if lower-case, else genus" and the two key-expectation cores. `load.py` and `claims.py` read the records through accessors (`declared_rank`, `pages`, `illustrations`, `cited_as`, `designation`, `homonym`, `original_parent`, `lang`, `status` on `Taxon`; `author_keys` and `citation_fields` on `Source`) in place of `_data`, and an alias shares its target's record outright. Gone, with no reader: `Source.count` and `title`, `_editors`, the month and day of a publication date, `Tree.is_new`, `bracket_end` and `_type_index`, `Section.notes`, `Authority._ex` and `_disambiguator`. The claims, the names index and the expected warnings are untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
"Collect the package logger's records for a block" was written five times: the loader's error counter, two handler classes in the scripts, one in the test fixtures and a stream handler in the test support. One
collecting()inload.pyyields aCollectorwith the records, the errors and the warning set;loadcounts from it, the claims script holds and replays through it (the one place that still swaps handlers), the expected-warnings script and the fixtures read it.The per-node integrity checks were listed by hand in three places, so a check added to the loader could be forgotten by the draft checker.
phylohist/loader/checks.pyholds the file, material, nomenclature and draft tables over one per-node scope;load.pyandcheck_draft.pyiterate them,draft_nullsmoves besidenull_material, the twosource_years become one rule, and a contract test holds the draft's tables to the loader's but for the three checks only a draft needs. The loader's output is unchanged; the drafts' is too.Author keys were resolved by three loops that differed on
et al.and on a capitalised surname;resolve_authorsinresearch.pyserves the authorities, the sources and the aliases with each one's own wording, and the warning for a capitalised author whose key form is registered now names the record it is on.implied_rankandAuthority.qualified_keysreplace the three spellings of "species if lower-case, else genus" and the two key-expectation cores.load.pyandclaims.pyread the records through accessors (declared_rank,pages,illustrations,cited_as,designation,homonym,original_parent,lang,statusonTaxon;author_keysandcitation_fieldsonSource) in place of_data, and an alias shares its target's record outright. Gone, with no reader:Source.countandtitle,_editors, the month and day of a publication date,Tree.is_new,bracket_endand_type_index,Section.notes,Authority._exand_disambiguator.The claims, the names index and the expected warnings are untouched.