Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _apply(self, value):
# Lazy-load dependencies to reduce memory usage when this
# filter is not used in a project.
from iso3166 import (
countries_by_alpha2,
countries_by_alpha3,
Country as CountryType,
)
value = self._filter(value, Type(string_types + (CountryType,)))
if self._has_errors:
return None
if isinstance(value, CountryType):
return value
search_functions = {
2: countries_by_alpha2,
3: countries_by_alpha3,
}
try:
return search_functions[len(value)][value.upper()]
except KeyError:
return self._invalid_value(value, self.CODE_INVALID, exc_info=True)
from ...icon_constant import PRepGrade, PRepStatus, PenaltyReason, Revision, PRepFlag
from ...utils.msgpack_for_db import MsgPackForDB
if TYPE_CHECKING:
from iconservice.base.address import Address
class PRepDictType(Enum):
FULL = auto() # getPRep
ABRIDGED = auto() # getPReps
class PRep(Sortable):
PREFIX: bytes = b"prep"
_VERSION: int = 2
_UNKNOWN_COUNTRY = iso3166.Country("Unknown", "ZZ", "ZZZ", "000", "Unknown")
class Index(IntEnum):
VERSION = 0
# Version: 0
ADDRESS = auto()
STATUS = auto()
GRADE = auto()
NAME = auto()
COUNTRY = auto()
CITY = auto()
EMAIL = auto()
WEBSITE = auto()
DETAILS = auto()
P2P_ENDPOINT = auto()
IREP = auto()
def _apply(self, value):
# Lazy-load dependencies to reduce memory usage when this
# filter is not used in a project.
from iso3166 import (
countries_by_alpha2,
countries_by_alpha3,
Country as CountryType,
)
value = self._filter(value, Type(string_types + (CountryType,)))
if self._has_errors:
return None
if isinstance(value, CountryType):
return value
search_functions = {
2: countries_by_alpha2,
3: countries_by_alpha3,
}
try:
return search_functions[len(value)][value.upper()]
except KeyError:
return self._invalid_value(value, self.CODE_INVALID, exc_info=True)