本文整理汇总了Python中weechat.config_read函数的典型用法代码示例。如果您正苦于以下问题:Python config_read函数的具体用法?Python config_read怎么用?Python config_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_read函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_own_config_file
def init_own_config_file():
# set up configuration options and load config file
global CONFIG_FILE, CONFIG_SECTIONS
CONFIG_FILE = weechat.config_new(SCRIPT_NAME, '', '')
CONFIG_SECTIONS = {}
CONFIG_SECTIONS['section_name'] = weechat.config_new_section(
CONFIG_FILE, 'section_name', 0, 0, '', '', '', '', '', '', '', '', '', '')
for option, typ, desc, default in [
('option_name',
'boolean',
'option description',
'off'),
('option_name2',
'boolean',
'option name2 description ',
'on'),
('option_name3',
'string',
'option name3 description',
''),
('option_name4',
'string',
'option name4 description',
'set an default string here'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['section_name'], option, typ, desc, '', 0,
0, default, default, 0, '', '', '', '', '', '')
weechat.config_read(CONFIG_FILE)
示例2: __init__
def __init__(self, filename):
''' Initialize the configuration. '''
self.filename = filename
self.config_file = weechat.config_new(self.filename, '', '')
self.sorting_section = None
self.case_sensitive = False
self.group_irc = True
self.rules = []
self.highest = 0
self.__case_sensitive = None
self.__group_irc = None
self.__rules = None
if not self.config_file:
log('Failed to initialize configuration file "{}".'.format(self.filename))
return
self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')
if not self.sorting_section:
log('Failed to initialize section "sorting" of configuration file.')
weechat.config_free(self.config_file)
return
self.__case_sensitive = weechat.config_new_option(
self.config_file, self.sorting_section,
'case_sensitive', 'boolean',
'If this option is on, sorting is case sensitive.',
'', 0, 0, 'off', 'off', 0,
'', '', '', '', '', ''
)
self.__group_irc = weechat.config_new_option(
self.config_file, self.sorting_section,
'group_irc', 'boolean',
'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
'This ensures that thsee buffers are grouped with their respective server buffer.',
'', 0, 0, 'on', 'on', 0,
'', '', '', '', '', ''
)
self.__rules = weechat.config_new_option(
self.config_file, self.sorting_section,
'rules', 'string',
'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
'', 0, 0, Config.default_rules, Config.default_rules, 0,
'', '', '', '', '', ''
)
if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to load configuration file.')
if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to write configuration file.')
self.reload()
示例3: fish_config_read
def fish_config_read():
global fish_config_file
return weechat.config_read(fish_config_file)
示例4: __init__
def __init__(self, filename):
''' Initialize the configuration. '''
self.filename = filename
self.config_file = weechat.config_new(self.filename, '', '')
self.sorting_section = None
self.v3_section = None
self.case_sensitive = False
self.rules = []
self.helpers = {}
self.signals = []
self.signal_delay = Config.default_signal_delay,
self.sort_on_config = True
self.__case_sensitive = None
self.__rules = None
self.__helpers = None
self.__signals = None
self.__signal_delay = None
self.__sort_on_config = None
if not self.config_file:
log('Failed to initialize configuration file "{0}".'.format(self.filename))
return
self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')
self.v3_section = weechat.config_new_section(self.config_file, 'v3', False, False, '', '', '', '', '', '', '', '', '', '')
if not self.sorting_section:
log('Failed to initialize section "sorting" of configuration file.')
weechat.config_free(self.config_file)
return
self.__case_sensitive = weechat.config_new_option(
self.config_file, self.sorting_section,
'case_sensitive', 'boolean',
'If this option is on, sorting is case sensitive.',
'', 0, 0, 'off', 'off', 0,
'', '', '', '', '', ''
)
weechat.config_new_option(
self.config_file, self.sorting_section,
'rules', 'string',
'Sort rules used by autosort v2.x and below. Not used by autosort anymore.',
'', 0, 0, '', '', 0,
'', '', '', '', '', ''
)
weechat.config_new_option(
self.config_file, self.sorting_section,
'replacements', 'string',
'Replacement patterns used by autosort v2.x and below. Not used by autosort anymore.',
'', 0, 0, '', '', 0,
'', '', '', '', '', ''
)
self.__rules = weechat.config_new_option(
self.config_file, self.v3_section,
'rules', 'string',
'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
'', 0, 0, Config.default_rules, Config.default_rules, 0,
'', '', '', '', '', ''
)
self.__helpers = weechat.config_new_option(
self.config_file, self.v3_section,
'helpers', 'string',
'A dictionary helper variables to use in the sorting rules, encoded as JSON. See /help autosort for commands to manipulate these helpers.',
'', 0, 0, Config.default_helpers, Config.default_helpers, 0,
'', '', '', '', '', ''
)
self.__signals = weechat.config_new_option(
self.config_file, self.sorting_section,
'signals', 'string',
'A space separated list of signals that will cause autosort to resort your buffer list.',
'', 0, 0, Config.default_signals, Config.default_signals, 0,
'', '', '', '', '', ''
)
self.__signal_delay = weechat.config_new_option(
self.config_file, self.sorting_section,
'signal_delay', 'integer',
'Delay in milliseconds to wait after a signal before sorting the buffer list. This prevents triggering many times if multiple signals arrive in a short time. It can also be needed to wait for buffer localvars to be available.',
'', 0, 1000, str(Config.default_signal_delay), str(Config.default_signal_delay), 0,
'', '', '', '', '', ''
)
self.__sort_on_config = weechat.config_new_option(
self.config_file, self.sorting_section,
'sort_on_config_change', 'boolean',
'Decides if the buffer list should be sorted when autosort configuration changes.',
'', 0, 0, 'on', 'on', 0,
'', '', '', '', '', ''
)
if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to load configuration file.')
#.........这里部分代码省略.........
示例5: WeeNSServer
######################################
# Main
######################################
if __name__ == "__main__":
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, '',
'wee_ns_script_unload_cb'):
weechat.hook_completion('ns_send', 'login completion',
'wee_ns_hook_completion_send', '')
weechat.hook_command('ns', 'weeNetsoul: A netsoul plugin for weechat',
' | '.join("%s%s" % (k, "" if 'desc' not in v
else " " + v['desc'])
for k, v in hook_cmd_ns.items()),
'\n'.join("%s: %s" % (k, v['cb'].__doc__)
for k, v in hook_cmd_ns.items()),
' || '.join("%s%s" % (k, "" if 'compl' not in v
else " " + v['compl'])
for k, v in hook_cmd_ns.items()),
'wee_ns_hook_cmd_ns', '')
wee_ns_config_file = weechat.config_new(SCRIPT_NAME, '', '')
wee_ns_conf_serv_sect = weechat.config_new_section(wee_ns_config_file,
'server', 0, 0,
('wee_ns_serv_'
'sect_read_cb'),
'', '', '', '', '',
'', '', '', '')
server = WeeNSServer()
weechat.config_read(wee_ns_config_file)
weechat.config_write(wee_ns_config_file)
示例6: len
msg = ' '.join(arglist[2:])
server.getChatByRecipient(groups[0], groups[1], create = True).send(msg)
else :
weechat.prnt(buffer, 'Message recipient must be of type login_x[:fd]')
elif arglist[0] == 'who' and server.isConnected() and len(arglist) > 1 :
server._ns_user_cmd_who(arglist[1])
elif arglist[0] == 'state' and server.isConnected() and len(arglist) > 1 :
server._ns_state(arglist[1])
else :
weechat.prnt(buffer, '%sNo such command, wrong argument count, or you need to (dis)connect' % weechat.prefix('error'))
return weechat.WEECHAT_RC_OK
######################################
# Main
######################################
if __name__ == "__main__" :
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', 'weeNS_script_unload_cb'):
weechat.hook_command('ns', 'weeNetsoul main command', 'connect | disconnect | send <login> <msg> | state <status> | who <login>',
" connect : Connect\n"
" disconnect : Diconnect\n"
" send : Send <msg> to <login> (any client) or to <:fd> (unique client)\n"
" state : Change status to <status> (en ligne/actif/whatever)\n"
" who : Show infos about <login>\n",
'connect|disconnect|send|state|who', 'weeNS_hook_cmd_ns', '')
weeNS_config_file = weechat.config_new(SCRIPT_NAME, '', '')
weeNS_config_server_section = weechat.config_new_section(weeNS_config_file, 'server', 0, 0, 'weeNS_server_section_read_cb', '', '', '', '', '', '', '', '', '')
server = weeNSServer()
weechat.config_read(weeNS_config_file)
weechat.config_write(weeNS_config_file)
示例7: ug_config_reload_cb
def ug_config_reload_cb(data, config_file):
""" Reload configuration file. """
return weechat.config_read(config_file)
示例8: __init__
def __init__(self, filename):
''' Initialize the configuration. '''
self.filename = filename
self.config_file = weechat.config_new(self.filename, '', '')
self.sorting_section = None
self.case_sensitive = False
self.group_irc = True
self.rules = []
self.replacements = []
self.signals = []
self.sort_on_config = True
self.__case_sensitive = None
self.__group_irc = None
self.__rules = None
self.__replacements = None
self.__signals = None
self.__sort_on_config = None
if not self.config_file:
log('Failed to initialize configuration file "{0}".'.format(self.filename))
return
self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')
if not self.sorting_section:
log('Failed to initialize section "sorting" of configuration file.')
weechat.config_free(self.config_file)
return
self.__case_sensitive = weechat.config_new_option(
self.config_file, self.sorting_section,
'case_sensitive', 'boolean',
'If this option is on, sorting is case sensitive.',
'', 0, 0, 'off', 'off', 0,
'', '', '', '', '', ''
)
self.__group_irc = weechat.config_new_option(
self.config_file, self.sorting_section,
'group_irc', 'boolean',
'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
'This ensures that these buffers are grouped with their respective server buffer.',
'', 0, 0, 'on', 'on', 0,
'', '', '', '', '', ''
)
self.__rules = weechat.config_new_option(
self.config_file, self.sorting_section,
'rules', 'string',
'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
'', 0, 0, Config.default_rules, Config.default_rules, 0,
'', '', '', '', '', ''
)
self.__replacements = weechat.config_new_option(
self.config_file, self.sorting_section,
'replacements', 'string',
'An ordered list of replacement patterns to use on buffer name components, encoded as JSON. See /help autosort for commands to manipulate these replacements.',
'', 0, 0, Config.default_replacements, Config.default_replacements, 0,
'', '', '', '', '', ''
)
self.__signals = weechat.config_new_option(
self.config_file, self.sorting_section,
'signals', 'string',
'The signals that will cause autosort to resort your buffer list. Seperate signals with spaces.',
'', 0, 0, Config.default_signals, Config.default_signals, 0,
'', '', '', '', '', ''
)
self.__sort_on_config = weechat.config_new_option(
self.config_file, self.sorting_section,
'sort_on_config_change', 'boolean',
'Decides if the buffer list should be sorted when autosort configuration changes.',
'', 0, 0, 'on', 'on', 0,
'', '', '', '', '', ''
)
if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to load configuration file.')
if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to write configuration file.')
self.reload()
示例9: colorize_config_read
def colorize_config_read():
""" Read configuration file. """
global colorize_config_file
return weechat.config_read(colorize_config_file)
示例10: bas_config_read
def bas_config_read():
"""Read configuration file."""
global bas_config_file
return weechat.config_read(bas_config_file)
示例11: init_config
def init_config():
"""Set up configuration options and load config file."""
global CONFIG_FILE
CONFIG_FILE = weechat.config_new(SCRIPT_NAME, 'config_reload_cb', '')
global CONFIG_SECTIONS
CONFIG_SECTIONS = {}
CONFIG_SECTIONS['general'] = weechat.config_new_section(
CONFIG_FILE, 'general', 0, 0, '', '', '', '', '', '', '', '', '', '')
for option, typ, desc, default in [
('debug', 'boolean', 'OTR script debugging', 'off'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['general'], option, typ, desc, '', 0,
0, default, default, 0, '', '', '', '', '', '')
CONFIG_SECTIONS['color'] = weechat.config_new_section(
CONFIG_FILE, 'color', 0, 0, '', '', '', '', '', '', '', '', '', '')
for option, desc, default, update_cb in [
('status.default', 'status bar default color', 'default',
'bar_config_update_cb'),
('status.encrypted', 'status bar encrypted indicator color', 'green',
'bar_config_update_cb'),
('status.unencrypted', 'status bar unencrypted indicator color',
'lightred', 'bar_config_update_cb'),
('status.authenticated', 'status bar authenticated indicator color',
'green', 'bar_config_update_cb'),
('status.unauthenticated', 'status bar unauthenticated indicator color',
'lightred', 'bar_config_update_cb'),
('status.logged', 'status bar logged indicator color', 'lightred',
'bar_config_update_cb'),
('status.notlogged', 'status bar not logged indicator color',
'green', 'bar_config_update_cb'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['color'], option, 'color', desc, '', 0,
0, default, default, 0, '', '', update_cb, '', '', '')
CONFIG_SECTIONS['look'] = weechat.config_new_section(
CONFIG_FILE, 'look', 0, 0, '', '', '', '', '', '', '', '', '', '')
for option, desc, default, update_cb in [
('bar.prefix', 'prefix for OTR status bar item', 'OTR:',
'bar_config_update_cb'),
('bar.state.encrypted',
'shown in status bar when conversation is encrypted', 'SEC',
'bar_config_update_cb'),
('bar.state.unencrypted',
'shown in status bar when conversation is not encrypted', '!SEC',
'bar_config_update_cb'),
('bar.state.authenticated',
'shown in status bar when peer is authenticated', 'AUTH',
'bar_config_update_cb'),
('bar.state.unauthenticated',
'shown in status bar when peer is not authenticated', '!AUTH',
'bar_config_update_cb'),
('bar.state.logged',
'shown in status bar when peer conversation is being logged to disk',
'LOG',
'bar_config_update_cb'),
('bar.state.notlogged',
'shown in status bar when peer conversation is not being logged to disk',
'!LOG',
'bar_config_update_cb'),
('bar.state.separator', 'separator for states in the status bar', ',',
'bar_config_update_cb'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['look'], option, 'string', desc, '',
0, 0, default, default, 0, '', '', update_cb, '', '', '')
CONFIG_SECTIONS['policy'] = weechat.config_new_section(
CONFIG_FILE, 'policy', 1, 1, '', '', '', '', '', '',
'policy_create_option_cb', '', '', '')
for option, desc, default in [
('default.allow_v2', 'default allow OTR v2 policy', 'on'),
('default.require_encryption', 'default require encryption policy',
'off'),
('default.send_tag', 'default send tag policy', 'off'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['policy'], option, 'boolean', desc, '',
0, 0, default, default, 0, '', '', '', '', '', '')
weechat.config_read(CONFIG_FILE)
示例12: theme_config_read
def theme_config_read():
"""Read configuration file."""
return weechat.config_read(theme_cfg_file)
示例13:
return ""
# }}}
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", "UTF-8"):
# load config
config_file = weechat.config_new(SCRIPT_NAME, 'reload_config_cb', '')
weechat.config_new_section(config_file, 'keys', 1, 1,
'keys_read_option_cb', '',
'', '',
'', '',
'keys_create_option_cb', '',
'', '')
weechat.config_read(config_file)
weechat.hook_command(SCRIPT_NAME,
"change weesodium options",
"[enable KEY] || "
"[disable]",
"",
"enable %-|| "
"disable",
"command_cb",
"")
weechat.hook_modifier('irc_in_privmsg', 'in_privmsg_cb', '')
weechat.hook_modifier('irc_out_privmsg', 'out_privmsg_cb', '')
weechat.hook_signal('buffer_closing', 'buffer_closing_cb', '')
statusbar = weechat.bar_item_new(SCRIPT_NAME, 'statusbar_cb', '')
示例14: config_read
def config_read():
return weechat.config_read(config_file)
示例15: colorize_config_read
def colorize_config_read():
''' Read configuration file. '''
global colorize_config_file
return weechat.config_read(colorize_config_file)