本文整理汇总了Python中weechat.color函数的典型用法代码示例。如果您正苦于以下问题:Python color函数的具体用法?Python color怎么用?Python color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了color函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: imap_get_unread
def imap_get_unread(data):
"""Return the unread count."""
imap = Imap()
if not w.config_get_plugin('message'):
output = ""
else:
output = '%s' % (
string_eval_expression(w.config_get_plugin('message')))
any_with_unread = False
mailboxes = w.config_get_plugin('mailboxes').split(',')
count = []
for mailbox in mailboxes:
mailbox = mailbox.strip()
unreadCount = imap.unreadCount(mailbox)
if unreadCount > 0:
any_with_unread = True
count.append('%s%s: %s%s' % (
w.color(w.config_get_plugin('mailbox_color')),
mailbox,
w.color(w.config_get_plugin('count_color')),
unreadCount))
imap.logout()
sep = '%s' % (
string_eval_expression(w.config_get_plugin('separator')))
output = output + sep.join(count) + w.color('reset')
return output if any_with_unread else ''
开发者ID:oakkitten,项目名称:scripts,代码行数:27,代码来源:imap_status.py
示例2: get_list_commands
def get_list_commands(plugin, input_cmd, input_args):
"""Get list of commands (beginning with current input)."""
global cmdhelp_settings
infolist = weechat.infolist_get('hook', '', 'command,%s*' % input_cmd)
commands = []
plugin_names = []
while weechat.infolist_next(infolist):
commands.append(weechat.infolist_string(infolist, 'command'))
plugin_names.append(
weechat.infolist_string(infolist, 'plugin_name') or 'core')
weechat.infolist_free(infolist)
if commands:
if len(commands) > 1 or commands[0].lower() != input_cmd.lower():
commands2 = []
for index, command in enumerate(commands):
if commands.count(command) > 1:
commands2.append('%s(%s)' % (command, plugin_names[index]))
else:
commands2.append(command)
return '%s%d commands: %s%s' % (
weechat.color(cmdhelp_settings['color_list_count']),
len(commands2),
weechat.color(cmdhelp_settings['color_list']),
', '.join(commands2))
return None
开发者ID:DarkDefender,项目名称:scripts,代码行数:25,代码来源:cmd_help.py
示例3: print_as_lines
def print_as_lines(target, matches, data, limit, total):
"""Prints the output as a line-separated list of nicks."""
prefix = fmt_prefix(data)
mstring = "{}{}".format(fmt_mode_char(data["mode"]), "" if data["set"] else " removal")
mask = fmt_banmask(data["mask"])
target_in_prefix = "_target_" in prefix
i = 0
for name in matches:
if target_in_prefix:
pf = prefix.replace("_target_", "{}{}{}".format(
w.color(w.info_get("irc_nick_color_name", name)),
name, w.color("reset")))
else:
pf = prefix
if (total - (limit - i) == 1) or (i >= limit):
left = total - i
left -= 1 if target_in_prefix else 0
w.prnt(target, "{}\tand {} more match{}..".format(pf, left, "es" if left != 1 else ""))
break
if target_in_prefix:
w.prnt(target, "{}\tmatches {} {}".format(pf, mstring, mask))
else:
w.prnt(target, "{}\t{} {} matches {}".format(pf, mstring, mask, fmt_nick(name)))
i += 1
开发者ID:DarkDefender,项目名称:scripts,代码行数:29,代码来源:maskmatch.py
示例4: 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)
开发者ID:DarkDefender,项目名称:scripts,代码行数:33,代码来源:cmd_help.py
示例5: get_help_option
def get_help_option(input_args):
"""Get help about option or values authorized for option."""
global cmdhelp_settings, cmdhelp_option_infolist
global cmdhelp_option_infolist_fields
pos = input_args.find(' ')
if pos > 0:
option = input_args[0:pos]
else:
option = input_args
options, description = get_option_list_and_desc(option, False)
if not options and not description:
options, description = get_option_list_and_desc('%s*' % option, True)
if len(options) > 1:
try:
max_options = int(cmdhelp_settings['max_options'])
except ValueError:
max_options = 5
if len(options) > max_options:
text = '%s...' % ', '.join(options[0:max_options])
else:
text = ', '.join(options)
return '%s%d options: %s%s' % (
weechat.color(cmdhelp_settings['color_list_count']),
len(options),
weechat.color(cmdhelp_settings['color_list']),
text)
if description:
return '%s%s' % (weechat.color(cmdhelp_settings['color_option_help']),
description)
return '%sNo help for option %s' % (
weechat.color(cmdhelp_settings['color_no_help']), option)
开发者ID:DarkDefender,项目名称:scripts,代码行数:31,代码来源:cmd_help.py
示例6: vdm_display
def vdm_display(vdm):
""" Display VDMs in buffer. """
global vdm_buffer
weechat.buffer_set(vdm_buffer, "unread", "1")
if weechat.config_get_plugin("number_as_prefix") == "on":
separator = "\t"
else:
separator = " > "
colors = weechat.config_get_plugin("colors").split(";");
vdm2 = vdm[:]
if weechat.config_get_plugin("reverse") == "on":
vdm2.reverse()
for index, item in enumerate(vdm2):
item_id = item["id"]
item_text = item["text"]
if sys.version_info < (3,):
# python 2.x: convert unicode to str (in python 3.x, id and text are already strings)
item_id = item_id.encode("UTF-8")
item_text = item_text.encode("UTF-8")
weechat.prnt_date_tags(vdm_buffer,
0, "notify_message",
"%s%s%s%s%s" %
(weechat.color(weechat.config_get_plugin("color_number")),
item_id,
separator,
weechat.color(colors[0]),
item_text))
colors.append(colors.pop(0))
if index == len(vdm) - 1:
weechat.prnt(vdm_buffer, "------")
elif weechat.config_get_plugin("blank_line") == "on":
weechat.prnt(vdm_buffer, "")
开发者ID:norrs,项目名称:weechat-plugins,代码行数:32,代码来源:vdm.py
示例7: find_and_process_urls
def find_and_process_urls(string, use_color=True):
new_message = string
color = weechat.color(weechat.config_get_plugin("color"))
reset = weechat.color('reset')
for url in urlRe.findall(string):
max_url_length = int(weechat.config_get_plugin('urllength'))
if len(url) > max_url_length and not should_ignore_url(url):
short_url = get_shortened_url(url)
if use_color:
new_message = new_message.replace(
url, '%(url)s %(color)s[%(short_url)s]%(reset)s' % dict(
color=color,
short_url=short_url,
reset=reset,
url=url
)
)
else:
new_message = new_message.replace(url, short_url)
elif use_color:
# Highlight the URL, even if we aren't going to shorting it
new_message = new_message.replace(
url, '%(color)s %(url)s %(reset)s' % dict(
color=color,
reset=reset,
url=url
)
)
return new_message
开发者ID:H0bby,项目名称:dotfiles,代码行数:32,代码来源:shortenurl.py
示例8: conversation_cb
def conversation_cb(data, buffer, args):
"""
Follows the reply trail until the original was found.
NOTE: This might block for a while.
"""
global twitter
conversation = []
reply_id = args
# Loop as long as there was a reply_id.
while reply_id:
try:
conversation.append(twitter.get_tweet(reply_id))
reply_id = conversation[-1].in_reply_to_status_id
except TwitterError as error:
print_error(error)
break
if conversation:
# Reverse the conversation to get the oldest first.
conversation.reverse()
# Now display the conversation.
print_to_current("%s-------------------" % wc.color("magenta"))
for tweet in conversation:
nick_color = wc.info_get("irc_nick_color", tweet.screen_name)
screen_name = nick_color + tweet.screen_name
expand_urls = wc.config_string_to_boolean(wc.config_get_plugin("expand_urls"))
text = tweet.txt_unescaped
if expand_urls:
text = tweet.txt
output = "%s\t%s" % (screen_name, text)
if tweet.is_retweet:
output += " (RT by @%s)" % tweet.rtscreen_name
output += "\n[#STATUSID: %s]" % tweet.id
print_to_current(output)
print_to_current("%s-------------------" % wc.color("magenta"))
return wc.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weetwit,代码行数:35,代码来源:weetwit.py
示例9: show_favorites_cb
def show_favorites_cb(data, buffer, args):
"""
Show all the tweets that are favourited by the user.
"""
global twitter
try:
favs = twitter.get_favorites()
except TwitterError as error:
print_error(error)
return wc.WEECHAT_RC_OK
if favs:
print_to_current("%sFAVOURITES\t%s-------------------" %
(wc.color("yellow"), wc.color("magenta")))
for fav in favs:
nick_color = wc.info_get("irc_nick_color", fav.screen_name)
screen_name = nick_color + fav.screen_name
expand_urls = wc.config_string_to_boolean(wc.config_get_plugin("expand_urls"))
text = fav.text_unescaped
if expand_urls:
text = fav.text
output = "%s\t%s" % (screen_name, text)
if fav.is_retweet:
output += " (RT by @%s)" % fav.rtscreen_name
output += "\n[#STATUSID: %s]" % fav.id
print_to_current(output)
print_to_current("%s-------------------" % wc.color("magenta"))
return wc.WEECHAT_RC_OK
开发者ID:ainmosni,项目名称:weetwit,代码行数:27,代码来源:weetwit.py
示例10: urlbar_item_cb
def urlbar_item_cb(data, item, window):
''' Callback that prints the lines in the urlbar '''
global DISPLAY_ALL, urls
try:
visible_amount = int(weechat.config_get_plugin('visible_amount'))
except ValueError:
weechat.prnt('', 'Invalid value for visible_amount setting.')
if not urls:
return 'Empty URL list'
if DISPLAY_ALL:
DISPLAY_ALL = False
printlist = urls
else:
printlist = urls[-visible_amount:]
result = ''
for index, url in enumerate(printlist):
if weechat.config_get_plugin('show_index') == 'on':
index = index+1
result += '%s%2d%s %s \r' %\
(weechat.color("yellow"), index, weechat.color("bar_fg"), url)
else:
result += '%s%s \r' %(weechat.color('bar_fg'), url)
return result
开发者ID:DarkDefender,项目名称:scripts,代码行数:26,代码来源:urlbar.py
示例11: refresh_line
def refresh_line(self, y):
format = "%%s%%s %%s%%-%ds%%s%%s %%s - %%s" % (self.max_buffer_width-4)
color_time = "cyan"
color_buffer = "red"
color_info = "green"
color_url = "blue"
color_bg_selected = "red"
if y == self.current_line:
color_time = "%s,%s" % (color_time, color_bg_selected)
color_buffer = "%s,%s" % (color_buffer, color_bg_selected)
color_info = "%s,%s" % (color_info, color_bg_selected)
color_url = "%s,%s" % (color_url, color_bg_selected)
color_time = weechat.color(color_time)
color_buffer = weechat.color(color_buffer)
color_info = weechat.color(color_info)
color_url = weechat.color(color_url)
text = ''
if len(self.urls) - 1 > y :
url = self.urls[y]
url_info = self.url_infos[url]
text = format % (color_time,
url_info['time'],
color_buffer,
url_info['buffer'],
color_info,
url_info['info'],
color_url,
url_info['url']
)
weechat.prnt_y(self.url_buffer,y,text)
开发者ID:seiji,项目名称:weechat-linkmon,代码行数:33,代码来源:urlhangar.py
示例12: nameday_print
def nameday_print(days):
"""Print name day for today and option N days in future."""
global nameday_i18n
today = date.today()
current_time = time.time()
string = '%02d/%02d: %s' % (today.day, today.month,
nameday_get_date(today, gender=True,
colorMale='color_male',
colorFemale='color_female'))
if days < 0:
days = 0
elif days > 50:
days = 50
if days > 0:
string += '%s (' % weechat.color('reset')
for i in range(1, days + 1):
if i > 1:
string += '%s, ' % weechat.color('reset')
date2 = date.fromtimestamp(current_time + ((3600 * 24) * i))
string += '%02d/%02d: %s' % (date2.day, date2.month,
nameday_get_date(date2, gender=True,
colorMale='color_male',
colorFemale='color_female'))
string += '%s)' % weechat.color('reset')
weechat.prnt('', string)
开发者ID:DarkDefender,项目名称:scripts,代码行数:25,代码来源:nameday.py
示例13: tc_bar_item
def tc_bar_item (data, item, window):
'''Item constructor'''
global laenge, cursor_pos, tc_input_text, count_over
count_over = "0"
# reverse check for max_chars
reverse_chars = (int(max_chars) - laenge)
if reverse_chars == 0:
reverse_chars = "%s" % ("0")
else:
if reverse_chars < 0:
count_over = "%s%s%s" % (w.color(warn_colour),str(reverse_chars*-1), w.color('default'))
reverse_chars = "%s" % ("0")
else:
reverse_chars = str(reverse_chars)
out_format = format
if laenge >= int(warn):
laenge_warn = "%s%s%s" % (w.color(warn_colour), str(laenge), w.color('default'))
out_format = out_format.replace('%L', laenge_warn)
else:
out_format = out_format.replace('%L', str(laenge))
out_format = out_format.replace('%P', str(cursor_pos))
out_format = out_format.replace('%R', reverse_chars)
out_format = out_format.replace('%C', count_over)
tc_input_text = out_format
return tc_input_text
开发者ID:atoponce,项目名称:dotfiles,代码行数:27,代码来源:typing_counter.py
示例14: search_whois_cb
def search_whois_cb(data, signal, hashtable):
ht = hashtable["output"] # string
ret = re.search(r"(\S+) \* :(.+)$", ht, re.M)
if ret:
masked_ip = ret.group(1)
w.prnt_date_tags("", 0, "no_log", "RESULT about {}{}".format(w.color("*lightblue"), masked_ip))
lst = stick(masked_ip)
for dic in lst:
w.prnt_date_tags(
"",
0,
"no_log",
"\n ".join(
[
"{}#{}: {}".format(w.color("_lightgreen"), dic["number"], dic["login_time"]),
"names: {}{}{} / {} / {}".format(
w.color("*lightred"),
dic["login_nick"][0],
w.color("chat"),
dic["login_nick"][1],
dic["login_nick"][2],
),
"channels: {}".format(dic["login_channels"]),
]
),
)
# else:
# w.prnt_date_tags("", 0, "no_log", "error: Not Found MASKED_IP")
return w.WEECHAT_RC_OK
开发者ID:rosalind8,项目名称:my_weechat_scripts,代码行数:29,代码来源:search.py
示例15: tc_bar_item
def tc_bar_item (data, item, window):
'''Item constructor'''
global length, cursor_pos, tc_input_text, count_over,tc_options
count_over = '0'
# reverse check for max_chars
reverse_chars = (int(tc_options['max_chars']) - length)
# reverse_chars = (int(max_chars) - length)
if reverse_chars == 0:
reverse_chars = "%s" % ("0")
else:
if reverse_chars < 0:
count_over = "%s%s%s" % (w.color(tc_options['warn_colour']),str(reverse_chars*-1), w.color('default'))
reverse_chars = "%s" % ("0")
tc_action_cb()
else:
reverse_chars = str(reverse_chars)
out_format = tc_options['format']
if length >= int(tc_options['warn']):
length_warn = "%s%s%s" % (w.color(tc_options['warn_colour']), str(length), w.color('default'))
out_format = out_format.replace('%L', length_warn)
else:
out_format = out_format.replace('%L', str(length))
out_format = out_format.replace('%P', str(cursor_pos))
out_format = out_format.replace('%R', reverse_chars)
out_format = out_format.replace('%C', count_over)
tc_input_text = out_format
return tc_input_text
开发者ID:frumiousbandersnatch,项目名称:weechat-scripts,代码行数:30,代码来源:typing_counter.py
示例16: show_spell_suggestion_item_cb
def show_spell_suggestion_item_cb (data, item, window):
buffer = weechat.window_get_pointer(window,"buffer")
if buffer == '':
return ''
if OPTIONS['replace_mode'].lower() == "on":
if not weechat.buffer_get_string(buffer,'localvar_inline_suggestions'):
return ''
tab_complete,position,aspell_suggest_items = weechat.buffer_get_string(buffer,'localvar_inline_suggestions').split(':',2)
return aspell_suggest_items
tab_complete,position,aspell_suggest_item = get_position_and_suggest_item(buffer)
localvar_aspell_suggest = get_localvar_aspell_suggest(buffer)
# localvar_aspell_suggest = word,word2/wort,wort2
if localvar_aspell_suggest:
misspelled_word,aspell_suggestions = localvar_aspell_suggest.split(':')
aspell_suggestions_orig = aspell_suggestions
aspell_suggestions = aspell_suggestions.replace('/',',')
aspell_suggestion_list = aspell_suggestions.split(',')
if not position:
return ''
if int(position) < len(aspell_suggestion_list):
reset_color = weechat.color('reset')
color = weechat.color("red")
new_word = aspell_suggestion_list[int(position)].replace(aspell_suggestion_list[int(position)],'%s%s%s' % (color, aspell_suggestion_list[int(position)], reset_color))
else:
return ''
return aspell_suggestions_orig
开发者ID:FiXato,项目名称:weechat-scripts,代码行数:31,代码来源:spell_correction.py
示例17: go_buffers_to_string
def go_buffers_to_string(listbuf, pos, strinput):
"""Return string built with list of buffers found (matching user input)."""
string = ''
strinput = strinput.lower()
for i in range(len(listbuf)):
selected = '_selected' if i == pos else ''
index = listbuf[i]['name'].lower().find(strinput)
if index >= 0:
index2 = index + len(strinput)
name = '%s%s%s%s%s' % (
listbuf[i]['name'][:index],
weechat.color(weechat.config_get_plugin(
'color_name_highlight' + selected)),
listbuf[i]['name'][index:index2],
weechat.color(weechat.config_get_plugin(
'color_name' + selected)),
listbuf[i]['name'][index2:])
else:
name = listbuf[i]['name']
string += ' %s%s%s%s%s' % (
weechat.color(weechat.config_get_plugin(
'color_number' + selected)),
str(listbuf[i]['number']),
weechat.color(weechat.config_get_plugin(
'color_name' + selected)),
name,
weechat.color('reset'))
return ' ' + string if string else ''
开发者ID:Gres,项目名称:dotfiles,代码行数:28,代码来源:go.py
示例18: print_tweet_data
def print_tweet_data(buffer,tweets,data):
for message in tweets:
nick = message[1]
text = message[3]
reply_id = ""
if script_options['tweet_nicks']:
parse_for_nicks(text,buffer)
add_to_nicklist(buffer,nick,tweet_nicks_group[buffer])
if script_options['print_id']:
t_id = weechat.color('reset') + ' ' + dict_tweet(message[2])
else:
t_id = ''
if len(message) == 5:
#This is a reply to a tweet
arrow_col = weechat.color('chat_prefix_suffix')
reset_col = weechat.color('reset')
reply_id = arrow_col + "<" + reset_col + dict_tweet(message[4]) + arrow_col + "> " + reset_col
temp_text = text
text = reply_id
reply_id = temp_text
weechat.prnt_date_tags(buffer, message[0], "notify_message",
"%s%s\t%s%s" % (nick, t_id, text,reply_id))
if data == "id":
try:
if script_options['last_id'] < tweets[-1][2]:
script_options['last_id'] = tweets[-1][2]
# Save last id
weechat.config_set_plugin("last_id",script_options["last_id"])
except:
pass
开发者ID:Arlefreak,项目名称:dotfiles,代码行数:34,代码来源:weetweet.py
示例19: format_weather
def format_weather(weather_data):
'''
Formats the weather data dictionary received from Google
Returns:
output: a string of formatted weather data.
'''
output = weechat.color(weechat.config_get_plugin('output_color')) + weechat.config_get_plugin('format')
output = output.replace('%C', weechat.config_get_plugin('city'))
temp = 'N/A'
condition = 'N/A'
if weather_data:
if len(weather_data['current_conditions']):
if weechat.config_get_plugin('unit') == 'F':
temp = weather_data['current_conditions']['temp_f'].encode('utf-8')
else:
temp = weather_data['current_conditions']['temp_c'].encode('utf-8')
if weather_data['current_conditions'].has_key('condition'):
condition = weather_data['current_conditions']['condition'].encode('utf-8')
output = output.replace('%D', temp)
output = output.replace('%O', condition)
output = output.replace('%U', weechat.config_get_plugin('unit'))
output += weechat.color('reset')
return output
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:30,代码来源:gweather.py
示例20: hook_commands_and_completions
def hook_commands_and_completions():
compl_list = []
com_list = []
desc_list = []
for command in sorted(command_dict):
compl_list.append(command)
com_list.append(command + weechat.color("*red") + " or " +
weechat.color('reset') + command_dict[command] + "\n")
desc_list.append(weechat.color("chat_nick_other") + command + ": \n" + desc_dict[command])
weechat.hook_command("twitter", "Command to interact with the twitter api/plugin",
" | ".join(com_list),
"You can type all of these command in the twitter buffer if you add a ':' before the command, IE:\n"
":limits\n\n"
"If you don't type a command in the twitter buffer you will tweet that instead,\n"
"text after 140 chars will turn red to let you know were twitter will cut off your tweet.\n\n"
+ weechat.color("*red") + "NOTE:\n"
"There are limits on how many twitter api calls you can do, some calls are _quite_ restricted.\n"
"So if you get HTML errors from the twitter lib you probably exceeded the limit\n"
"you can check out your limits with the rate_limits/limits command.\n"
"_Most_ commands in this plugin only uses one call. If you want to check old tweets\n"
"in your home timeline it's better to request many tweets in one go.\n"
"That way you don't have to request new tweets as often to go further back in the timeline.\n"
"And thus you are less likely to hit the limit of requests you can do in the 15 min time window.\n"
"\nYou can write newlines in your tweet with html newline ' ' (you can autocomplete it)\n"
"\nThe 'number' next to the nicks in the chat window is the <id> of the tweet it's used\n"
"in the some of the twitter plugin commands.\n\n"
"Command desc:\n"+ "\n".join(desc_list),
" || ".join(compl_list),
"my_command_cb", "")
开发者ID:Arlefreak,项目名称:dotfiles,代码行数:29,代码来源:weetweet.py
注:本文中的weechat.color函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论