本文整理汇总了Python中property_parser.Property.has_children方法的典型用法代码示例。如果您正苦于以下问题:Python Property.has_children方法的具体用法?Python Property.has_children怎么用?Python Property.has_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property_parser.Property
的用法示例。
在下文中一共展示了Property.has_children方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flag_random
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import has_children [as 别名]
def flag_random(inst, res: Property):
"""Randomly is either true or false."""
if res.has_children():
chance = res['chance', '100']
seed = res['seed', '']
else:
chance = res.value
seed = ''
# Allow ending with '%' sign
chance = utils.conv_int(chance.rstrip('%'), 100)
random.seed('random_chance_{}:{}_{}_{}'.format(
seed,
inst['targetname', ''],
inst['origin'],
inst['angles'],
))
return random.randrange(100) < chance
示例2: write_sound
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import has_children [as 别名]
def write_sound(file, snds: Property, pack_list, snd_prefix='*'):
"""Write either a single sound, or multiple rndsound.
snd_prefix is the prefix for each filename - *, #, @, etc.
"""
if snds.has_children():
file.write(' "rndwave"\n {\n')
for snd in snds:
file.write(
' "wave" "{sndchar}{file}"\n'.format(
file=snd.value,
sndchar=snd_prefix,
)
)
pack_list.add('sound/' + snd.value.casefold())
file.write(' }\n')
else:
file.write(
' "wave" "{sndchar}{file}"\n'.format(
file=snds.value,
sndchar=snd_prefix,
)
)
pack_list.add('sound/' + snds.value.casefold())