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


Python CONFIG.register_defaults_helper方法代码示例

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


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

示例1: to

# 需要导入模块: from neubot.config import CONFIG [as 别名]
# 或者: from neubot.config.CONFIG import register_defaults_helper [as 别名]
    ('bittorrent.address', '', 'Address to listen/connect to ("" = auto)'),
    ('bittorrent.bytes.down', 0, 'Num of bytes to download (0 = auto)'),
    ('bittorrent.bytes.up', 0, 'Num of bytes to upload (0 = auto)'),
    ('bittorrent.daemonize', False, 'Become a daemon and run in background'),
    ('bittorrent.infohash', '', 'Set InfoHash ("" = auto)'),
    ('bittorrent.listen', False, 'Run in server mode'),
    ('bittorrent.negotiate', True, 'Enable negotiate client/server'),
    ('bittorrent.negotiate.port', 80, 'Negotiate port'),
    ('bittorrent.my_id', '', 'Set local PeerId ("" = auto)'),
    ('bittorrent.numpieces', NUMPIECES, 'Num of pieces in bitfield'),
    ('bittorrent.piece_len', PIECE_LEN, 'Length of each piece'),
    ('bittorrent.port', 6881, 'Port to listen/connect to (0 = auto)'),
    ('bittorrent.watchdog', WATCHDOG, 'Maximum test run-time in seconds'),
)

CONFIG.register_defaults_helper(PROPERTIES)

def register_descriptions():
    ''' Registers the description of bittorrent variables '''
    CONFIG.register_descriptions_helper(PROPERTIES)

def _random_bytes(num):
    ''' Generates a random string of @num bytes '''
    return ''.join([chr(random.randint(32, 126)) for _ in range(num)])

def finalize_conf(conf):

    ''' Finalize configuration and guess the proper value of all
        the undefined variables '''

    if not conf['bittorrent.my_id']:
开发者ID:DavideAllavena,项目名称:neubot,代码行数:33,代码来源:config.py


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