当前位置: 首页>>代码示例>>Python>>正文


Python Property.extend方法代码示例

本文整理汇总了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 + '>'
开发者ID:NotFirestorm348,项目名称:BEE2.4,代码行数:85,代码来源:packageLoader.py

示例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 + '>'
开发者ID:GiovanH,项目名称:BEE2.4,代码行数:92,代码来源:packageLoader.py


注:本文中的property_parser.Property.extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。