本文整理汇总了Python中weechat.infolist_pointer函数的典型用法代码示例。如果您正苦于以下问题:Python infolist_pointer函数的具体用法?Python infolist_pointer怎么用?Python infolist_pointer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了infolist_pointer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: get_all_buffers
def get_all_buffers():
'''Returns list with pointers of all open buffers.'''
buffers = []
infolist = w.infolist_get('buffer', '', '')
while w.infolist_next(infolist):
buffer_type = w.buffer_get_string(w.infolist_pointer(infolist, 'pointer'), 'localvar_type')
if buffer_type == 'private': # we only close private message buffers for now
buffers.append(w.infolist_pointer(infolist, 'pointer'))
w.infolist_free(infolist)
return buffers
示例4: get_all_buffers
def get_all_buffers():
"""Returns list with pointers of all open buffers."""
buffers = []
infolist = w.infolist_get("buffer", "", "")
while w.infolist_next(infolist):
buffer_type = w.buffer_get_string(w.infolist_pointer(infolist, "pointer"), "localvar_type")
if buffer_type == "private": # we only close private message buffers for now
buffers.append(w.infolist_pointer(infolist, "pointer"))
w.infolist_free(infolist)
return buffers
示例5: 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
示例6: save_query_buffer_to_file
def save_query_buffer_to_file():
global query_buffer_list
ptr_infolist_buffer = weechat.infolist_get("buffer", "", "")
while weechat.infolist_next(ptr_infolist_buffer):
ptr_buffer = weechat.infolist_pointer(ptr_infolist_buffer, "pointer")
type = weechat.buffer_get_string(ptr_buffer, "localvar_type")
if type == "private":
server = weechat.buffer_get_string(ptr_buffer, "localvar_server")
channel = weechat.buffer_get_string(ptr_buffer, "localvar_channel")
query_buffer_list.insert(0, "%s %s" % (server, channel))
weechat.infolist_free(ptr_infolist_buffer)
filename = get_filename_with_path()
if len(query_buffer_list):
try:
f = open(filename, "w")
i = 0
while i < len(query_buffer_list):
f.write("%s\n" % query_buffer_list[i])
i = i + 1
f.close()
except:
weechat.prnt(
"", '%s%s: Error writing query buffer to "%s"' % (weechat.prefix("error"), SCRIPT_NAME, filename)
)
raise
else: # no query buffer(s). remove file
if os.path.isfile(filename):
os.remove(filename)
return
示例7: disable_logging
def disable_logging(self):
"""Return the previous logger level and set the buffer logger level
to 0. If it was already 0, return None."""
# If previous_log_level has not been previously set, return the level
# we detect now.
if not hasattr(self, 'previous_log_level'):
infolist = weechat.infolist_get('logger_buffer', '', '')
buf = self.buffer()
previous_log_level = 0
while weechat.infolist_next(infolist):
if weechat.infolist_pointer(infolist, 'buffer') == buf:
previous_log_level = weechat.infolist_integer(
infolist, 'log_level')
if self.is_logged():
weechat.command(buf, '/mute logger disable')
self.print_buffer(
'Logs have been temporarily disabled for the session. They will be restored upon finishing the OTR session.')
break
weechat.infolist_free(infolist)
return previous_log_level
# If previous_log_level was already set, it means we already altered it
# and that we just detected an already modified logging level.
# Return the pre-existing value so it doesn't get lost, and we can
# restore it later.
else:
return self.previous_log_level
示例8: save_query_buffer_to_file
def save_query_buffer_to_file():
global query_buffer_list
ptr_infolist_buffer = weechat.infolist_get('buffer', '', '')
while weechat.infolist_next(ptr_infolist_buffer):
ptr_buffer = weechat.infolist_pointer(ptr_infolist_buffer,'pointer')
type = weechat.buffer_get_string(ptr_buffer, 'localvar_type')
if type == 'private':
server = weechat.buffer_get_string(ptr_buffer, 'localvar_server')
channel = weechat.buffer_get_string(ptr_buffer, 'localvar_channel')
query_buffer_list.insert(0,"%s %s" % (server,channel))
weechat.infolist_free(ptr_infolist_buffer)
filename = get_filename_with_path()
if len(query_buffer_list):
try:
f = open(filename, 'w')
i = 0
while i < len(query_buffer_list):
f.write('%s\n' % query_buffer_list[i])
i = i + 1
f.close()
except:
weechat.prnt('','%s%s: Error writing query buffer to "%s"' % (weechat.prefix('error'), SCRIPT_NAME, filename))
raise
else: # no query buffer(s). remove file
if os.path.isfile(filename):
os.remove(filename)
return
示例9: format_option
def format_option(match):
"""Replace ${xxx} by its value in option format."""
global cmdhelp_settings, cmdhelp_option_infolist
global cmdhelp_option_infolist_fields
string = match.group()
end = string.find('}')
if end < 0:
return string
field = string[2:end]
color1 = ''
color2 = ''
pos = field.find(':')
if pos:
color1 = field[0:pos]
field = field[pos+1:]
if color1:
color1 = weechat.color(color1)
color2 = weechat.color(cmdhelp_settings['color_option_help'])
fieldtype = cmdhelp_option_infolist_fields.get(field, '')
if fieldtype == 'i':
string = str(weechat.infolist_integer(cmdhelp_option_infolist, field))
elif fieldtype == 's':
string = weechat.infolist_string(cmdhelp_option_infolist, field)
elif fieldtype == 'p':
string = weechat.infolist_pointer(cmdhelp_option_infolist, field)
elif fieldtype == 't':
date = weechat.infolist_time(cmdhelp_option_infolist, field)
# since WeeChat 2.2, infolist_time returns a long integer instead of
# a string
if not isinstance(date, str):
date = time.strftime('%F %T', time.localtime(int(date)))
string = date
return '%s%s%s' % (color1, string, color2)
示例10: 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
示例11: update_title
def update_title(data, signal, signal_data):
''' The callback that adds title. '''
if w.config_get_plugin('short_name') == 'on':
title = w.buffer_get_string(w.current_buffer(), 'short_name')
else:
title = w.buffer_get_string(w.current_buffer(), 'name')
hotlist = w.infolist_get('hotlist', '', '')
hot_text = ''
while w.infolist_next(hotlist):
priority = w.infolist_integer(hotlist, 'priority')
if priority >= int(w.config_get_plugin('title_priority')):
number = w.infolist_integer(hotlist, 'buffer_number')
thebuffer = w.infolist_pointer(hotlist, 'buffer_pointer')
name = w.buffer_get_string(thebuffer, 'short_name')
hot_text += ' %s' % number
if hot_text:
title += ' [A:%s]' % hot_text
w.infolist_free(hotlist)
w.window_set_title(title)
return w.WEECHAT_RC_OK
示例12: 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
示例13: format_option
def format_option(match):
"""Replace ${xxx} by its value in option format."""
global cmdhelp_settings, cmdhelp_option_infolist, cmdhelp_option_infolist_fields
string = match.group()
end = string.find('}')
if end < 0:
return string
field = string[2:end]
color1 = ''
color2 = ''
pos = field.find(':')
if pos:
color1 = field[0:pos]
field = field[pos+1:]
if color1:
color1 = weechat.color(color1)
color2 = weechat.color(cmdhelp_settings['color_option_help'])
fieldtype = cmdhelp_option_infolist_fields.get(field, '')
if fieldtype == 'i':
string = str(weechat.infolist_integer(cmdhelp_option_infolist, field))
elif fieldtype == 's':
string = weechat.infolist_string(cmdhelp_option_infolist, field)
elif fieldtype == 'p':
string = weechat.infolist_pointer(cmdhelp_option_infolist, field)
elif fieldtype == 't':
string = weechat.infolist_time(cmdhelp_option_infolist, field)
return '%s%s%s' % (color1, string, color2)
示例14: 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
示例15: 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