コード例 #1
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_irc_colors():
    """
    Get list of IRC colors as list of dictionaries.
    """
    irc_colors = []
    infolist = dogechat.infolist_get('irc_color_dogechat', '', '')
    while dogechat.infolist_next(infolist):
        irc_colors.append({
            'color_irc': dogechat.infolist_string(infolist, 'color_irc'),
            'color_dogechat': dogechat.infolist_string(infolist,
                                                     'color_dogechat'),
        })
    dogechat.infolist_free(infolist)
    return irc_colors
コード例 #2
0
def get_plugins_priority():
    """
    Get priority of default DogeChat plugins as a dictionary.
    """
    plugins_priority = {}
    infolist = dogechat.infolist_get('plugin', '', '')
    while dogechat.infolist_next(infolist):
        name = dogechat.infolist_string(infolist, 'name')
        priority = dogechat.infolist_integer(infolist, 'priority')
        if priority in plugins_priority:
            plugins_priority[priority].append(name)
        else:
            plugins_priority[priority] = [name]
    dogechat.infolist_free(infolist)
    return plugins_priority
コード例 #3
0
def get_irc_colors():
    """
    Get list of IRC colors as list of dictionaries.
    """
    irc_colors = []
    infolist = dogechat.infolist_get('irc_color_dogechat', '', '')
    while dogechat.infolist_next(infolist):
        irc_colors.append({
            'color_irc':
            dogechat.infolist_string(infolist, 'color_irc'),
            'color_dogechat':
            dogechat.infolist_string(infolist, 'color_dogechat'),
        })
    dogechat.infolist_free(infolist)
    return irc_colors
コード例 #4
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_plugins_priority():
    """
    Get priority of default DogeChat plugins as a dictionary.
    """
    plugins_priority = {}
    infolist = dogechat.infolist_get('plugin', '', '')
    while dogechat.infolist_next(infolist):
        name = dogechat.infolist_string(infolist, 'name')
        priority = dogechat.infolist_integer(infolist, 'priority')
        if priority in plugins_priority:
            plugins_priority[priority].append(name)
        else:
            plugins_priority[priority] = [name]
    dogechat.infolist_free(infolist)
    return plugins_priority
コード例 #5
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_infolists():
    """
    Get list of DogeChat/plugins infolists as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    infolists = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'infolist')
    while dogechat.infolist_next(infolist):
        infolist_name = dogechat.infolist_string(infolist, 'infolist_name')
        plugin = dogechat.infolist_string(infolist, 'plugin_name') or 'dogechat'
        for key in ('description', 'pointer_description', 'args_description'):
            infolists[plugin][infolist_name][key] = \
                dogechat.infolist_string(infolist, key)
    dogechat.infolist_free(infolist)
    return infolists
コード例 #6
0
def get_completions():
    """
    Get list of DogeChat/plugins completions as dictionary with 3 indexes:
    plugin, item, xxx.
    """
    completions = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'completion')
    while dogechat.infolist_next(infolist):
        completion_item = dogechat.infolist_string(infolist, 'completion_item')
        if not re.search('|'.join(IGNORE_COMPLETIONS_ITEMS), completion_item):
            plugin = dogechat.infolist_string(infolist, 'plugin_name') or \
                'dogechat'
            completions[plugin][completion_item]['description'] = \
                dogechat.infolist_string(infolist, 'description')
    dogechat.infolist_free(infolist)
    return completions
コード例 #7
0
def get_infolists():
    """
    Get list of DogeChat/plugins infolists as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    infolists = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'infolist')
    while dogechat.infolist_next(infolist):
        infolist_name = dogechat.infolist_string(infolist, 'infolist_name')
        plugin = dogechat.infolist_string(infolist,
                                          'plugin_name') or 'dogechat'
        for key in ('description', 'pointer_description', 'args_description'):
            infolists[plugin][infolist_name][key] = \
                dogechat.infolist_string(infolist, key)
    dogechat.infolist_free(infolist)
    return infolists
コード例 #8
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_url_options():
    """
    Get list of URL options as list of dictionaries.
    """
    url_options = []
    infolist = dogechat.infolist_get('url_options', '', '')
    while dogechat.infolist_next(infolist):
        url_options.append({
            'name': dogechat.infolist_string(infolist, 'name').lower(),
            'option': dogechat.infolist_integer(infolist, 'option'),
            'type': dogechat.infolist_string(infolist, 'type'),
            'constants': dogechat.infolist_string(
                infolist, 'constants').lower().replace(',', ', ')
        })
    dogechat.infolist_free(infolist)
    return url_options
