inputtype.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:archive-Holmes-Totem-Service-Library 作者: HolmesProcessing 项目源码 文件源码
def Detect(_input):
    """
    Determine the type of the object and return an integer corresponding to the
    global constants Domain, Email, or IP.

    Any string input is assumed to be utf-8 encoded and transformed to a bytes
    object by calling _input.encode("utf-8") if necessary (domain/email
    detection).

    Supports IPv4, IPv6 in punctuated string representation or decimal number
        (<32 bit is considered IPv4)
        -> Return value: ipaddress.IPv4Address or ipaddress.IPv6Address
    Supports CIDR IP address range (returns: ipaddress.IPv4Network or
        ipaddress.IPv6Network)
    Supports Email and "Name <Email>" (returns Email)
    Supports Domain (returns the input string)
    Supports detection of files (by checking if it is available in /tmp/)

    On success returns:

         Type(int): Domain, Email, IP, IPNet, File
         Parsed Object: Email, ipaddress.ip_address, ipaddress.ip_network, os.Fi
         Error: None

    On failure returns:

         Type(int): Unknown / None (None if EmptyInputError)
         Parsed Object: None
         Error: EmptyInputError / UnknownTypeError

    *Any attempt to detect a domain without a proper TLD map set will
    result in a panic!* (see inputtype.InitializeTLDMap(path))

    TODO: provide methods to check if an input is a specific type
    """
    return __detectType(_input)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号