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


Python SubElement.attrib['Id']方法代码示例

本文整理汇总了Python中xml.etree.ElementTree.SubElement.attrib['Id']方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.attrib['Id']方法的具体用法?Python SubElement.attrib['Id']怎么用?Python SubElement.attrib['Id']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml.etree.ElementTree.SubElement的用法示例。


在下文中一共展示了SubElement.attrib['Id']方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_components

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def add_components(path, dir_elem):
    for name in os.listdir(path):
        fullname = os.path.join(path, name)
        if os.path.isfile(fullname):
            file_elem = dir_elem.find('./{%s}Component/{%s}File[@Name="%s"]' % (XMLNS, XMLNS, name))
            if file_elem is None:
                comp_elem = SubElement(dir_elem, '{%s}Component' % XMLNS)
                file_elem = SubElement(comp_elem, '{%s}File' % XMLNS)
                file_elem.attrib['Name'] = name
            file_elem.attrib['Id'] = get_path_id(fullname)
            file_elem.attrib['KeyPath'] = 'yes'
        elif os.path.isdir(fullname):
            child_elem = dir_elem.find('./{%s}Directory[@Name="%s"]' % (XMLNS, name))
            if child_elem is None:
                child_elem = SubElement(dir_elem, '{%s}Directory' % XMLNS)
                child_elem.attrib['Id'] = get_path_id(fullname)
                child_elem.attrib['Name'] = name
            add_components(fullname, child_elem)
开发者ID:waveform80,项目名称:oxitopped,代码行数:20,代码来源:configure_wxs.py

示例2: add_shortcut

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def add_shortcut(product_elem, dir_elem, file_elem, script, folder):
    shortcut_elem = file_elem.find('./{%s}Shortcut[@Directory="%s"]' % (XMLNS, folder))
    if shortcut_elem is None:
        shortcut_elem = SubElement(file_elem, '{%s}Shortcut' % XMLNS)
        shortcut_elem.attrib['Directory'] = folder
    shortcut_elem.attrib['Id'] = '%s_%s' % (folder, script)
    shortcut_elem.attrib['Name'] = script
    shortcut_elem.attrib['Advertise'] = 'yes'
    shortcut_elem.attrib['Icon'] = '%s_%s.exe' % (folder, script)
    shortcut_elem.attrib['IconIndex'] = '0'
    add_icon(product_elem, shortcut_elem.attrib['Icon'], os.path.join(
        dir_elem.attrib['FileSource'], '%s.exe' % script))
开发者ID:waveform80,项目名称:oxitopped,代码行数:14,代码来源:configure_wxs.py

示例3: generateShareSDKXmlFile

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def generateShareSDKXmlFile(pluginInfo, decompileDir):
	assetsPath = file_utils.getFullPath(decompileDir) + "/assets"

	if not os.path.exists(assetsPath):
		os.makedirs(assetsPath)

	shareSdkXml = assetsPath + "/ShareSDK.xml"

	if os.path.exists(shareSdkXml):
		os.remove(shareSdkXml)
		
	tree = ElementTree()
	root = Element('DevInfor')
	tree._setroot(root)

	shareNode = SubElement(root, 'ShareSDK')

	if 'params' in pluginInfo and pluginInfo['params'] != None and len(pluginInfo['params']) > 0:
		for param in pluginInfo['params']:
			paramName = param.get('name')
			if paramName == 'AppKey':
				paramValue = param.get('value')
				shareNode.set('AppKey', paramValue)
				break

	subplugins = pluginInfo.get('subplugins')

	if subplugins != None and len(subplugins) > 0:
		index = 1
		for subplg in subplugins:
			subplgNode = SubElement(root, subplg['name'])
			subparams = subplg.get('params')
			if subparams != None and len(subparams) > 0:
				for subparam in subparams:
					subplgNode.set(subparam['name'], subparam['value'])

			if subplgNode.get('Id') == None:
				subplgNode.set('Id', str(index))
			else:
				subplgNode.attrib['Id'] = str(index)

			if subplgNode.get('Enable') == None:
				subplgNode.set('Enable', 'true')
			else:
				subplgNode.attrib['Enable'] = 'true'

			index = index + 1

	tree.write(shareSdkXml, 'UTF-8')
开发者ID:SunWeiDrean,项目名称:QuickSDKTool_Win_P34,代码行数:51,代码来源:script.py

示例4: add_gui_scripts

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def add_gui_scripts(product_elem, dir_elem, feature_elem):
    shortcuts = SubElement(feature_elem, '{%s}ComponentRef' % XMLNS)
    shortcuts.attrib['Id'] = 'StartMenuShortcuts'
    scripts = [
        ep.split('=')[0].rstrip()
        for ep in ENTRY_POINTS['gui_scripts']
        ]
    all_component_elems = dir_elem.findall('./{%s}Component' % XMLNS)
    gui_component_elems = [
        (script, component_elem)
        for component_elem in all_component_elems
        for script in scripts
        if component_elem.find('./{%s}File[@Name="%s.exe"]' % (XMLNS, script)) is not None
        ]
    for (script, component_elem) in gui_component_elems:
        if 'Id' not in component_elem.attrib:
            component_elem.attrib['Id'] = '%s.exe' % script
        file_elem = component_elem.find('./{%s}File[@Name="%s.exe"]' % (XMLNS, script))
        add_shortcut(product_elem, dir_elem, file_elem, script, 'DesktopFolder')
        add_shortcut(product_elem, dir_elem, file_elem, script, 'ProgramMenuDir')
        SubElement(feature_elem, '{%s}ComponentRef' % XMLNS).attrib['Id'] = component_elem.attrib['Id']