コード例 #9
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_completions():
    """
    Get list of DogeChat/plugins completions as dictionary with 3 indexes:
    plugin, item, xxx.
    """
    completions = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'completion')
    while dogechat.infolist_next(infolist):
        completion_item = dogechat.infolist_string(infolist, 'completion_item')
        if not re.search('|'.join(IGNORE_COMPLETIONS_ITEMS), completion_item):
            plugin = dogechat.infolist_string(infolist, 'plugin_name') or \
                'dogechat'
            completions[plugin][completion_item]['description'] = \
                dogechat.infolist_string(infolist, 'description')
    dogechat.infolist_free(infolist)
    return completions
コード例 #10
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_commands():
    """
    Get list of DogeChat/plugins commands as dictionary with 3 indexes: plugin,
    command, xxx.
    """
    commands = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'command')
    while dogechat.infolist_next(infolist):
        plugin = dogechat.infolist_string(infolist, 'plugin_name') or 'dogechat'
        if plugin in PLUGIN_LIST:
            command = dogechat.infolist_string(infolist, 'command')
            if command == plugin or 'c' in PLUGIN_LIST[plugin]:
                for key in ('description', 'args', 'args_description',
                            'completion'):
                    commands[plugin][command][key] = \
                        dogechat.infolist_string(infolist, key)
    dogechat.infolist_free(infolist)
    return commands
コード例 #11
0
def get_commands():
    """
    Get list of DogeChat/plugins commands as dictionary with 3 indexes: plugin,
    command, xxx.
    """
    commands = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'command')
    while dogechat.infolist_next(infolist):
        plugin = dogechat.infolist_string(infolist,
                                          'plugin_name') or 'dogechat'
        if plugin in PLUGIN_LIST:
            command = dogechat.infolist_string(infolist, 'command')
            if command == plugin or 'c' in PLUGIN_LIST[plugin]:
                for key in ('description', 'args', 'args_description',
                            'completion'):
                    commands[plugin][command][key] = \
                        dogechat.infolist_string(infolist, key)
    dogechat.infolist_free(infolist)
    return commands
コード例 #12
0
def get_url_options():
    """
    Get list of URL options as list of dictionaries.
    """
    url_options = []
    infolist = dogechat.infolist_get('url_options', '', '')
    while dogechat.infolist_next(infolist):
        url_options.append({
            'name':
            dogechat.infolist_string(infolist, 'name').lower(),
            'option':
            dogechat.infolist_integer(infolist, 'option'),
            'type':
            dogechat.infolist_string(infolist, 'type'),
            'constants':
            dogechat.infolist_string(infolist,
                                     'constants').lower().replace(',', ', ')
        })
    dogechat.infolist_free(infolist)
    return url_options
コード例 #13
0
def get_options():
    """
    Get list of DogeChat/plugins config options as dictionary with 4 indexes:
    config, section, option, xxx.
    """
    options = \
        defaultdict(lambda: defaultdict(lambda: defaultdict(defaultdict)))
    infolist = dogechat.infolist_get('option', '', '')
    while dogechat.infolist_next(infolist):
        full_name = dogechat.infolist_string(infolist, 'full_name')
        if not re.search('|'.join(IGNORE_OPTIONS), full_name):
            config = dogechat.infolist_string(infolist, 'config_name')
            if config in PLUGIN_LIST and 'o' in PLUGIN_LIST[config]:
                section = dogechat.infolist_string(infolist, 'section_name')
                option = dogechat.infolist_string(infolist, 'option_name')
                for key in ('type', 'string_values', 'default_value',
                            'description'):
                    options[config][section][option][key] = \
                        dogechat.infolist_string(infolist, key)
                for key in ('min', 'max', 'null_value_allowed'):
                    options[config][section][option][key] = \
                        dogechat.infolist_integer(infolist, key)
    dogechat.infolist_free(infolist)
    return options
コード例 #14
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_options():
    """
    Get list of DogeChat/plugins config options as dictionary with 4 indexes:
    config, section, option, xxx.
    """
    options = \
        defaultdict(lambda: defaultdict(lambda: defaultdict(defaultdict)))
    infolist = dogechat.infolist_get('option', '', '')
    while dogechat.infolist_next(infolist):
        full_name = dogechat.infolist_string(infolist, 'full_name')
        if not re.search('|'.join(IGNORE_OPTIONS), full_name):
            config = dogechat.infolist_string(infolist, 'config_name')
            if config in PLUGIN_LIST and 'o' in PLUGIN_LIST[config]:
                section = dogechat.infolist_string(infolist, 'section_name')
                option = dogechat.infolist_string(infolist, 'option_name')
                for key in ('type', 'string_values', 'default_value',
                            'description'):
                    options[config][section][option][key] = \
                        dogechat.infolist_string(infolist, key)
                for key in ('min', 'max', 'null_value_allowed'):
                    options[config][section][option][key] = \
                        dogechat.infolist_integer(infolist, key)
    dogechat.infolist_free(infolist)
    return options
