本文整理匯總了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())