开发者ID:waveform80,项目名称:oxitopped,代码行数:23,代码来源:configure_wxs.py

示例5: configure_wxs

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def configure_wxs(
        template=os.path.join(MY_PATH, 'template.wxs'),
        output=os.path.join(MY_PATH, NAME + '.wxs'),
        source_dir=os.path.join(MY_PATH, 'dist'),
        encoding='utf-8'):
    # Open the WiX installer template
    with io.open(template, 'rb') as f:
        document = fromstring(f.read().decode(encoding))
    product = document.find('{%s}Product' % XMLNS)
    product.attrib['Name'] = NAME
    product.attrib['Version'] = VERSION
    package = product.find('./{%s}Package' % XMLNS)
    package.attrib['Description'] = DESCRIPTION
    # Construct Component/File elements for all files under source_dir
    # (ignoring any entries that are already present)
    install_dir = product.find('.//{%s}Directory[@Id="INSTALLDIR"]' % XMLNS)
    install_dir.attrib['FileSource'] = source_dir
    add_components(source_dir, install_dir)
    # Add all console_script entry points to the CLIFeature
    root_feature = product.find('./{%s}Feature[@Id="RootFeature"]' % XMLNS)
    cli_feature = root_feature.find('./{%s}Feature[@Id="CLIFeature"]' % XMLNS)
    if cli_feature is None:
        cli_feature = SubElement(root_feature, '{%s}Feature' % XMLNS)
        cli_feature.attrib['Id'] = 'CLIFeature'
        cli_feature.attrib['Title'] = 'Command line applications'
    add_cli_scripts(product, install_dir, cli_feature)
    # Add all gui_script entry_points to the GUIFeature and configure their icons
    gui_feature = root_feature.find('./{%s}Feature[@Id="GUIFeature"]' % XMLNS)
    if gui_feature is None:
        gui_feature = SubElement(root_feature, '{%s}Feature' % XMLNS)
        gui_feature.attrib['Id'] = 'GUIFeature'
        gui_feature.attrib['Title'] = 'Graphical applications'
    add_gui_scripts(product, install_dir, gui_feature)
    # Fix up name substitutions because WiX/MSI is horribly inconsistent in
    # where it permits substitutions...
    install_dir.attrib['Name'] = NAME
    menu_dir = product.find('.//{%s}Directory[@Id="ProgramMenuDir"]' % XMLNS)
    menu_dir.attrib['Name'] = NAME
    root_feature = product.find('./{%s}Feature[@Id="RootFeature"]' % XMLNS)
    root_feature.attrib['Title'] = NAME
    # Find the default <Feature> element or create one if it doesn't exist
    default_feature = product.find('.//{%s}Feature[@Id="DefaultFeature"]' % XMLNS)
    all_features = product.findall('.//{%s}Feature' % XMLNS)
    if default_feature is None:
        default_feature = SubElement(product, '{%s}Feature' % XMLNS)
        default_feature.attrib['Id'] = 'DefaultFeature'
        default_feature.attrib['Title'] = 'Default Feature'
    # Add all created components to the default feature, unless they're already
    # present in that (or any other) feature
    for comp_elem in product.findall('.//{%s}Component' % XMLNS):
        ref_id = get_component_id(comp_elem)
        comp_ref = None
        for feature in all_features:
            comp_ref = feature.find('./{%s}ComponentRef[@Id="%s"]' % (XMLNS, ref_id))
            if comp_ref is not None:
                break
        if comp_ref is None:
            SubElement(default_feature, 'ComponentRef').attrib['Id'] = ref_id
    indent(document)
    with io.open(output, 'wb') as f:
        f.write('<?xml version="1.0" encoding="utf-8"?>\n')
        f.write(tostring(document, encoding=encoding))
开发者ID:waveform80,项目名称:oxitopped,代码行数:64,代码来源:configure_wxs.py

示例6: add_icon

# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib['Id'] [as 别名]
def add_icon(product_elem, icon_id, source_file):
    icon_elem = product_elem.find('./{%s}Icon[@Id="%s"]' % (XMLNS, icon_id))
    if icon_elem is None:
        icon_elem = SubElement(product_elem, '{%s}Icon' % XMLNS)
        icon_elem.attrib['Id'] = icon_id
    icon_elem.attrib['SourceFile'] = source_file
开发者ID:waveform80,项目名称:oxitopped,代码行数:8,代码来源:configure_wxs.py


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