コード例 #15
0
def get_hdata():
    """
    Get list of DogeChat/plugins hdata as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'hdata')
    while dogechat.infolist_next(infolist):
        hdata_name = dogechat.infolist_string(infolist, 'hdata_name')
        plugin = dogechat.infolist_string(infolist,
                                          'plugin_name') or 'dogechat'
        hdata[plugin][hdata_name]['description'] = \
            dogechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = dogechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = dogechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = dogechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        dogechat.hdata_get_var_array_size_string(ptr_hdata, '',
                                                                key)
                    if var_array_size:
                        var_array_size = \
                            ', array_size: "{0}"'.format(var_array_size)
                    var_hdata = dogechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = dogechat.hdata_get_var_type_string(
                        ptr_hdata, key)
                    hdata2.append({
                        'offset':
                        var_offset,
                        'text':
                        '\'{0}\' ({1})'.format(key, type_string),
                        'textlong':
                        '\'{0}\' ({1}{2}{3})'.format(key, type_string,
                                                     var_array_size,
                                                     var_hdata),
                        'update':
                        dogechat.hdata_update(ptr_hdata, '',
                                              {'__update_allowed': key}),
                    })
                hdata2 = sorted(hdata2, key=itemgetter('offset'))
                for item in hdata2:
                    variables += '*** {0}\n'.format(item['textlong'])
                    if item['update']:
                        variables_update += '*** {0}\n'.format(item['text'])
                if dogechat.hdata_update(ptr_hdata, '',
                                         {'__create_allowed': ''}):
                    variables_update += '*** \'__create\'\n'
                if dogechat.hdata_update(ptr_hdata, '',
                                         {'__delete_allowed': ''}):
                    variables_update += '*** \'__delete\'\n'
            hdata[plugin][hdata_name]['vars'] = variables
            hdata[plugin][hdata_name]['vars_update'] = variables_update

            string = dogechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                for item in sorted(string.split(',')):
                    lists += '*** \'{0}\'\n'.format(item)
            hdata[plugin][hdata_name]['lists'] = lists
    dogechat.infolist_free(infolist)
    return hdata
コード例 #16
0
ファイル: docgen.py プロジェクト: nyuszika7h/dogechat
def get_hdata():
    """
    Get list of DogeChat/plugins hdata as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = dogechat.infolist_get('hook', '', 'hdata')
    while dogechat.infolist_next(infolist):
        hdata_name = dogechat.infolist_string(infolist, 'hdata_name')
        plugin = dogechat.infolist_string(infolist, 'plugin_name') or 'dogechat'
        hdata[plugin][hdata_name]['description'] = \
            dogechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = dogechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = dogechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = dogechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        dogechat.hdata_get_var_array_size_string(ptr_hdata, '',
                                                                key)
                    if var_array_size:
                        var_array_size = \
                            ', array_size: "{0}"'.format(var_array_size)
                    var_hdata = dogechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = dogechat.hdata_get_var_type_string(ptr_hdata,
                                                                    key)
                    hdata2.append({
                        'offset': var_offset,
                        'text': '\'{0}\' ({1})'.format(key, type_string),
                        'textlong': '\'{0}\' ({1}{2}{3})'.format(
                            key, type_string, var_array_size, var_hdata),
                        'update': dogechat.hdata_update(
                            ptr_hdata, '', {'__update_allowed': key}),
                    })
                hdata2 = sorted(hdata2, key=itemgetter('offset'))
                for item in hdata2:
                    variables += '*** {0}\n'.format(item['textlong'])
                    if item['update']:
                        variables_update += '*** {0}\n'.format(item['text'])
                if dogechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    variables_update += '*** \'__create\'\n'
                if dogechat.hdata_update(ptr_hdata, '',
                                        {'__delete_allowed': ''}):
                    variables_update += '*** \'__delete\'\n'
            hdata[plugin][hdata_name]['vars'] = variables
            hdata[plugin][hdata_name]['vars_update'] = variables_update

            string = dogechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                for item in sorted(string.split(',')):
                    lists += '*** \'{0}\'\n'.format(item)
            hdata[plugin][hdata_name]['lists'] = lists
    dogechat.infolist_free(infolist)
    return hdata