Repository navigation
fix(gloucester): handle communal bin cards that start with a line break - #2331
coredev-uk wants to merge 1 commit into
Conversation
Communal recycling cards prefix the bin-type <div> with a <br/>, so div:nth-child(1) matched nothing and parsing crashed with "'NoneType' object has no attribute 'children'". Take the card's first <div> child instead, wherever it sits.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Problem
Gloucester City Council fails for properties with communal bins:
Example: Flat 1, Britannia Warehouse, The Docks, GL1 2EH (UPRN
10007323976).The parser read the bin type with
select_one("div:nth-child(1)"). That only matches a<div>that is the container's first child. Communal recycling cards put a<br/>before the bin-type<div>:So nothing matched,
select_onereturnedNone, and.childrenraised. The first communal card (Communal household waste) has no leading<br/>, so it parses fine. The crash comes from the recycling cards after it.Fix
Use the container's first direct
<div>child, wherever it sits (find("div", recursive=False)), and take its first non-empty string as the bin type. If no type is found, the card is skipped, same as before.Verification
Ran live against the council site with headless Chrome:
AttributeErrorinput.jsonfixture, kerbside)Other communal flats I checked (GL1 3NE, GL1 2DJ) crashed the same way before the fix and parse after it. Kerbside flats in GL2 5AJ give the same output before and after.
Summary by CodeRabbit