本文整理汇总了Python中property_parser.Property.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Property.extend方法的具体用法?Python Property.extend怎么用?Python Property.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property_parser.Property
的用法示例。
在下文中一共展示了Property.extend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import extend [as 别名]
class Style:
def __init__(
self,
style_id,
name,
author,
desc,
icon,
editor,
config=None,
base_style=None,
short_name=None,
suggested=None,
has_video=True,
):
self.id = style_id
self.auth = author
self.name = name
self.desc = desc
self.icon = icon
self.short_name = name if short_name is None else short_name
self.editor = editor
self.base_style = base_style
self.bases = [] # Set by setup_style_tree()
self.suggested = suggested or {}
self.has_video = has_video
if config is None:
self.config = Property(None, [])
else:
self.config = config
@classmethod
def parse(cls, data):
"""Parse a style definition."""
info = data.info
selitem_data = get_selitem_data(info)
base = info['base', '']
has_video = utils.conv_bool(info['has_video', '1'])
sugg = info.find_key('suggested', [])
sugg = (
sugg['quote', '<NONE>'],
sugg['music', '<NONE>'],
sugg['skybox', 'SKY_BLACK'],
sugg['goo', 'GOO_NORM'],
sugg['elev', '<NONE>'],
)
short_name = selitem_data.short_name or None
if base == '':
base = None
folder = 'styles/' + info['folder']
config = folder + '/vbsp_config.cfg'
with data.zip_file.open(folder + '/items.txt', 'r') as item_data:
items = Property.parse(item_data, folder+'/items.txt')
try:
with data.zip_file.open(config, 'r') as vbsp_config:
vbsp = Property.parse(vbsp_config, config)
except KeyError:
vbsp = None
return cls(
style_id=data.id,
name=selitem_data.name,
author=selitem_data.auth,
desc=selitem_data.desc,
icon=selitem_data.icon,
editor=items,
config=vbsp,
base_style=base,
short_name=short_name,
suggested=sugg,
has_video=has_video,
)
def add_over(self, override):
"""Add the additional commands to ourselves."""
self.editor.extend(override.editor)
self.config.extend(override.config)
self.auth.extend(override.auth)
def __repr__(self):
return '<Style:' + self.id + '>'
示例2: __init__
# 需要导入模块: from property_parser import Property [as 别名]
# 或者: from property_parser.Property import extend [as 别名]
class Style:
def __init__(
self,
style_id,
selitem_data: 'SelitemData',
editor,
config=None,
base_style=None,
suggested=None,
has_video=True,
corridor_names=utils.EmptyMapping,
):
self.id = style_id
self.selitem_data = selitem_data
self.editor = editor
self.base_style = base_style
self.bases = [] # Set by setup_style_tree()
self.suggested = suggested or {}
self.has_video = has_video
self.corridor_names = {
'sp_entry': corridor_names.get('sp_entry', Property('', [])),
'sp_exit': corridor_names.get('sp_exit', Property('', [])),
'coop': corridor_names.get('coop', Property('', [])),
}
if config is None:
self.config = Property(None, [])
else:
self.config = config
@classmethod
def parse(cls, data):
"""Parse a style definition."""
info = data.info
selitem_data = get_selitem_data(info)
base = info['base', '']
has_video = utils.conv_bool(info['has_video', '1'])
sugg = info.find_key('suggested', [])
sugg = (
sugg['quote', '<NONE>'],
sugg['music', '<NONE>'],
sugg['skybox', 'SKY_BLACK'],
sugg['goo', 'GOO_NORM'],
sugg['elev', '<NONE>'],
)
corridors = info.find_key('corridors', [])
corridors = {
'sp_entry': corridors.find_key('sp_entry', []),
'sp_exit': corridors.find_key('sp_exit', []),
'coop': corridors.find_key('coop', []),
}
if base == '':
base = None
folder = 'styles/' + info['folder']
config = folder + '/vbsp_config.cfg'
with data.zip_file.open(folder + '/items.txt', 'r') as item_data:
items = Property.parse(
item_data,
data.pak_id+':'+folder+'/items.txt'
)
try:
with data.zip_file.open(config, 'r') as vbsp_config:
vbsp = Property.parse(
vbsp_config,
data.pak_id+':'+config,
)
except KeyError:
vbsp = None
return cls(
style_id=data.id,
selitem_data=selitem_data,
editor=items,
config=vbsp,
base_style=base,
suggested=sugg,
has_video=has_video,
corridor_names=corridors,
)
def add_over(self, override: 'Style'):
"""Add the additional commands to ourselves."""
self.editor.extend(override.editor)
self.config.extend(override.config)
self.selitem_data.auth.extend(override.selitem_data.auth)
def __repr__(self):
return '<Style:' + self.id + '>'