Пример #1
0
def get_hdata():
    """Get list of hdata hooked by plugins in a dict with 3 indexes: plugin, name, xxx."""
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = weechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = weechat.hdata_get_var_array_size_string(ptr_hdata, '', key)
                    if var_array_size:
                        var_array_size = ', array_size: "%s"' % var_array_size
                    var_hdata = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "%s"' % var_hdata
                    type_string = weechat.hdata_get_var_type_string(ptr_hdata, key)
                    hdata2.append({'offset': var_offset,
                                   'text': '\'%s\' (%s)' % (key, type_string),
                                   'textlong': '\'%s\' (%s%s%s)' % (key, type_string, var_array_size, var_hdata),
                                   'update': weechat.hdata_update(ptr_hdata, '', { '__update_allowed': key })})
                hdata2 = sorted(hdata2, key=itemgetter('offset'))
                for item in hdata2:
                    if variables:
                        variables += ' +\n'
                    variables += '  %s' % item['textlong']
                    if item['update']:
                        if variables_update:
                            variables_update += ' +\n'
                        variables_update += '  %s' % item['text']
                if weechat.hdata_update(ptr_hdata, '', { '__delete_allowed' : '' }):
                    if variables_update:
                        variables_update += ' +\n'
                    variables_update += '  \'__delete\''
            hdata[plugin][hdata_name]['vars'] = '\n%s' % variables
            hdata[plugin][hdata_name]['vars_update'] = '\n%s' % variables_update

            string = weechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                for item in sorted(string.split(',')):
                    if lists:
                        lists += ' +\n'
                    lists += '  \'%s\'' % item
                lists = '\n%s' % lists
            else:
                lists = '\n  -'
            hdata[plugin][hdata_name]['lists'] = lists
    weechat.infolist_free(infolist)
    return hdata
Пример #2
0
def get_hdata():
    """
    Get list of WeeChat/plugins hdata as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = \
            weechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        weechat.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 = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = weechat.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':
                        weechat.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 weechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    variables_update += '    _{hdata_update_create}_ +\n'
                if weechat.hdata_update(ptr_hdata, '',
                                        {'__delete_allowed': ''}):
                    variables_update += '    _{hdata_update_delete}_ +\n'
            hdata[plugin][hdata_name]['vars'] = variables
            hdata[plugin][hdata_name]['vars_update'] = variables_update

            string = weechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                list_lists = string.split(',')
                lists_std = [
                    l for l in list_lists if not l.startswith('last_')
                ]
                lists_last = [l for l in list_lists if l.startswith('last_')]
                for item in sorted(lists_std) + sorted(lists_last):
                    lists += '_{0}_ +\n'.format(item)
            hdata[plugin][hdata_name]['lists'] = lists
    weechat.infolist_free(infolist)
    return hdata
Пример #3
0
def get_hdata():
    """
    Get list of hdata hooked by plugins in a dict with 3 indexes:
    plugin, name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = \
            weechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        weechat.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 = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = weechat.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': weechat.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 weechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    variables_update += '*** \'__create\'\n'
                if weechat.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 = weechat.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
    weechat.infolist_free(infolist)
    return hdata
