示例#1
0
class FakeConfigSection(types.StaticSection):
    valattr = types.ValidatedAttribute('valattr')
    listattr = types.ListAttribute('listattr')
    choiceattr = types.ChoiceAttribute('choiceattr', ['spam', 'egg', 'bacon'])
    booleanattr = types.BooleanAttribute('booleanattr')
    booleanattr_true = types.BooleanAttribute('booleanattr', default=True)
    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)
示例#2
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"""
示例#3
0
文件: tell.py 项目: sopel-irc/sopel
class TellSection(types.StaticSection):
    use_private_reminder = types.BooleanAttribute(
        'use_private_reminder', default=False)
    """When set to ``true``, Sopel will send reminder as private message."""
    maximum_public = types.ValidatedAttribute(
        'maximum_public', parse=int, default=4)
    """How many Sopel can send in public before using private message."""
示例#4
0
def test_boolean_serialize():
    option = types.BooleanAttribute('foo')
    assert option.serialize(True) == 'true'
    assert option.serialize('string') == 'false'
    assert option.serialize('1') == 'true'
    assert option.serialize('') == 'false'
    assert option.serialize(1) == 'true'

    # true-ish values
    assert option.serialize('yes') == 'true'
    assert option.serialize('YES') == 'true'
    assert option.serialize('yES') == 'true'
    assert option.serialize('y') == 'true'
    assert option.serialize('Y') == 'true'
    assert option.serialize('true') == 'true'
    assert option.serialize('True') == 'true'
    assert option.serialize('TRUE') == 'true'
    assert option.serialize('trUE') == 'true'
    assert option.serialize('on') == 'true'
    assert option.serialize('ON') == 'true'
    assert option.serialize('On') == 'true'
    assert option.serialize('enable') == 'true'
    assert option.serialize('enabled') == 'true'

    # everything else
    assert option.serialize('no') == 'false'
    assert option.serialize('disable') == 'false'
    assert option.serialize('disabled') == 'false'
示例#5
0
def test_boolean_parse():
    option = types.BooleanAttribute('foo')
    assert option.parse('string') is False
    assert option.parse('1') is True
    assert option.parse('') is False
    assert option.parse(1) is True

    # true-ish values
    assert option.parse('yes') is True
    assert option.parse('YES') is True
    assert option.parse('yES') is True
    assert option.parse('y') is True
    assert option.parse('Y') is True
    assert option.parse('true') is True
    assert option.parse('True') is True
    assert option.parse('TRUE') is True
    assert option.parse('trUE') is True
    assert option.parse('on') is True
    assert option.parse('ON') is True
    assert option.parse('On') is True
    assert option.parse('enable') is True
    assert option.parse('enabled') is True

    # everything else
    assert option.parse('no') is False
    assert option.parse('off') is False
    assert option.parse('disable') is False
    assert option.parse('disabled') is False
示例#6
0
class UrlSection(types.StaticSection):
    enable_auto_title = types.BooleanAttribute('enable_auto_title',
                                               default=True)
    """Enable auto-title (enabled by default)"""
    # TODO some validation rules maybe?
    exclude = types.ListAttribute('exclude')
    """A list of regular expressions to match URLs for which the title should not be shown."""
    exclusion_char = types.ValidatedAttribute('exclusion_char', default='!')
    """A character (or string) which, when immediately preceding a URL, will stop that URL's title from being shown."""
    shorten_url_length = types.ValidatedAttribute('shorten_url_length',
                                                  int,
                                                  default=0)
    """If greater than 0, the title fetcher will include a TinyURL version of links longer than this many characters."""
    enable_private_resolution = types.BooleanAttribute(
        'enable_private_resolution', default=False)
    """Enable requests to private and local network IP addresses"""
示例#7
0
class SafetySection(types.StaticSection):
    enabled_by_default = types.BooleanAttribute('enabled_by_default',
                                                default=True)
    """Whether to enable URL safety in all channels where it isn't explicitly disabled."""
    known_good = types.ListAttribute('known_good')
    """List of "known good" domains to ignore."""
    vt_api_key = types.ValidatedAttribute('vt_api_key')
    """Optional VirusTotal API key (improves malicious URL detection)."""
示例#8
0
文件: safety.py 项目: sopel-irc/sopel
class SafetySection(types.StaticSection):
    enabled_by_default = types.BooleanAttribute("enabled_by_default",
                                                default=True)
    """Deprecated: Sets default_mode to "off" or "on"."""
    default_mode = types.ValidatedAttribute("default_mode")
    """Which mode to use in channels without a mode set."""
    known_good = types.ListAttribute('known_good')
    """List of "known good" domains or regexes to consider trusted."""
    vt_api_key = types.ValidatedAttribute('vt_api_key')
    """Optional VirusTotal API key (improves malicious URL detection)."""
    domain_blocklist_url = types.ValidatedAttribute("domain_blocklist_url")
    """Optional hosts-file formatted domain blocklist to use instead of StevenBlack's."""
示例#9
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?"""
示例#10
0
def test_boolean_attribute():
    option = types.BooleanAttribute('foo')
    assert option.name == 'foo'
    assert option.default is False
示例#11
0
文件: admin.py 项目: eliocamp/sopel
class AdminSection(types.StaticSection):
    hold_ground = types.BooleanAttribute('hold_ground', default=False)
    """Auto re-join on kick"""
    auto_accept_invite = types.BooleanAttribute('auto_accept_invite',
                                                default=True)
    """Auto-join channels when invited"""
示例#12
0
class PronounsSection(types.StaticSection):
    fetch_complete_list = types.BooleanAttribute('fetch_complete_list',
                                                 default=True)
    """Whether to attempt fetching the complete list pronoun.is uses, at bot startup."""