当前位置: 首页>>代码示例>>Python>>正文


Python SimpleNamespace.away方法代码示例

本文整理汇总了Python中types.SimpleNamespace.away方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleNamespace.away方法的具体用法?Python SimpleNamespace.away怎么用?Python SimpleNamespace.away使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types.SimpleNamespace的用法示例。


在下文中一共展示了SimpleNamespace.away方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: who_flag_parse

# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import away [as 别名]
def who_flag_parse(flags):
    """ Parse WHO flags.

    :param flags:
        Flags to parse.

    :returns:
        A namespace object containing the following attributes:

        :param operator:
            Whether or not the user is an operator.

        :param away:
            Whether or not the user is away.

        :param modes:
            A set of the user's present modes (prefixes).
    """
    ret = SimpleNamespace(operator=False, away=False, modes=set())
    ret.operator = False

    for char in flags:
        if char == '*':
            ret.operator = True
        elif char == "G":
            ret.away = True
        elif char == "H":
            ret.away = False
        elif char not in numletters:
            ret.modes.add(char)
        else:
            logger.debug("No known way to handle WHO flag %s", char)

    return ret
开发者ID:bethebunny,项目名称:mircy,代码行数:36,代码来源:auxparse.py

示例2: userhost_parse

# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import away [as 别名]
def userhost_parse(mask):
    """Parse a USERHOST reply.

    :returns:
        An object with the following attributes set:

        :hostmask:
            :py:class:`~PyIRC.line.Hostmask` of the user. This may be a cloak.

        :operator:
            Whether or not the user is an operator. False does not mean they
            are not an operator, as operators may be hidden on the server.

        :away:
            Whether or not the user is away.

    """
    if not mask:
        raise ValueError("Need a mask to parse")

    ret = SimpleNamespace(hostmask=None, operator=None, away=None)

    nick, sep, userhost = mask.partition('=')
    if not sep:
        return ret

    if nick.endswith('*'):
        nick = nick[:-1]
        ret.operator = True

    if userhost.startswith(('+', '-')):
        away, userhost = userhost[0], userhost[:1]
        ret.away = (away == '+')

    # [email protected]
    username, sep, host = userhost.partition('@')
    if not sep:
        host = username
        username = None

    ret.hostmask = Hostmask(nick=nick, username=username, host=host)

    return ret
开发者ID:mickael9,项目名称:PyIRC,代码行数:45,代码来源:auxparse.py


注:本文中的types.SimpleNamespace.away方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。