Пример #4
0
def get_hdata():
    """
    Get list of WeeChat/plugins hdata as dictionary with 3 indexes: plugin,
    name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = \
            weechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        weechat.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 = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = weechat.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': weechat.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 weechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    variables_update += '    _{hdata_update_create}_ +\n'
                if weechat.hdata_update(ptr_hdata, '',
                                        {'__delete_allowed': ''}):
                    variables_update += '    _{hdata_update_delete}_ +\n'
            hdata[plugin][hdata_name]['vars'] = variables
            hdata[plugin][hdata_name]['vars_update'] = variables_update

            string = weechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                list_lists = string.split(',')
                lists_std = [l for l in list_lists
                             if not l.startswith('last_')]
                lists_last = [l for l in list_lists
                              if l.startswith('last_')]
                for item in sorted(lists_std) + sorted(lists_last):
                    lists += '_{0}_ +\n'.format(item)
            hdata[plugin][hdata_name]['lists'] = lists
    weechat.infolist_free(infolist)
    return hdata
Пример #5
0
    def _read_api_hdata():  # pylint: disable=too-many-locals
        """
        Get list of WeeChat/plugins hdata as dictionary with 3 indexes:
        plugin, name, xxx.
        """
        hdata = defaultdict(lambda: defaultdict(defaultdict))
        infolist = weechat.infolist_get('hook', '', 'hdata')
        while weechat.infolist_next(infolist):
            hdata_name = weechat.infolist_string(infolist, 'hdata_name')
            plugin = (weechat.infolist_string(infolist, 'plugin_name')
                      or 'weechat')
            hdata[plugin][hdata_name]['description'] = \
                weechat.infolist_string(infolist, 'description')
            variables = ''
            vars_update = ''
            lists = ''
            ptr_hdata = weechat.hdata_get(hdata_name)
            if ptr_hdata:
                hdata2 = []
                string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
                if string:
                    for item in string.split(','):
                        key = item.split(':')[0]
                        var_offset = weechat.hdata_get_var_offset(
                            ptr_hdata,
                            key,
                        )
                        var_array_size = \
                            weechat.hdata_get_var_array_size_string(
                                ptr_hdata,
                                '',
                                key,
                            )
                        if var_array_size:
                            var_array_size = \
                                f', array_size: "{var_array_size}"'
                        var_hdata = weechat.hdata_get_var_hdata(ptr_hdata, key)
                        if var_hdata:
                            var_hdata = f', hdata: "{var_hdata}"'
                        type_string = weechat.hdata_get_var_type_string(
                            ptr_hdata,
                            key,
                        )
                        hdata2.append({
                            'offset':
                            var_offset,
                            'text':
                            f'_{key}_ ({type_string})',
                            'textlong': (f'_{key}_   ({type_string}'
                                         f'{var_array_size}{var_hdata})'),
                            'update':
                            weechat.hdata_update(ptr_hdata, '',
                                                 {'__update_allowed': key}),
                        })
                    hdata2 = sorted(hdata2, key=itemgetter('offset'))
                    for item in hdata2:
                        variables += f'{item["textlong"]} +\n'
                        if item['update']:
                            vars_update += f'    {item["text"]} +\n'
                    if weechat.hdata_update(ptr_hdata, '',
                                            {'__create_allowed': ''}):
                        vars_update += '    _{hdata_update_create}_ +\n'
                    if weechat.hdata_update(ptr_hdata, '',
                                            {'__delete_allowed': ''}):
                        vars_update += '    _{hdata_update_delete}_ +\n'
                hdata[plugin][hdata_name]['vars'] = variables
                hdata[plugin][hdata_name]['vars_update'] = vars_update.rstrip()

                string = weechat.hdata_get_string(ptr_hdata, 'list_keys')
                if string:
                    list_lists = string.split(',')
                    lists_std = [
                        lst for lst in list_lists
                        if not lst.startswith('last_')
                    ]
                    lists_last = [
                        lst for lst in list_lists if lst.startswith('last_')
                    ]
                    for item in sorted(lists_std) + sorted(lists_last):
                        lists += f'_{item}_ +\n'
                hdata[plugin][hdata_name]['lists'] = lists
        weechat.infolist_free(infolist)
        return hdata
Пример #6
0
def get_hdata():
    """
    Get list of hdata hooked by plugins in a dict with 3 indexes:
    plugin, name, xxx.
    """
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = \
            weechat.infolist_string(infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = \
                        weechat.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 = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "{0}"'.format(var_hdata)
                    type_string = weechat.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': weechat.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 weechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    variables_update += '*** \'__create\'\n'
                if weechat.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 = weechat.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
    weechat.infolist_free(infolist)
    return hdata
Пример #7
0
def get_hdata():
    """Get list of hdata hooked by plugins in a dict with 3 indexes: plugin, name, xxx."""
    hdata = defaultdict(lambda: defaultdict(defaultdict))
    infolist = weechat.infolist_get('hook', '', 'hdata')
    while weechat.infolist_next(infolist):
        hdata_name = weechat.infolist_string(infolist, 'hdata_name')
        plugin = weechat.infolist_string(infolist, 'plugin_name') or 'weechat'
        hdata[plugin][hdata_name]['description'] = weechat.infolist_string(
            infolist, 'description')
        variables = ''
        variables_update = ''
        lists = ''
        ptr_hdata = weechat.hdata_get(hdata_name)
        if ptr_hdata:
            hdata2 = []
            string = weechat.hdata_get_string(ptr_hdata, 'var_keys_values')
            if string:
                for item in string.split(','):
                    key = item.split(':')[0]
                    var_offset = weechat.hdata_get_var_offset(ptr_hdata, key)
                    var_array_size = weechat.hdata_get_var_array_size_string(
                        ptr_hdata, '', key)
                    if var_array_size:
                        var_array_size = ', array_size: "%s"' % var_array_size
                    var_hdata = weechat.hdata_get_var_hdata(ptr_hdata, key)
                    if var_hdata:
                        var_hdata = ', hdata: "%s"' % var_hdata
                    type_string = weechat.hdata_get_var_type_string(
                        ptr_hdata, key)
                    hdata2.append({
                        'offset':
                        var_offset,
                        'text':
                        '\'%s\' (%s)' % (key, type_string),
                        'textlong':
                        '\'%s\' (%s%s%s)' %
                        (key, type_string, var_array_size, var_hdata),
                        'update':
                        weechat.hdata_update(ptr_hdata, '',
                                             {'__update_allowed': key})
                    })
                hdata2 = sorted(hdata2, key=itemgetter('offset'))
                for item in hdata2:
                    if variables:
                        variables += ' +\n'
                    variables += '  %s' % item['textlong']
                    if item['update']:
                        if variables_update:
                            variables_update += ' +\n'
                        variables_update += '  %s' % item['text']
                if weechat.hdata_update(ptr_hdata, '',
                                        {'__create_allowed': ''}):
                    if variables_update:
                        variables_update += ' +\n'
                    variables_update += '  `__create`'
                if weechat.hdata_update(ptr_hdata, '',
                                        {'__delete_allowed': ''}):
                    if variables_update:
                        variables_update += ' +\n'
                    variables_update += '  `__delete`'
            hdata[plugin][hdata_name]['vars'] = '\n%s' % variables
            hdata[plugin][hdata_name][
                'vars_update'] = '\n%s' % variables_update

            string = weechat.hdata_get_string(ptr_hdata, 'list_keys')
            if string:
                for item in sorted(string.split(',')):
                    if lists:
                        lists += ' +\n'
                    lists += '  \'%s\'' % item
                lists = '\n%s' % lists
            else:
                lists = '\n  -'
            hdata[plugin][hdata_name]['lists'] = lists
    weechat.infolist_free(infolist)
    return hdata