Exemplo n.º 1
0
class HelpSection(types.StaticSection):
    """Configuration section for this plugin."""
    output = types.ChoiceAttribute('output',
                                   list(PASTEBIN_PROVIDERS),
                                   default='clbin')
    """The pastebin provider to use for help output."""
    reply_method = types.ChoiceAttribute('reply_method',
                                         REPLY_METHODS,
                                         default='channel')
    """Where/how to reply to help commands (public/private)."""
    show_server_host = types.BooleanAttribute('show_server_host', default=True)
    """Show the IRC server's hostname/IP in the first line of the help listing?"""
Exemplo n.º 2
0
class QotdSection(config.StaticSession):
    """
    Base section for configuring qotd module.
    """
    translate_quote = config.ChoiceAttribute(
        'translate_quote', ['true', 'on', '1', 'false', 'off', '0'], 'true')
    language_subdomain = config.ValidatedAttribute('language_subdomain',
                                                   str,
                                                   default='fr')
    enabled = config.ChoiceAttribute('enabled',
                                     ['true', 'on', '1', 'false', 'off', '0'],
                                     'true')
    publishing_time = config.ValidatedAttribute(
        'publishing_time',
        lambda str_value: datetime.datetime.strptime(
            "1900-01-01 {}".format(str_value), "%Y-%m-%d %H:%M:%S").time(),
        default='09:00:00')
Exemplo n.º 3
0
class FakeConfigSection(types.StaticSection):
    valattr = types.ValidatedAttribute('valattr')
    listattr = types.ListAttribute('listattr')
    choiceattr = types.ChoiceAttribute('choiceattr', ['spam', 'egg', 'bacon'])
    af_fileattr = types.FilenameAttribute('af_fileattr', relative=False, directory=False)
    ad_fileattr = types.FilenameAttribute('ad_fileattr', relative=False, directory=True)
    rf_fileattr = types.FilenameAttribute('rf_fileattr', relative=True, directory=False)
    rd_fileattr = types.FilenameAttribute('rd_fileattr', relative=True, directory=True)
Exemplo n.º 4
0
def test_choice_serialize():
    option = types.ChoiceAttribute('foo', choices=['a', 'b', 'c'])
    assert option.serialize('a') == 'a'
    assert option.serialize('b') == 'b'
    assert option.serialize('c') == 'c'

    with pytest.raises(ValueError):
        option.serialize('d')
Exemplo n.º 5
0
class CurrencySection(types.StaticSection):
    fiat_provider = types.ChoiceAttribute('fiat_provider',
                                          list(FIAT_PROVIDERS.keys()),
                                          default='exchangerate.host')
    """Which data provider to use (some of which require no API key)"""
    fixer_io_key = types.ValidatedAttribute('fixer_io_key', default=None)
    """API key for Fixer.io (widest currency support)"""
    fixer_use_ssl = types.BooleanAttribute('fixer_use_ssl', default=False)
    """Whether to use SSL (HTTPS) for Fixer API"""
    auto_convert = types.BooleanAttribute('auto_convert', default=False)
    """Whether to convert currencies without an explicit command"""
Exemplo n.º 6
0
def test_choice_attribute():
    option = types.ChoiceAttribute('foo', choices=['a', 'b', 'c'])
    assert option.name == 'foo'
    assert option.default is None
    assert option.is_secret is False