本文整理汇总了Python中config.ConfigManager.save_config方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.save_config方法的具体用法?Python ConfigManager.save_config怎么用?Python ConfigManager.save_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.ConfigManager
的用法示例。
在下文中一共展示了ConfigManager.save_config方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_resizer
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
def update_resizer(self, widget, event):
self.resizer.set_position(self.get_allocation().height)
if not self.is_fullscreen:
new_percent = int((self.get_allocation().height * 1.0) / self.screen.get_height() * 100.0)
ConfigManager.set_conf('height', str(new_percent))
ConfigManager.save_config()
示例2: ActionSignListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class ActionSignListener(BaseListener):
default_config = {
'signs': [
{
'coordinates': [0, 0, 0],
'type': 'teleport',
'destination': [0, 0, 0]
}
]
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'signs.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerInteract, PlayerInteractEvent)
register_command(self.reload_command, 'reload-sign-config', permission="omneity.actionsigns.reload")
def onDisable(self):
self.config_manager.save_config()
def onPlayerInteract(self, event):
block = event.getClickedBlock()
if block is None:
return
block_state = block.getState()
if not isinstance(block_state, Sign):
return
sign = block_state
sign_coords = [block.getX(), block.getY(), block.getZ()]
for sign_instance in self.config_manager.config['signs']:
if sign_instance['coordinates'] == sign_coords:
type_handler = sign_types[sign_instance['type']]
if event.getAction() == Action.LEFT_CLICK_BLOCK:
type_handler.onLeftClick(sign_instance, self.plugin, event, sign)
elif event.getAction() == Action.RIGHT_CLICK_BLOCK:
type_handler.onRightClick(sign_instance, self.plugin, event, sign)
else:
return #Something is fucked, should raise a exception
event.setCancelled(True)
return
def reload_command(self, sender, label, args):
self.config_manager.reload_config()
sender.sendMessage("Reloaded sign config")
示例3: WarpZoneListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class WarpZoneListener(BaseListener):
default_config = {
'warpzones': [
{
'area': {
'min': [0, 0, 0],
'max': [1, 1, 1],
'world': 'world'
},
'to': {
'location': [2, 2, 2],
'world': 'world'
}
}
]
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'warpzones.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerMoveEvent, PlayerMoveEvent)
def onDisable(self):
self.config_manager.save_config()
def onPlayerMoveEvent(self, event):
if event.getFrom().getBlock() == event.getTo().getBlock():
return
to = event.getTo()
to_arr = [to.getBlockX(), to.getBlockY(), to.getBlockZ()]
for warp in self.config_manager.config['warpzones']:
if warp['area']['world'] == event.getPlayer().getLocation().getWorld().getName():
if self.is_in_range(to_arr, warp['area']['min'], warp['area']['max']): #Should probably do a rtree or something
to_loc = warp['to']['location']
event.getPlayer().teleport(Location(self.plugin.getServer().getWorld(warp['to']['world']), to_loc[0], to_loc[1], to_loc[2]))
def is_in_range(self, loc, mini, maxi):
return self.arr_gt(loc, mini) and self.arr_lt(loc, maxi)
def arr_gt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] >= arr2[index]:
return False
return True
def arr_lt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] <= (arr2[index]):
return False
return True
示例4: XpListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class XpListener(BaseListener):
default_config = {
'xp_buff': 5
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'xp.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerExpChangeEvent, PlayerExpChangeEvent)
def onDisable(self):
self.config_manager.save_config()
def onPlayerExpChangeEvent(self, event):
event.setAmount(event.getAmount()*self.config_manager.config['xp_buff'])
示例5: Omneity
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class Omneity(PythonPlugin):
default_config = {
'modules': [
'aliases',
'actionsigns'
]
}
def onEnable(self):
# Config stuffs
self.getDataFolder().mkdirs()
self.config_manager = ConfigManager(path.join(self.getDataFolder().getAbsolutePath(), 'config.yml'), default=self.default_config)
self.config_manager.load_config()
# Register listeners
self.listeners = list()
for module_name in self.config_manager.config['modules']:
listener = __import__(module_name).listener(self)
self.listeners.append(listener)
listener.onEnable()
self.getServer().getPluginManager().registerEvents(listener, self);
print "Omneity Enabled"
def onDisable(self):
for listener in self.listeners:
listener.onDisable()
self.config_manager.save_config()
print "Omneity Disabled"
示例6: on_apply_clicked
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
#.........这里部分代码省略.........
ConfigManager.set_conf('use-default-font', self.chk_use_system_font.get_active())
ConfigManager.set_conf('font-name', self.font_name.get_font_name())
ConfigManager.set_conf('show-scrollbar', self.chk_show_scrollbar.get_active())
ConfigManager.set_conf('always-on-top', self.chk_always_on_top.get_active())
ConfigManager.set_conf('losefocus-hiding', self.chk_losefocus.get_active())
ConfigManager.set_conf('hide-on-start', self.chk_hide_on_start.get_active())
ConfigManager.set_conf('fullscreen-key', self.fullscreen_key.get_text())
ConfigManager.set_conf('quit-key', self.quit_key.get_text())
ConfigManager.set_conf('new-page-key', self.new_page_key.get_text())
ConfigManager.set_conf('close-page-key', self.close_page_key.get_text())
ConfigManager.set_conf('rename-page-key', self.rename_page_key.get_text())
ConfigManager.set_conf('next-page-key', self.next_page_key.get_text())
ConfigManager.set_conf('prev-page-key', self.prev_page_key.get_text())
ConfigManager.set_conf('global-key', self.global_key.get_text())
ConfigManager.set_conf('select-all-key', self.select_all_key.get_text())
ConfigManager.set_conf('copy-key', self.copy_key.get_text())
ConfigManager.set_conf('paste-key', self.paste_key.get_text())
ConfigManager.set_conf('split-h-key', self.split_h_key.get_text())
ConfigManager.set_conf('split-v-key', self.split_v_key.get_text())
ConfigManager.set_conf('close-node-key', self.close_node_key.get_text())
ConfigManager.set_conf('move-up-key', self.move_up_key.get_text())
ConfigManager.set_conf('move-down-key', self.move_down_key.get_text())
ConfigManager.set_conf('move-left-key', self.move_left_key.get_text())
ConfigManager.set_conf('move-right-key', self.move_right_key.get_text())
ConfigManager.set_conf('toggle-scrollbars-key', self.toggle_scrollbars_key.get_text())
try:
scrollback_line = int(self.entry_scrollback_lines.get_text())
except ValueError:
scrollback_line = 1024
ConfigManager.set_conf('scrollback-lines', str(scrollback_line))
ConfigManager.set_conf('scroll-on-output', self.chk_scroll_on_output.get_active())
ConfigManager.set_conf('scroll-on-keystroke', self.chk_scroll_on_keystroke.get_active())
ConfigManager.set_conf('infinite-scrollback', self.chk_scrollback_unlimited.get_active())
ConfigManager.set_conf('hide-tab-bar', self.chk_hide_tab_bar.get_active())
ConfigManager.set_conf('hide-tab-bar-fullscreen', self.chk_hide_tab_bar_fullscreen.get_active())
ConfigManager.set_conf('prompt-on-quit', self.chk_prompt_on_quit.get_active())
ConfigManager.set_conf('spawn-term-on-last-close', self.spawn_term_on_last_close.get_active())
try:
step_time = int(self.entry_step_time.get_text())
if not step_time > 0:
step_time = 20
except ValueError:
step_time = 20
try:
step_count = int(self.entry_step_count.get_text())
if not step_count > 0:
step_count = 20
except ValueError:
step_count = 20
ConfigManager.set_conf('use-animation', self.chk_use_animation.get_active())
ConfigManager.set_conf('step-count', step_count)
ConfigManager.set_conf('step-time', step_time)
if (self.chk_run_on_startup.get_active() and not os.path.exists(os.environ['HOME'] + '/.config/autostart/terra.desktop')):
os.system('cp /usr/share/applications/terra.desktop ' + os.environ['HOME'] + '/.config/autostart/terra.desktop')
if (not self.chk_run_on_startup.get_active() and os.path.exists(os.environ['HOME'] + '/.config/autostart/terra.desktop')):
os.system('rm -f ' + os.environ['HOME'] + '/.config/autostart/terra.desktop')
ConfigManager.save_config()
ConfigManager.callback()
示例7: NetherListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class NetherListener(BaseListener):
default_config = {
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'nether.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerPortalEvent, PlayerPortalEvent)
self.register_event(self.onPortalCreateEvent, PortalCreateEvent)
self.travelagent = OtOTravelAgent(self.plugin.getServer())
def onDisable(self):
self.config_manager.save_config()
def onPortalCreateEvent(self, event):
pass
def onPlayerPortalEvent(self, event):
if event.getCause() != PlayerTeleportEvent.TeleportCause.NETHER_PORTAL:
print "not a nether portal"
return
fr = event.getFrom()
to = event.getTo()
to_new = self.find_portal_data(fr)
to_new.setWorld(to.getWorld())
event.setTo(to_new)
event.setPortalTravelAgent(self.travelagent)
def find_portal_data(self, location):
world = location.getWorld()
#Coordinates are not always accurate, sometimes they are a block next to it. Check nearby blocks for portal.
corner = find_portal_block(location, 2)
if not corner:
raise PortalException("Unable to find from portal")
#Find the bottom of the portal.
while world.getBlockAt(corner).getType() == Material.PORTAL:
corner.subtract(0, 1, 0)
if world.getBlockAt(corner).getType() != Material.OBSIDIAN:
raise PortalException("Portal wasn't really a portal")
#Find which way the portal is placed, and do final adjustments to the corner.
if world.getBlockAt(corner.getBlockX()+1, corner.getBlockY()+1, corner.getBlockZ()).getType() == Material.PORTAL:
direction = 0
corner.subtract(1, 0, 0)
elif world.getBlockAt(corner.getBlockX(), corner.getBlockY()+1, corner.getBlockZ()+1).getType() == Material.PORTAL:
direction = 1
corner.subtract(0, 0, 1)
elif world.getBlockAt(corner.getBlockX()-1, corner.getBlockY()+1, corner.getBlockZ()).getType() == Material.PORTAL:
direction = 0
corner.subtract(2, 0, 0)
elif world.getBlockAt(corner.getBlockX(), corner.getBlockY()+1, corner.getBlockZ()-1).getType() == Material.PORTAL:
direction = 1
corner.subtract(0, 0, 2)
else:
raise PortalException("Unable to find portal direction")
return PortalCoordinates(world, location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getYaw(), location.getPitch(), corner, direction)
示例8: WarpZoneListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class WarpZoneListener(BaseListener):
default_config = {
"warpzones": [
{
"area": {"min": [0, 0, 0], "max": [1, 1, 1], "world": "world"},
"to": {"location": [2, 2, 2], "orientation": [0, 0], "world": "world"},
}
]
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(
path.join(self.plugin.getDataFolder().getAbsolutePath(), "warpzones.yml"), default=self.default_config
)
self.config_manager.load_config()
self.register_event(self.onPlayerMoveEvent, PlayerMoveEvent)
def onDisable(self):
self.config_manager.save_config()
def onPlayerMoveEvent(self, event):
if event.getFrom().getBlock() == event.getTo().getBlock():
return
to = event.getTo()
to_arr = [to.getBlockX(), to.getBlockY(), to.getBlockZ()]
for warp in self.config_manager.config["warpzones"]:
if warp["area"]["world"] == event.getPlayer().getLocation().getWorld().getName():
if self.is_in_range(
to_arr, warp["area"]["min"], warp["area"]["max"]
): # Should probably do a rtree or something
to_loc = warp["to"]["location"]
to_py = warp["to"]["orientation"]
event.getPlayer().teleport(
Location(
self.plugin.getServer().getWorld(warp["to"]["world"]),
to_loc[0],
to_loc[1],
to_loc[2],
to_py[0],
to_py[1],
)
)
def is_in_range(self, loc, mini, maxi):
return self.arr_gt(loc, mini) and self.arr_lt(loc, maxi)
def arr_gt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] >= arr2[index]:
return False
return True
def arr_lt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] <= (arr2[index]):
return False
return True
示例9: on_apply_clicked
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
def on_apply_clicked(self, widget):
ConfigManager.set_conf('seperator-size', int(self.adj_seperator.get_value()))
ConfigManager.set_conf('width', int(self.adj_width.get_value()))
ConfigManager.set_conf('height', int(self.adj_height.get_value()))
ConfigManager.set_conf('transparency', int(self.adj_transparency.get_value()))
ConfigManager.set_conf('vertical-position', self.v_alig.get_active() * 50)
ConfigManager.set_conf('horizontal-position', self.h_alig.get_active() * 50)
ConfigManager.set_conf('skip-taskbar', self.chk_hide_from_taskbar.get_active())
ConfigManager.set_conf('use-border', self.chk_use_border.get_active())
ConfigManager.set_conf('color-text', self.color_text.get_color().to_string())
ConfigManager.set_conf('color-background', self.color_background.get_color().to_string())
ConfigManager.set_conf('shell', self.entry_shell.get_text())
if self.radio_home.get_active():
ConfigManager.set_conf('dir', '$home$')
elif self.radio_pwd.get_active():
ConfigManager.set_conf('dir', '$pwd$')
else:
ConfigManager.set_conf('dir', self.dir_custom.get_text())
ConfigManager.set_conf('background-image', self.background_image.get_filename())
ConfigManager.set_conf('use-default-font', self.chk_use_system_font.get_active())
ConfigManager.set_conf('font-name', self.font_name.get_font_name())
ConfigManager.set_conf('show-scrollbar', self.chk_show_scrollbar.get_active())
ConfigManager.set_conf('always-on-top', self.chk_always_on_top.get_active())
ConfigManager.set_conf('losefocus-hiding', self.chk_losefocus.get_active())
ConfigManager.set_conf('hide-on-start', self.chk_hide_on_start.get_active())
ConfigManager.set_conf('fullscreen-key', self.fullscreen_key.get_text())
ConfigManager.set_conf('quit-key', self.quit_key.get_text())
ConfigManager.set_conf('new-page-key', self.new_page_key.get_text())
ConfigManager.set_conf('close-page-key', self.close_page_key.get_text())
ConfigManager.set_conf('rename-page-key', self.rename_page_key.get_text())
ConfigManager.set_conf('next-page-key', self.next_page_key.get_text())
ConfigManager.set_conf('prev-page-key', self.prev_page_key.get_text())
ConfigManager.set_conf('global-key', self.global_key.get_text())
ConfigManager.set_conf('select-all-key', self.select_all_key.get_text())
ConfigManager.set_conf('copy-key', self.copy_key.get_text())
ConfigManager.set_conf('paste-key', self.paste_key.get_text())
ConfigManager.set_conf('split-h-key', self.split_h_key.get_text())
ConfigManager.set_conf('split-v-key', self.split_v_key.get_text())
ConfigManager.set_conf('close-node-key', self.close_node_key.get_text())
if (self.chk_run_on_startup.get_active() and not os.path.exists(os.environ['HOME'] + '/.config/autostart/terra.desktop')):
os.system('cp /usr/share/applications/terra.desktop ' + os.environ['HOME'] + '/.config/autostart/terra.desktop')
if (not self.chk_run_on_startup.get_active() and os.path.exists(os.environ['HOME'] + '/.config/autostart/terra.desktop')):
os.system('rm -f ' + os.environ['HOME'] + '/.config/autostart/terra.desktop')
ConfigManager.save_config()
ConfigManager.callback()
示例10: SpawnListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class SpawnListener(BaseListener):
default_config = {
'spawn': {
'location': [0, 0, 0],
'orientation': [0, 0],
'world': 'world'
},
'first-join-message': {
'show': True,
'message': "%(GOLD)sWelcome %(name)s to the server!"
},
'allow-bed-spawn': True
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'spawn.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerJoinEvent, PlayerJoinEvent)
self.register_event(self.onPlayerPortalEvent, PlayerPortalEvent)
self.register_event(self.onPlayerRespawnEvent, PlayerRespawnEvent)
register_command(self.spawnCommand, "spawn", permission="omneity.spawn.tp")
def onDisable(self):
self.config_manager.save_config()
def getSpawnLocation(self):
spawn_info = self.config_manager.config['spawn']
return Location(
self.plugin.getServer().getWorld(spawn_info['world']),
spawn_info['location'][0], spawn_info['location'][1], spawn_info['location'][2],
spawn_info['orientation'][0], spawn_info['orientation'][1]
)
def onPlayerJoinEvent(self, event):
player = event.getPlayer()
if not player.hasPlayedBefore():
player.teleport(self.getSpawnLocation())
first_join_message_info = self.config_manager.config['first-join-message']
if first_join_message_info['show']:
message = first_join_message_info['message'] % dict({'name': event.getPlayer().getName()}.items() + chatcolor.colors.items())
self.plugin.getServer().broadcastMessage(message)
def onPlayerPortalEvent(self, event):
if event.getFrom().getWorld().getEnvironment() == Environment.THE_END and not self.config_manager.config['allow-bed-spawn']:
event.setTo(self.getSpawnLocation())
def onPlayerRespawnEvent(self, event):
if not event.isBedSpawn() or not self.config_manager.config['allow-bed-spawn']:
event.setRespawnLocation(self.getSpawnLocation())
def spawnCommand(self, sender, alias, args):
if isinstance(sender, Player):
sender.teleport(self.getSpawnLocation())
sender.sendMessage("Whoosh!")
示例11: WarpListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class WarpListener(BaseListener):
permission_error = chatcolor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."
default_config = {
'warps':{
'test': {
'location': [0, 0, 0],
'orientation': [0, 0],
'world': 'world'
}
}
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'warps.yml'), default=self.default_config)
self.config_manager.load_config()
register_command(self.command_warp, 'warp', description="Warp to places", usage="/<command> <warp> | set <warp> | del <warp> | list", permission="omneity.warp")
def onDisable(self):
self.config_manager.save_config()
def command_warp(self, sender, label, args):
if len(args) < 1:
return False
if args[0] == "set":
if not sender.hasPermission("omneity.warp.set"):
sender.sendMessage(self.permission_error)
return
if len(args) != 2:
return False
location = sender.getLocation()
self.config_manager.config['warps'][args[1]] = {'location': [location.getX(), location.getY(), location.getZ()], 'orientation': [location.getYaw(), location.getPitch()], 'world': location.getWorld().getName()}
self.config_manager.mark_dirty()
sender.sendMessage(chatcolor.GOLD + "Warp set.")
return True
if args[0] == "del":
if not sender.hasPermission("omneity.warp.del"):
sender.sendMessage(self.permission_error)
return
if len(args) != 2:
return False
del(self.config_manager.config['warps'][args[1]])
self.config_manager.mark_dirty()
sender.sendMessage(chatcolor.GOLD + "Warp deleted.")
return
if args[0] == "list":
sender.sendMessage(chatcolor.GOLD + ', '.join(self.config_manager.config['warps'].keys()))
return
if len(args) != 1:
return False
try:
warp_data = self.config_manager.config['warps'][args[0]]
except KeyError:
sender.sendMessage(chatcolor.GOLD + "Warp doesn't exist.")
return
location = Location(
self.plugin.getServer().getWorld(warp_data['world']),
warp_data['location'][0], warp_data['location'][1], warp_data['location'][2],
warp_data['orientation'][0], warp_data['orientation'][1])
sender.teleport(location)
sender.sendMessage(chatcolor.GOLD + "Warped.")
示例12: RecipeListener
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
class RecipeListener(BaseListener):
default_config = {
'furnace': [
{
'result': {
'id': 1,
'amount': 1, #default: 1
'data': -1 #default: -1
},
'source': {
'id': 1,
'data': -1 #default: -1
}
}
],
'shape': [
{
'result': {
'id': 1,
'amount': 1, #default: 1
'data': -1 #default: -1
},
'shape': [
"ABA",
"BAB",
"ABA"
],
'ingredients': {
'A': {
'id': 2,
'data': -1 #default: -1
},
'B': {
'id': 3,
'data': -1 #default: -1
}
}
}
],
'shapeless': [
{
'result': {
'id': 1,
'amount': 1, #default: 1
'data': -1 #default: -1
},
'ingredients': [
{
'id': 1,
'amount': 1, #default: 1 max: 9
'data': -1 #default: 1-
}
]
}
]
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'recipes.yml'), default=self.default_config)
self.config_manager.load_config()
server = self.plugin.getServer()
for recipe_data in self.config_manager.config['furnace']:
recipe = FurnaceRecipe(self.parse_itemstack(recipe_data['result']), self.parse_materialdata(recipe_data['source']))
server.addRecipe(recipe)
for recipe_data in self.config_manager.config['shape']:
recipe = ShapedRecipe(self.parse_itemstack(recipe_data['result']))
recipe.shape(recipe_data['shape'])
for key, ingredient in recipe_data['ingredients'].iteritems():
recipe.setIngredient(key, self.parse_materialdata(ingredient))
server.addRecipe(recipe)
for recipe_data in self.config_manager.config['shapeless']:
recipe = ShapelessRecipe(self.parse_itemstack(recipe_data['result']))
for ingredient in recipe_data['ingredients']:
recipe.addIngredient(ingredient.get('amount', 1), self.parse_materialdata(ingredient))
server.addRecipe(recipe)
def parse_itemstack(self, data):
return ItemStack(data['id'], data.get('amount', 1), data.get('data', -1))
def parse_materialdata(self, data):
return MaterialData(data['id'], data.get('data', -1))
def onDisable(self):
self.config_manager.save_config()
示例13: on_keypress
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
def on_keypress(self, widget, event):
if ConfigManager.key_event_compare('toggle-scrollbars-key', event):
ConfigManager.set_conf('show-scrollbar', not ConfigManager.get_conf('show-scrollbar'))
ConfigManager.save_config()
ConfigManager.callback()
return True
if ConfigManager.key_event_compare('move-up-key', event):
self.get_active_terminal().move(direction=1)
return True
if ConfigManager.key_event_compare('move-down-key', event):
self.get_active_terminal().move(direction=2)
return True
if ConfigManager.key_event_compare('move-left-key', event):
self.get_active_terminal().move(direction=3)
return True
if ConfigManager.key_event_compare('move-right-key', event):
self.get_active_terminal().move(direction=4)
return True
if ConfigManager.key_event_compare('quit-key', event):
self.quit()
return True
if ConfigManager.key_event_compare('select-all-key', event):
self.get_active_terminal().select_all()
return True
if ConfigManager.key_event_compare('copy-key', event):
self.get_active_terminal().copy_clipboard()
return True
if ConfigManager.key_event_compare('paste-key', event):
self.get_active_terminal().paste_clipboard()
return True
if ConfigManager.key_event_compare('split-v-key', event):
self.get_active_terminal().split_axis(None, 'h')
return True
if ConfigManager.key_event_compare('split-h-key', event):
self.get_active_terminal().split_axis(None, 'v')
return True
if ConfigManager.key_event_compare('close-node-key', event):
self.get_active_terminal().close_node(None)
return True
if ConfigManager.key_event_compare('fullscreen-key', event):
self.toggle_fullscreen()
return True
if ConfigManager.key_event_compare('new-page-key', event):
self.add_page()
return True
if ConfigManager.key_event_compare('rename-page-key', event):
for button in self.buttonbox:
if button != self.radio_group_leader and button.get_active():
self.page_rename(None, button)
return True
if ConfigManager.key_event_compare('close-page-key', event):
for button in self.buttonbox:
if button != self.radio_group_leader and button.get_active():
self.page_close(None, button)
return True
if ConfigManager.key_event_compare('next-page-key', event):
page_button_list = self.buttonbox.get_children()[1:]
for i in range(len(page_button_list)):
if (page_button_list[i].get_active() == True):
if (i + 1 < len(page_button_list)):
page_button_list[i+1].set_active(True)
else:
page_button_list[0].set_active(True)
return True
if ConfigManager.key_event_compare('prev-page-key', event):
page_button_list = self.buttonbox.get_children()[1:]
for i in range(len(page_button_list)):
if page_button_list[i].get_active():
if i > 0:
page_button_list[i-1].set_active(True)
else:
page_button_list[-1].set_active(True)
return True
if ConfigManager.key_event_compare('move-page-left', event):
i = 0
for button in self.buttonbox:
if button != self.radio_group_leader and button.get_active():
if (i - 1) > 0:
self.notebook.reorder_child(self.notebook.get_nth_page(i - 1), i - 2)
#.........这里部分代码省略.........
示例14: quit
# 需要导入模块: from config import ConfigManager [as 别名]
# 或者: from config.ConfigManager import save_config [as 别名]
def quit(self):
global Wins
ConfigManager.save_config()
Wins.remove_app(self)
self.destroy()