def __init__(self, raw_address, allow_international_letters=False): self.raw_address = raw_address self.allow_international_letters = allow_international_letters self._lines = [ remove_whitespace_before_punctuation(line.rstrip(' ,')) for line in normalise_lines(self.raw_address) if line.rstrip(' ,') ] or [''] try: self.country = Country(self._lines[-1]) self._lines_without_country = self._lines[:-1] except CountryNotFoundError: self._lines_without_country = self._lines self.country = country_UK
def test_removing_whitespace_before_full_stops(dirty, clean): assert remove_whitespace_before_punctuation(dirty) == clean
def _lines(self): return [ remove_whitespace_before_punctuation(line) for line in normalise_lines(self.raw_address) if line ] or ['']