本文整理汇总了Python中property_parser.Property.find_key方法的典型用法代码示例。如果您正苦于以下问题:Python Property.find_key方法的具体用法?Python Property.find_key怎么用?Python Property.find_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property_parser.Property
的用法示例。
在下文中一共展示了Property.find_key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_music_script
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def generate_music_script(data: Property, pack_list):
"""Generate a soundscript file for music."""
# We also pack the filenames used for the tracks - that way funnel etc
# only get packed when needed. Stock sounds are in VPKS or in aperturetag/,
# we don't check there.
# The voice attrs used in the map - we can skip tracks
voice_attr = CONF['VoiceAttr', ''].casefold().split(';')
funnel = data.find_key('tbeam', '')
bounce = data.find_key('bouncegel', '')
speed = data.find_key('speedgel', '')
# The sounds must be present, and the items should be in the map.
has_funnel = funnel.value and (
'funnel' in voice_attr or
'excursionfunnel' in voice_attr
)
has_bounce = bounce.value and (
'bouncegel' in voice_attr or
'bluegel' in voice_attr
)
# Speed-gel sounds also play when flinging, so keep it always.
with open(os.path.join('bee2', 'inject', 'music_script.txt'), 'w') as file:
# Write the base music track
file.write(MUSIC_START.format(name='', vol='1'))
write_sound(file, data.find_key('base'), pack_list, snd_prefix='#*')
file.write(MUSIC_BASE)
# The 'soundoperators' section is still open now.
# Add the operators to play the auxilluary sounds..
if has_funnel:
file.write(MUSIC_FUNNEL_MAIN)
if has_bounce:
file.write(MUSIC_GEL_BOUNCE_MAIN)
if speed.value:
file.write(MUSIC_GEL_SPEED_MAIN)
# End the main sound block
file.write(MUSIC_END)
if has_funnel:
# Write the 'music.BEE2_funnel' sound entry
file.write('\n')
file.write(MUSIC_START.format(name='_funnel', vol='1'))
write_sound(file, funnel, pack_list, snd_prefix='*')
file.write(MUSIC_FUNNEL_STACK)
if has_bounce:
file.write('\n')
file.write(MUSIC_START.format(name='_gel_bounce', vol='0.5'))
write_sound(file, bounce, pack_list, snd_prefix='*')
file.write(MUSIC_GEL_STACK)
if speed.value:
file.write('\n')
file.write(MUSIC_START.format(name='_gel_speed', vol='0.5'))
write_sound(file, speed, pack_list, snd_prefix='*')
file.write(MUSIC_GEL_STACK)
示例2: load_conf
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def load_conf(prop_block: Property):
"""Read the config and build our dictionaries."""
global INST_SPECIAL
for prop in prop_block.find_key("Allinstances"):
INSTANCE_FILES[prop.real_name] = [inst.value.casefold() for inst in prop]
INST_SPECIAL = {key.casefold(): resolve(val_string) for key, val_string in SPECIAL_INST.items()}
# Several special items which use multiple item types!
# Checkmark and Timer indicator panels:
INST_SPECIAL["indpan"] = INST_SPECIAL["indpancheck"] + INST_SPECIAL["indpantimer"]
INST_SPECIAL["door_frame"] = INST_SPECIAL["door_frame_sp"] + INST_SPECIAL["door_frame_coop"]
INST_SPECIAL["white_frame"] = INST_SPECIAL["white_frame_sp"] + INST_SPECIAL["white_frame_coop"]
INST_SPECIAL["black_frame"] = INST_SPECIAL["black_frame_sp"] + INST_SPECIAL["black_frame_coop"]
# Arrival_departure_ents is set in both entry doors - it's usually the same
# though.
INST_SPECIAL["transitionents"] = resolve("<ITEM_ENTRY_DOOR:11>") + resolve("<ITEM_COOP_ENTRY_DOOR:4>")
# Laser items have the offset and centered item versions.
INST_SPECIAL["lasercatcher"] = resolve("<ITEM_LASER_CATCHER_CENTER>") + resolve("<ITEM_LASER_CATCHER_OFFSET>")
INST_SPECIAL["laseremitter"] = resolve("<ITEM_LASER_EMITTER_CENTER>") + resolve("<ITEM_LASER_EMITTER_OFFSET>")
INST_SPECIAL["laserrelay"] = resolve("<ITEM_LASER_RELAY_CENTER>") + resolve("<ITEM_LASER_RELAY_OFFSET>")
示例3: parse_package
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def parse_package(zip_file, info, pak_id, disp_name):
"""Parse through the given package to find all the components."""
for pre in Property.find_key(info, 'Prerequisites', []).value:
if pre.value not in packages:
utils.con_log(
'Package "' +
pre.value +
'" required for "' +
pak_id +
'" - ignoring package!'
)
return False
objects = 0
# First read through all the components we have, so we can match
# overrides to the originals
for comp_type in OBJ_TYPES:
allow_dupes = OBJ_TYPES[comp_type].allow_mult
# Look for overrides
for obj in info.find_all("Overrides", comp_type):
obj_id = obj['id']
obj_override[comp_type][obj_id].append(
ParseData(zip_file, obj_id, obj, pak_id)
)
for obj in info.find_all(comp_type):
obj_id = obj['id']
if obj_id in all_obj[comp_type]:
if allow_dupes:
# Pretend this is an override
obj_override[comp_type][obj_id].append(
ParseData(zip_file, obj_id, obj, pak_id)
)
else:
raise Exception('ERROR! "' + obj_id + '" defined twice!')
objects += 1
all_obj[comp_type][obj_id] = ObjData(
zip_file,
obj,
pak_id,
disp_name,
)
img_count = 0
img_loc = os.path.join('resources', 'bee2')
for item in zip_names(zip_file):
item = os.path.normcase(item).casefold()
if item.startswith("resources"):
extract_packages.res_count += 1
if item.startswith(img_loc):
img_count += 1
return objects, img_count
示例4: parse_package
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def parse_package(pack: 'Package'):
"""Parse through the given package to find all the components."""
for pre in Property.find_key(pack.info, 'Prerequisites', []):
if pre.value not in packages:
LOGGER.warning(
'Package "{pre}" required for "{id}" - '
'ignoring package!',
pre=pre.value,
id=pack.id,
)
return False
# First read through all the components we have, so we can match
# overrides to the originals
for comp_type in OBJ_TYPES:
allow_dupes = OBJ_TYPES[comp_type].allow_mult
# Look for overrides
for obj in pack.info.find_all("Overrides", comp_type):
obj_id = obj['id']
obj_override[comp_type][obj_id].append(
ParseData(pack.zip, obj_id, obj, pack.id)
)
for obj in pack.info.find_all(comp_type):
obj_id = obj['id']
if obj_id in all_obj[comp_type]:
if allow_dupes:
# Pretend this is an override
obj_override[comp_type][obj_id].append(
ParseData(pack.zip, obj_id, obj, pack.id)
)
else:
raise Exception('ERROR! "' + obj_id + '" defined twice!')
all_obj[comp_type][obj_id] = ObjData(
pack.zip,
obj,
pack.id,
pack.disp_name,
)
img_count = 0
img_loc = os.path.join('resources', 'bee2')
for item in zip_names(pack.zip):
item = os.path.normcase(item).casefold()
if item.startswith("resources"):
extract_packages.res_count += 1
if item.startswith(img_loc):
img_count += 1
return img_count
示例5: parse_package
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def parse_package(zip_file, info, pak_id, disp_name):
"""Parse through the given package to find all the components."""
global res_count
for pre in Property.find_key(info, 'Prerequisites', []).value:
if pre.value not in packages:
utils.con_log(
'Package "' +
pre.value +
'" required for "' +
pak_id +
'" - ignoring package!'
)
return False
objects = 0
# First read through all the components we have, so we can match
# overrides to the originals
for comp_type in obj_types:
# Look for overrides
for obj in info.find_all("Overrides", comp_type):
obj_id = obj['id']
obj_override[comp_type][obj_id].append(
(zip_file, obj)
)
for obj in info.find_all(comp_type):
obj_id = obj['id']
if obj_id in all_obj[comp_type]:
raise Exception('ERROR! "' + obj_id + '" defined twice!')
objects += 1
all_obj[comp_type][obj_id] = ObjData(
zip_file,
obj,
pak_id,
disp_name,
)
if res_count != -1:
for item in zip_names(zip_file):
if item.startswith("resources"):
res_count += 1
loader.set_length("RES", res_count)
return objects
示例6: load_conf
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import find_key [as 别名]
def load_conf(prop_block: Property):
"""Read the config and build our dictionaries."""
global INST_SPECIAL
for prop in prop_block.find_key('Allinstances', []):
INSTANCE_FILES[prop.real_name] = [
inst.value.casefold()
for inst in
prop
]
for prop in prop_block.find_key('CustInstances', []):
CUST_INST_FILES[prop.real_name] = {
inst.name: inst.value.casefold()
for inst in
prop
}
INST_SPECIAL = {
key.casefold(): resolve(val_string, silent=True)
for key, val_string in
SPECIAL_INST.items()
}
# Several special items which use multiple item types!
# Checkmark and Timer indicator panels:
INST_SPECIAL['indpan'] = (
INST_SPECIAL['indpancheck'] +
INST_SPECIAL['indpantimer']
)
INST_SPECIAL['door_frame'] = (
INST_SPECIAL['door_frame_sp'] +
INST_SPECIAL['door_frame_coop']
)
INST_SPECIAL['white_frame'] = (
INST_SPECIAL['white_frame_sp'] +
INST_SPECIAL['white_frame_coop']
)
INST_SPECIAL['black_frame'] = (
INST_SPECIAL['black_frame_sp'] +
INST_SPECIAL['black_frame_coop']
)
# Arrival_departure_ents is set in both entry doors - it's usually the same
# though.
INST_SPECIAL['transitionents'] = (
resolve('<ITEM_ENTRY_DOOR:11>') +
resolve('<ITEM_COOP_ENTRY_DOOR:4>')
)
# Laser items have the offset and centered item versions.
INST_SPECIAL['lasercatcher'] = (
resolve('<ITEM_LASER_CATCHER_CENTER>', silent=True) +
resolve('<ITEM_LASER_CATCHER_OFFSET>', silent=True)
)
INST_SPECIAL['laseremitter'] = (
resolve('<ITEM_LASER_EMITTER_CENTER>', silent=True) +
resolve('<ITEM_LASER_EMITTER_OFFSET>', silent=True)
)
INST_SPECIAL['laserrelay'] = (
resolve('<ITEM_LASER_RELAY_CENTER>', silent=True) +
resolve('<ITEM_LASER_RELAY_OFFSET>', silent=True)
)
LOGGER.warning('None in vals: {}', None in INST_SPECIAL.values())