X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c314a3092c5b51c7782015f6fa9ac093b46fa174..7c9002cae7f950a99f3045d3058ed61ef79fe044:/src/nominatim_db/data/postcode_format.py?ds=sidebyside diff --git a/src/nominatim_db/data/postcode_format.py b/src/nominatim_db/data/postcode_format.py index 0d04826d..0e6635f9 100644 --- a/src/nominatim_db/data/postcode_format.py +++ b/src/nominatim_db/data/postcode_format.py @@ -14,6 +14,7 @@ import re from ..errors import UsageError from . import country_info + class CountryPostcodeMatcher: """ Matches and formats a postcode according to a format definition of the given country. @@ -30,7 +31,6 @@ class CountryPostcodeMatcher: self.output = config.get('output', r'\g<0>') - def match(self, postcode: str) -> Optional[Match[str]]: """ Match the given postcode against the postcode pattern for this matcher. Returns a `re.Match` object if the match was successful @@ -44,7 +44,6 @@ class CountryPostcodeMatcher: return None - def normalize(self, match: Match[str]) -> str: """ Return the default format of the postcode for the given match. `match` must be a `re.Match` object previously returned by @@ -71,14 +70,12 @@ class PostcodeFormatter: else: raise UsageError(f"Invalid entry 'postcode' for country '{ccode}'") - def set_default_pattern(self, pattern: str) -> None: """ Set the postcode match pattern to use, when a country does not have a specific pattern. """ self.default_matcher = CountryPostcodeMatcher('', {'pattern': pattern}) - def get_matcher(self, country_code: Optional[str]) -> Optional[CountryPostcodeMatcher]: """ Return the CountryPostcodeMatcher for the given country. Returns None if the country doesn't have a postcode and the @@ -92,7 +89,6 @@ class PostcodeFormatter: return self.country_matcher.get(country_code, self.default_matcher) - def match(self, country_code: Optional[str], postcode: str) -> Optional[Match[str]]: """ Match the given postcode against the postcode pattern for this matcher. Returns a `re.Match` object if the country has a pattern @@ -105,7 +101,6 @@ class PostcodeFormatter: return self.country_matcher.get(country_code, self.default_matcher).match(postcode) - def normalize(self, country_code: str, match: Match[str]) -> str: """ Return the default format of the postcode for the given match. `match` must be a `re.Match` object previously returned by