本文整理汇总了Python中weechat.infolist_get函数的典型用法代码示例。如果您正苦于以下问题:Python infolist_get函数的具体用法?Python infolist_get怎么用?Python infolist_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了infolist_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: find_channels
def find_channels():
"""Return list of servers and channels"""
#@TODO: make it return a dict with more options like "nicks_count etc."
items = {}
infolist = w.infolist_get('irc_server', '', '')
# populate servers
while w.infolist_next(infolist):
items[w.infolist_string(infolist, 'name')] = ''
w.infolist_free(infolist)
# populate channels per server
for server in items.keys():
items[server] = '' #init if connected but no channels
infolist = w.infolist_get('irc_channel', '', server)
while w.infolist_next(infolist):
if w.infolist_integer(infolist, 'nicks_count') == 0:
#parted but still open in a buffer: bit hackish
continue
if w.infolist_integer(infolist, 'type') == 0:
channel = w.infolist_string(infolist, "buffer_short_name")
items[server] += '%s,' %channel
w.infolist_free(infolist)
return items
开发者ID:sitaktif,项目名称:weechat-scripts,代码行数:25,代码来源:autojoin.py
示例2: find_channels
def find_channels():
"""Return list of servers and channels"""
#@TODO: make it return a dict with more options like "nicks_count etc."
items = {}
infolist = w.infolist_get('irc_server', '', '')
# populate servers
while w.infolist_next(infolist):
items[w.infolist_string(infolist, 'name')] = ''
w.infolist_free(infolist)
# populate channels per server
for server in items.keys():
keys = []
keyed_channels = []
unkeyed_channels = []
items[server] = '' #init if connected but no channels
infolist = w.infolist_get('irc_channel', '', server)
while w.infolist_next(infolist):
if w.infolist_integer(infolist, 'nicks_count') == 0:
#parted but still open in a buffer: bit hackish
continue
if w.infolist_integer(infolist, 'type') == 0:
key = w.infolist_string(infolist, "key")
if len(key) > 0:
keys.append(key)
keyed_channels.append(w.infolist_string(infolist, "name"))
else :
unkeyed_channels.append(w.infolist_string(infolist, "name"))
items[server] = ','.join(keyed_channels + unkeyed_channels)
if len(keys) > 0:
items[server] += ' %s' % ','.join(keys)
w.infolist_free(infolist)
return items
开发者ID:AlanSherman,项目名称:.weechat,代码行数:35,代码来源:autojoin.py
示例3: command_main
def command_main(data, buffer, args):
infolist = w.infolist_get("buffer", "", "")
buffer_groups = {}
results = []
buffer_count = 0
merge_count = 0
numbers = set()
while w.infolist_next(infolist):
bplugin = w.infolist_string(infolist, "plugin_name")
bname = w.infolist_string(infolist, "name")
bpointer = w.infolist_pointer(infolist, "pointer")
bnumber = w.infolist_integer(infolist, "number")
btype = w.buffer_get_string(bpointer, 'localvar_type')
if not bnumber in numbers:
numbers.add(bnumber)
else:
merge_count += 1
if btype == 'server':
bdesc = 'servers'
elif btype == 'channel':
bdesc = 'channels'
elif btype == 'private':
bdesc = 'queries'
else:
bdesc = bplugin
buffer_groups.setdefault(bdesc,[]).append({'name': bname, 'pointer': bpointer})
w.infolist_free(infolist)
infolist = w.infolist_get("window", "", "")
windows_v = set()
windows_h = set()
windows = set()
while w.infolist_next(infolist):
window = w.infolist_pointer(infolist, "pointer")
window_w = w.infolist_integer(infolist, "width_pct")
window_h = w.infolist_integer(infolist, "height_pct")
windows.add(window)
if window_h == 100 and window_w != 100:
windows_v.add(window)
elif window_w == 100 and window_h != 100:
windows_h.add(window)
#else: #both 100%, thus no splits
w.infolist_free(infolist)
window_count = len(windows)
for desc, buffers in buffer_groups.iteritems():
buffer_count += len(buffers)
results.append('%i %s' % (len(buffers), desc))
buffer_stats = ', '.join(sorted(results, key = lambda item: (int(item.partition(' ')[0]) if item[0].isdigit() else float('inf'), item),reverse=True)) # descending numerical sort of strings
stats_string = '%i buffers (%i merged): %s; %i windows' % (buffer_count, merge_count, buffer_stats, window_count)
if '-split' in args:
stats_string += ": %i vertically / %i horizontally split" % (len(windows_v), len(windows_h))
w.command("", "/input insert %s" % stats_string)
return w.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:59,代码来源:weestats.py
示例4: command_main
def command_main(data, buffer, args):
infolist = w.infolist_get("buffer", "", "")
buffer_groups = {}
results = []
buffer_count = 0
merge_count = 0
numbers = set()
while w.infolist_next(infolist):
bplugin = w.infolist_string(infolist, "plugin_name")
bname = w.infolist_string(infolist, "name")
bpointer = w.infolist_pointer(infolist, "pointer")
bnumber = w.infolist_integer(infolist, "number")
if not bnumber in numbers:
numbers.add(bnumber)
else:
merge_count += 1
btype = bplugin
if bplugin == 'irc':
if 'server.' in bname:
btype = '%s servers' % btype
elif '#' in bname:
btype = '%s channels' % btype
else:
btype = '%s queries' % btype
buffer_groups.setdefault(btype,[]).append({'name': bname, 'pointer': bpointer})
w.infolist_free(infolist)
infolist = w.infolist_get("window", "", "")
windows_v = set()
windows_h = set()
windows = set()
while w.infolist_next(infolist):
window = w.infolist_pointer(infolist, "pointer")
window_w = w.infolist_integer(infolist, "width_pct")
window_h = w.infolist_integer(infolist, "height_pct")
windows.add(window)
if window_h == 100 and window_w != 100:
windows_v.add(window)
elif window_w == 100 and window_h != 100:
windows_h.add(window)
#else: #both 100%, thus no splits
w.infolist_free(infolist)
window_count = len(windows)
for bplugin, buffers in buffer_groups.iteritems():
buffer_count += len(buffers)
results.append('%i %s' % (len(buffers), bplugin))
buffer_stats = ', '.join(sorted(results))
stats_string = '%i windows used (%i vertically / %i horizontally split). %i (of which %i merged) buffers open: %s' % (window_count, len(windows_v), len(windows_h), buffer_count, merge_count, buffer_stats)
w.command("", "/input insert %s" % stats_string)
return w.WEECHAT_RC_OK
开发者ID:idk,项目名称:moo-skel,代码行数:55,代码来源:weestats.py
示例5: init_weechat
def init_weechat(self):
"""
Initialize theme using current WeeChat options (aliases are
replaced with their values from palette).
"""
# get palette options
self.palette = {}
infolist = weechat.infolist_get('option', '', 'weechat.palette.*')
while weechat.infolist_next(infolist):
option_name = weechat.infolist_string(infolist, 'option_name')
value = weechat.infolist_string(infolist, 'value')
self.palette[value] = option_name
weechat.infolist_free(infolist)
# get color options (replace aliases by values from palette)
self.options = {}
infolist = weechat.infolist_get('option', '', '')
while weechat.infolist_next(infolist):
full_name = weechat.infolist_string(infolist, 'full_name')
if self._option_is_used(full_name):
value = weechat.infolist_string(infolist, 'value')
self.options[full_name] = self._get_color_without_alias(value)
weechat.infolist_free(infolist)
# replace aliases in chat_nick_colors
option = 'weechat.color.chat_nick_colors'
colors = []
for color in self.options.get(option, '').split(','):
colors.append(self._get_color_without_alias(color))
if colors:
self.options[option] = ','.join(colors)
# replace aliases in buffer_time_format
option = 'weechat.look.buffer_time_format'
if option in self.options:
value = re.compile(r'\$\{color:[^\}]+\}').sub(
self._replace_color_alias, self.options[option])
if value:
self.options[option] = value
# build dict with nick prefixes (and replace alisases)
prefixes = []
option = 'irc.color.nick_prefixes'
for prefix in self.options.get(option, '').split(';'):
values = prefix.split(':', 1)
if len(values) == 2:
prefixes.append(values[0] + ':' +
self._get_color_without_alias(values[1]))
if prefixes:
self.options[option] = ';'.join(prefixes)
# delete palette
del self.palette
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:48,代码来源:theme.py
示例6: update_user_count
def update_user_count(server=None, channel=None):
if isinstance(channel, str):
channel = set((channel, ))
elif channel:
channel = set(channel)
def update_channel(server, channel=None):
channel_infolist = weechat.infolist_get('irc_channel', '', server)
while weechat.infolist_next(channel_infolist):
_channel = weechat.infolist_string(channel_infolist, 'name')
if channel:
_channel = caseInsensibleKey(_channel)
if _channel not in channel:
continue
channel_stats[server, _channel] = weechat.infolist_integer(channel_infolist, 'nicks_count')
weechat.infolist_free(channel_infolist)
if not server:
server_infolist = weechat.infolist_get('irc_server', '', '')
while weechat.infolist_next(server_infolist):
server = weechat.infolist_string(server_infolist, 'name')
update_channel(server)
weechat.infolist_free(server_infolist)
else:
update_channel(server, channel)
开发者ID:NuclearW,项目名称:weechat-scripts,代码行数:25,代码来源:chanstat.py
示例7: match_against_nicklist
def match_against_nicklist(server, channel, hostmask):
"""Compare the hostmask against all users in the channel"""
infolist = w.infolist_get("irc_nick", "", "{},{}".format(server, channel))
if "$a:" in hostmask or "$~a" in hostmask:
field = "account"
hostmask = hostmask.replace("$a:", "")
hostfield = False
else:
field = "host"
hostfield = True
extban_unreg = hostmask == "$~a"
matches = []
while w.infolist_next(infolist):
name = w.infolist_string(infolist, "name")
if hostfield:
host = name + "!" + w.infolist_string(infolist, field)
else:
host = w.infolist_string(infolist, field)
if ((extban_unreg and host == "*") or
(not extban_unreg and w.string_match(host, hostmask, 0))):
matches.append(name)
w.infolist_free(infolist)
return matches
开发者ID:DarkDefender,项目名称:scripts,代码行数:30,代码来源:maskmatch.py
示例8: get_help_command
def get_help_command(plugin, input_cmd, input_args):
"""Get help for command in input."""
global cmdhelp_settings
if input_cmd == 'set' and input_args:
return get_help_option(input_args)
infolist = weechat.infolist_get('hook', '', 'command,%s' % input_cmd)
cmd_plugin_name = ''
cmd_command = ''
cmd_args = ''
cmd_desc = ''
while weechat.infolist_next(infolist):
cmd_plugin_name = (weechat.infolist_string(infolist, 'plugin_name') or
'core')
cmd_command = weechat.infolist_string(infolist, 'command')
cmd_args = weechat.infolist_string(infolist, 'args_nls')
cmd_desc = weechat.infolist_string(infolist, 'description')
if weechat.infolist_pointer(infolist, 'plugin') == plugin:
break
weechat.infolist_free(infolist)
if cmd_plugin_name == 'alias':
return '%sAlias %s%s%s => %s%s' % (
weechat.color(cmdhelp_settings['color_alias']),
weechat.color(cmdhelp_settings['color_alias_name']),
cmd_command,
weechat.color(cmdhelp_settings['color_alias']),
weechat.color(cmdhelp_settings['color_alias_value']),
cmd_desc,
)
if input_args:
cmd_args = get_command_arguments(input_args, cmd_args)
if not cmd_args:
return None
return '%s%s' % (weechat.color(cmdhelp_settings['color_arguments']),
cmd_args)
开发者ID:DarkDefender,项目名称:scripts,代码行数:34,代码来源:cmd_help.py
示例9: allquery_command_cb
def allquery_command_cb(data, buffer, args):
""" Callback for /allquery command """
args = args.strip()
if args == "":
weechat.command("", "/help %s" % SCRIPT_COMMAND)
return weechat.WEECHAT_RC_OK
argv = args.split(" ")
exclude_nick = None
if argv[0].startswith("-exclude="):
exclude_nick = make_list(argv[0])
command = " ".join(argv[1::])
else:
command = args
if not command.startswith("/"):
weechat.command("", "/help %s" % SCRIPT_COMMAND)
return weechat.WEECHAT_RC_OK
infolist = weechat.infolist_get("buffer", "", "")
while weechat.infolist_next(infolist):
if weechat.infolist_string(infolist, "plugin_name") == "irc":
ptr = weechat.infolist_pointer(infolist, "pointer")
server = weechat.buffer_get_string(ptr, "localvar_server")
query = weechat.buffer_get_string(ptr, "localvar_channel")
execute_command = re.sub(r'\b\$nick\b', query, command)
if weechat.buffer_get_string(ptr, "localvar_type") == "private":
if exclude_nick is not None:
if not query in exclude_nick:
weechat.command(ptr, execute_command)
else:
weechat.command(ptr, execute_command)
weechat.infolist_free(infolist)
return weechat.WEECHAT_RC_OK
开发者ID:fbesser,项目名称:weechat_scripts,代码行数:34,代码来源:allquery.py
示例10: gen_infolist_get
def gen_infolist_get(infolist_name, arguments, pointer=""):
"""
Same as infolist_get(), but yields it's elements.
Be sure to iterate through the whole list, to ensure
weechat.infolist_free() is called.
"""
infolist = weechat.infolist_get(infolist_name, pointer, arguments)
if infolist:
while weechat.infolist_next(infolist):
fields = weechat.infolist_fields(infolist).split(',')
field_names = []
list_element = {}
for field in fields:
field_type, field_name = field.split(':')
field_names.append(field_name)
# decide which function to use
info_func = {
'i': weechat.infolist_integer,
's': weechat.infolist_string,
'p': weechat.infolist_pointer,
# 'b': weechat.infolist_buffer,
't': weechat.infolist_time,
}[field_type]
value = info_func(infolist, field_name)
list_element[field_name] = value
# create a temporary namedtuple type using field_names
item_tpl = namedtuple('InfolistItem', field_names)
yield item_tpl(**list_element)
weechat.infolist_free(infolist)
开发者ID:FichteForks,项目名称:knitori-tools,代码行数:30,代码来源:__init__.py
示例11: check_buffer_timer_cb
def check_buffer_timer_cb(data, remaining_calls):
global WEECHAT_VERSION,whitelist
# search for buffers in hotlist
ptr_infolist = weechat.infolist_get("hotlist", "", "")
while weechat.infolist_next(ptr_infolist):
ptr_buffer = weechat.infolist_pointer(ptr_infolist, "buffer_pointer")
localvar_name = weechat.buffer_get_string(ptr_buffer, 'localvar_name')
# buffer in whitelist? go to next buffer
buf_type = weechat.buffer_get_string(ptr_buffer,'localvar_type')
# buffer is a query buffer?
if OPTIONS['ignore_query'].lower() == 'on' and buf_type == 'private':
continue
# buffer in whitelist?
if localvar_name in whitelist:
continue
if ptr_buffer:
if get_time_from_line(ptr_buffer):
if OPTIONS['clear'].lower() == 'hotlist' or OPTIONS['clear'].lower() == 'all':
weechat.buffer_set(ptr_buffer, "hotlist", '-1')
if OPTIONS['clear'].lower() == 'unread' or OPTIONS['clear'].lower() == 'all':
weechat.command(ptr_buffer,"/input set_unread_current_buffer")
weechat.infolist_free(ptr_infolist)
return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:25,代码来源:automarkbuffer.py
示例12: servernicks
def servernicks(servername):
infolist = weechat.infolist_get('irc_server','',servername)
weechat.infolist_next(infolist)
nicks = weechat.infolist_string(infolist, 'nicks')
weechat.infolist_free(infolist)
servernicks = nicks.split(',')
return servernicks
开发者ID:megalithic,项目名称:dotfiles,代码行数:7,代码来源:keepnick.py
示例13: bufsave_cmd
def bufsave_cmd(data, buffer, args):
''' Callback for /bufsave command '''
filename = args
if not filename:
w.command('', '/help %s' %SCRIPT_COMMAND)
return w.WEECHAT_RC_OK
if exists(filename):
w.prnt('', "Error: target file already exists!")
return w.WEECHAT_RC_OK
infolist = w.infolist_get('buffer_lines', buffer, '')
channel = w.buffer_get_string(buffer, 'name')
try:
fp = file(filename, 'w')
except:
w.prnt('', "Error writing to target file!")
return w.WEECHAT_RC_OK
while w.infolist_next(infolist):
fp.write('%s %s %s\n' %(\
w.infolist_time(infolist, 'date'),
cstrip(w.infolist_string(infolist, 'prefix')),
cstrip(w.infolist_string(infolist, 'message')),
))
w.infolist_free(infolist)
return w.WEECHAT_RC_OK
开发者ID:FiXato,项目名称:weechat-scripts-xt,代码行数:31,代码来源:bufsave.py
示例14: hotlist_dict
def hotlist_dict():
"""Return the contents of the hotlist as a dictionary.
The returned dictionary has the following structure:
>>> hotlist = {
... "0x0": { # string representation of the buffer pointer
... "count_low": 0,
... "count_message": 0,
... "count_private": 0,
... "count_highlight": 0,
... }
... }
"""
hotlist = {}
infolist = weechat.infolist_get("hotlist", "", "")
while weechat.infolist_next(infolist):
buffer_pointer = weechat.infolist_pointer(infolist, "buffer_pointer")
hotlist[buffer_pointer] = {}
hotlist[buffer_pointer]["count_low"] = weechat.infolist_integer(
infolist, "count_00")
hotlist[buffer_pointer]["count_message"] = weechat.infolist_integer(
infolist, "count_01")
hotlist[buffer_pointer]["count_private"] = weechat.infolist_integer(
infolist, "count_02")
hotlist[buffer_pointer]["count_highlight"] = weechat.infolist_integer(
infolist, "count_03")
weechat.infolist_free(infolist)
return hotlist
开发者ID:DarkDefender,项目名称:scripts,代码行数:28,代码来源:buffer_autohide.py
示例15: reorder_buffers
def reorder_buffers():
"""Reorders the buffers once the whitelist has changed
"""
count = 2
chan = ""
ilist = weechat.infolist_get("buffer", "", "")
for chan in whitelist:
if -1 == chan.find(".#"): #network name is not set, matching by short_name
weechat.infolist_reset_item_cursor(ilist)
while weechat.infolist_next(ilist):
if weechat.infolist_string(ilist, "short_name") == chan:
chan = weechat.infolist_string(ilist, "name")
break
buff = weechat.buffer_search("irc", chan)
if buff:
weechat.buffer_set(buff, "number", str(count))
count += 1
weechat.infolist_free(ilist)
return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:27,代码来源:chanpriority.py
示例16: reorder_buffers
def reorder_buffers():
global buffers
bufcopy = dict(buffers)
priolist = []
while len(bufcopy):
priolist.append(max(bufcopy, key=bufcopy.get))
bufcopy.pop(max(bufcopy, key=bufcopy.get))
pointerlist = {}
infolist = wee.infolist_get("buffer", "", "")
while wee.infolist_next(infolist): # go through the buffers and jot down relevant pointers
for name in priolist:
try:
bufname = wee.infolist_string(infolist, "name").split('.', 1)[1]
except IndexError:
bufname = wee.infolist_string(infolist, "name")
if name == bufname:
if name in pointerlist:
pointerlist[name].append(
wee.infolist_pointer(infolist, "pointer"))
else:
pointerlist[name] = [wee.infolist_pointer(
infolist, "pointer")]
index = 1
if(maintop):
index += 1
for name in priolist:
if name in pointerlist:
for pointer in pointerlist[name]:
wee.buffer_set(pointer, "number", str(index))
index += 1
return
开发者ID:numerical,项目名称:dotfiles,代码行数:32,代码来源:buffer_priority.py
示例17: get_matching_buffers
def get_matching_buffers(input):
""" Return list with buffers matching user input """
global buffers_pos
list = []
if len(input) == 0:
buffers_pos = 0
input = input.lower()
infolist = weechat.infolist_get("buffer", "", "")
while weechat.infolist_next(infolist):
if weechat.config_get_plugin("short_name") == "on":
name = weechat.infolist_string(infolist, "short_name")
else:
name = weechat.infolist_string(infolist, "name")
number = weechat.infolist_integer(infolist, "number")
matching = name.lower().find(input) >= 0
if not matching and input[-1] == ' ':
matching = name.lower().endswith(input.strip())
if not matching and input.isdigit():
matching = str(number).startswith(input)
if len(input) == 0 or matching:
list.append({"number": number, "name": name})
if len(input) == 0 and weechat.infolist_pointer(infolist, "pointer") == weechat.current_buffer():
buffers_pos = len(list) - 1
weechat.infolist_free(infolist)
return list
开发者ID:GGLucas,项目名称:configs,代码行数:25,代码来源:go.py
示例18: buffer_count
def buffer_count():
buffer_count = 0
buffer = weechat.infolist_get("buffer", "", "")
while weechat.infolist_next(buffer):
buffer_count += 1
weechat.infolist_free(buffer)
return buffer_count
开发者ID:DarkDefender,项目名称:scripts,代码行数:7,代码来源:terminal_title.py
示例19: get_irc_servers
def get_irc_servers():
""" Returns a list of configured IRC servers in weechat"""
serverptrlist = weechat.infolist_get('irc_server', '', '')
serverlist = []
while weechat.infolist_next(serverptrlist):
serverlist.append(weechat.infolist_string(serverptrlist, 'name'))
return serverlist
开发者ID:DarkDefender,项目名称:scripts,代码行数:7,代码来源:undernet_totp.py
示例20: bas_config_option_cb
def bas_config_option_cb(data, option, value):
if not weechat.config_boolean(bas_options["look_instant"]):
return weechat.WEECHAT_RC_OK
if not weechat.config_get(option): # option was deleted
return weechat.WEECHAT_RC_OK
option = option[len("%s.buffer." % CONFIG_FILE_NAME):]
pos = option.rfind(".")
if pos > 0:
buffer_mask = option[0:pos]
property = option[pos+1:]
if buffer_mask and property:
buffers = weechat.infolist_get("buffer", "", buffer_mask)
if not buffers:
return weechat.WEECHAT_RC_OK
while weechat.infolist_next(buffers):
buffer = weechat.infolist_pointer(buffers, "pointer")
weechat.buffer_set(buffer, property, value)
weechat.infolist_free(buffers)
return weechat.WEECHAT_RC_OK
开发者ID:AndyHoang,项目名称:dotfiles,代码行数:26,代码来源:buffer_autoset.py
注:本文中的weechat.infolist_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论