def parse_address_or_bbl_or_bin(self, value: str) -> str:
        if BBL.safe_parse(value) or is_bin(value):
            return value
        features = geocoding.search(value)
        if not features:
            raise CommandError("Address not found!")

        props = features[0].properties
        self.stdout.write(f"Found BBL {props.pad_bbl} / BIN {props.pad_bin} ({props.label}).")
        self.stdout.write(
            f"Using the BIN (call this command separately with the BBL to use that instead)."
        )
        return props.pad_bin
Beispiel #2
0
 def test_parse_raises_err_when_input_is_too_long(self):
     with pytest.raises(ValueError, match="string should be 10 digits"):
         BBL.parse("12319832518932598")
Beispiel #3
0
 def test_safe_parse_works(self):
     assert BBL.safe_parse('') is None
     assert BBL.safe_parse('91832589132598132958') is None
     assert BBL.safe_parse('2022150116') == BBL(2, 2215, 116)
Beispiel #4
0
 def from_pad_bbl(self, pad_bbl: str):
     bbl = BBL.parse(pad_bbl)
     return self.filter(boroid=bbl.boro, block=bbl.block, lot=bbl.lot)
Beispiel #5
0
 def test_safe_parse_works(self):
     assert BBL.safe_parse("") is None
     assert BBL.safe_parse("91832589132598132958") is None
     assert BBL.safe_parse("2022150116") == BBL(2, 2215, 116)