Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class IPAddressResult(Result):
"""Pull IPv4, IPv6 - and validate using on-board Python tools."""
category = ExtractedEntity.IPADDRESS
def __init__(self, ctx, label, start, end):
super(IPAddressResult, self).__init__(ctx, label, start, end)
try:
ip = ip_address(label)
self.key = self.label = str(ip)
except ValueError:
self.valid = False
class EmailResult(Result):
category = ExtractedEntity.EMAIL
def __init__(self, ctx, label, start, end):
super(EmailResult, self).__init__(ctx, label, start, end)
self.key = self.label_key(self.label)
self.valid = self.key is not None
# TODO: do we want to do TLD -> country?
class PhoneResult(Result):
FORMAT = phonenumbers.PhoneNumberFormat.E164
category = ExtractedEntity.PHONE
def __init__(self, ctx, label, start, end):
super(PhoneResult, self).__init__(ctx, label, start, end)
number = self._parse(label)
for country in ctx.countries: