本文整理汇总了Python中property_parser.Property.append方法的典型用法代码示例。如果您正苦于以下问题:Python Property.append方法的具体用法?Python Property.append怎么用?Python Property.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property_parser.Property
的用法示例。
在下文中一共展示了Property.append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_instance_data
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import append [as 别名]
def build_instance_data(editoritems: Property):
"""Build a property tree listing all of the instances for each item.
as well as another listing the input and output commands.
VBSP uses this to reduce duplication in VBSP_config files.
This additionally strips custom instance definitions from the original
list.
"""
instance_locs = Property("AllInstances", [])
cust_inst = Property("CustInstances", [])
commands = Property("Connections", [])
root_block = Property(None, [instance_locs, cust_inst, commands])
for item in editoritems.find_all("Item"):
instance_block = Property(item['Type'], [])
instance_locs.append(instance_block)
comm_block = Property(item['Type'], [])
for inst_block in item.find_all("Exporting", "instances"):
for inst in inst_block.value[:]: # type: Property
if inst.name.isdigit():
# Direct Portal 2 value
instance_block.append(
Property('Instance', inst['Name'])
)
else:
# It's a custom definition, remove from editoritems
inst_block.value.remove(inst)
cust_inst.set_key(
(item['type'], inst.name),
# Allow using either the normal block format,
# or just providing the file - we don't use the
# other values.
inst['name'] if inst.has_children() else inst.value,
)
# Look in the Inputs and Outputs blocks to find the io definitions.
# Copy them to property names like 'Input_Activate'.
for io_type in ('Inputs', 'Outputs'):
for block in item.find_all('Exporting', io_type, CONN_NORM):
for io_prop in block:
comm_block[
io_type[:-1] + '_' + io_prop.real_name
] = io_prop.value
# The funnel item type is special, having the additional input type.
# Handle that specially.
if item['type'] == 'item_tbeam':
for block in item.find_all('Exporting', 'Inputs', CONN_FUNNEL):
for io_prop in block:
comm_block['TBEAM_' + io_prop.real_name] = io_prop.value
# Only add the block if the item actually has IO.
if comm_block.value:
commands.append(comm_block)
return root_block.export()
示例2: build_instance_data
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import append [as 别名]
def build_instance_data(editoritems: Property):
"""Build a property tree listing all of the instances for each item.
as well as another listing the input and output commands.
VBSP uses this to reduce duplication in VBSP_config files.
"""
instance_locs = Property("AllInstances", [])
commands = Property("Connections", [])
root_block = Property(None, [instance_locs, commands])
for item in editoritems.find_all("Item"):
instance_block = Property(item['Type'], [])
instance_locs.append(instance_block)
comm_block = Property(item['Type'], [])
for inst_block in item.find_all("Exporting", "instances"):
for inst in inst_block:
instance_block.append(
Property('Instance', inst['Name'])
)
# Look in the Inputs and Outputs blocks to find the io definitions.
# Copy them to property names like 'Input_Activate'.
for io_type in ('Inputs', 'Outputs'):
for block in item.find_all('Exporting', io_type, CONN_NORM):
for io_prop in block:
comm_block[
io_type[:-1] + '_' + io_prop.real_name
] = io_prop.value
# The funnel item type is special, having the additional input type.
# Handle that specially.
if item['type'] == 'item_tbeam':
for block in item.find_all('Exporting', 'Inputs', CONN_FUNNEL):
for io_prop in block:
comm_block['TBEAM_' + io_prop.real_name] = io_prop.value
# Only add the block if the item actually has IO.
if comm_block.value:
commands.append(comm_block)
return root_block.export()
示例3: export
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import append [as 别名]
def export(
self,
style,
all_items,
music,
skybox,
voice,
style_vars,
elevator,
):
"""Generate the editoritems.txt and vbsp_config.
- If no backup is present, the original editoritems is backed up
- We unlock the mandatory items if specified
-
"""
print('--------------------')
print('Exporting Items and Style for "' + self.name + '"!')
print('Style =', style)
print('Music =', music)
print('Voice =', voice)
print('Skybox =', skybox)
print('Elevator = ', elevator)
print('Style Vars:\n {')
for key, val in style_vars.items():
print(' {} = {!s}'.format(key, val))
print(' }')
vbsp_config = style.config.copy()
# Editoritems.txt is composed of a "ItemData" block, holding "Item" and
# "Renderables" sections.
editoritems = Property("ItemData", *style.editor.find_all('Item'))
for item in sorted(all_items):
item_block, editor_parts, config_part = all_items[item].export()
editoritems += item_block
editoritems += editor_parts
vbsp_config += config_part
if voice is not None:
vbsp_config += voice.config
if skybox is not None:
vbsp_config.set_key(
('Textures', 'Special', 'Sky'),
skybox.material,
)
vbsp_config += skybox.config
if music is not None:
if music.sound is not None:
vbsp_config.set_key(
('Options', 'music_SoundScript'),
music.sound,
)
if music.inst is not None:
vbsp_config.set_key(
('Options', 'music_instance'),
music.inst,
)
vbsp_config.set_key(('Options', 'music_ID'), music.id)
vbsp_config += music.config
vbsp_config.set_key(('Options', 'BEE2_loc'),
os.path.dirname(os.getcwd()) # Go up one dir to our actual location
)
# If there are multiple of these blocks, merge them together
vbsp_config.merge_children('Conditions',
'InstanceFiles',
'Options',
'StyleVars',
'Textures')
vbsp_config.ensure_exists('StyleVars')
vbsp_config['StyleVars'] += [
Property(key, utils.bool_as_int(val))
for key, val in
style_vars.items()
]
for name, file, ext in FILES_TO_BACKUP:
item_path = self.abs_path(file + ext)
backup_path = self.abs_path(file + '_original' + ext)
if os.path.isfile(item_path) and not os.path.isfile(backup_path):
print('Backing up original ' + name + '!')
shutil.copy(item_path, backup_path)
# This is the connections "heart" icon and "error" icon
editoritems += style.editor.find_key("Renderables", [])
# Build a property tree listing all of the instances for each item
all_instances = Property("AllInstances", [])
for item in editoritems.find_all("Item"):
item_prop = Property(item['Type'], [])
all_instances.append(item_prop)
for inst_block in item.find_all("Exporting", "instances"):
for inst in inst_block:
#.........这里部分代码省略.........
示例4: export
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import append [as 别名]
#.........这里部分代码省略.........
voice.id,
)
vbsp_config.set_key(
('Options', 'voice_char'),
','.join(voice.chars)
)
if voice.cave_skin is not None:
vbsp_config.set_key(
('Options', 'cave_port_skin'),
voice.cave_skin,
)
vbsp_config.set_key(
('Options', 'BEE2_loc'),
os.path.dirname(os.getcwd()) # Go up one dir to our actual location
)
vbsp_config.set_key(
('Options', 'Game_ID'),
self.steamID,
)
vbsp_config.ensure_exists('StyleVars')
vbsp_config['StyleVars'] += [
Property(key, utils.bool_as_int(val))
for key, val in
style_vars.items()
]
pack_block = Property('PackList', [])
# A list of materials which will casue a specific packlist to be used.
pack_triggers = Property('PackTriggers', [])
for key, pack in pack_list.items():
pack_block.append(Property(
key,
[
Property('File', file)
for file in
pack.files
]
))
for trigger_mat in pack.trigger_mats:
pack_triggers.append(
Property('Material', [
Property('Texture', trigger_mat),
Property('PackList', pack.id),
])
)
if pack_triggers.value:
vbsp_config.append(pack_triggers)
# If there are multiple of these blocks, merge them together
# They will end up in this order.
vbsp_config.merge_children(
'Textures',
'Fizzler',
'Options',
'StyleVars',
'Conditions',
'Voice',
'PackTriggers',
)
for name, file, ext in FILES_TO_BACKUP:
item_path = self.abs_path(file + ext)
backup_path = self.abs_path(file + '_original' + ext)