orm.py 文件源码

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

项目:maas 作者: maas 项目源码 文件源码
def parse_item_specifier_type(
        specifier, spec_types: Container=None, separator=':'):
    """
    Returns a tuple that splits the string int a specifier, and its specifier
    type.

    Retruns a tuple of (specifier, specifier_type). If no specifier type could
    be found in the set, returns None in place of the specifier_type.

    :param specifier: The specifier string, such as "ip:10.0.0.1".
    :param spec_types: A container whose elements are strings that will be
        recognized as specifier types.
    :param separator: Optional specifier. Defaults to ':'.
    :return: tuple
    """
    if separator in specifier:
        tokens = specifier.split(separator, 1)
        if tokens[0] in spec_types:
            specifier_type = tokens[0]
            specifier = tokens[1].strip()
        else:
            specifier_type = None
    else:
        specifier_type = None
    return specifier, specifier_type
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号