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


Python cElementTree.XMLParser方法代码示例

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


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

示例1: obfuscate

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def obfuscate(self, obfuscation_info: Obfuscation):
        self.logger.info('Running "{0}" obfuscator'.format(self.__class__.__name__))

        try:
            # Change default namespace.
            Xml.register_namespace('obfuscation', 'http://schemas.android.com/apk/res/android')

            xml_parser = Xml.XMLParser(encoding='utf-8')
            manifest_tree = Xml.parse(obfuscation_info.get_manifest_file(), parser=xml_parser)
            manifest_root = manifest_tree.getroot()
            self.remove_xml_duplicates(manifest_root)
            self.scramble_xml_element(manifest_root)
            self.indent_xml(manifest_root)

            # Write the changes into the manifest file.
            manifest_tree.write(obfuscation_info.get_manifest_file(), encoding='utf-8')

        except Exception as e:
            self.logger.error('Error during execution of "{0}" obfuscator: {1}'.format(self.__class__.__name__, e))
            raise

        finally:
            obfuscation_info.used_obfuscators.append(self.__class__.__name__) 
开发者ID:ClaudiuGeorgiu,项目名称:Obfuscapk,代码行数:25,代码来源:random_manifest.py

示例2: encrypt_string_resources

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def encrypt_string_resources(self, string_resources_xml_file: str, string_names_to_encrypt: Set[str]):

        xml_parser = Xml.XMLParser(encoding='utf-8')
        xml_tree = Xml.parse(string_resources_xml_file, parser=xml_parser)

        for xml_string in xml_tree.iter('string'):
            string_name = xml_string.get('name', None)
            string_value = xml_string.text
            if string_name and string_value and string_name in string_names_to_encrypt:
                encrypted_string_value = self.encrypt_string(string_value)
                xml_string.text = encrypted_string_value

        xml_tree.write(string_resources_xml_file, encoding='utf-8') 
开发者ID:ClaudiuGeorgiu,项目名称:Obfuscapk,代码行数:15,代码来源:res_string_encryption.py

示例3: encrypt_string_array_resources

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def encrypt_string_array_resources(self, string_array_resources_xml_file: str,
                                       string_array_names_to_encrypt: Set[str]):

        xml_parser = Xml.XMLParser(encoding='utf-8')
        xml_tree = Xml.parse(string_array_resources_xml_file, parser=xml_parser)

        for xml_string_array in xml_tree.iter('string-array'):
            string_array_name = xml_string_array.get('name', None)
            if string_array_name and string_array_name in string_array_names_to_encrypt:
                for item in xml_string_array.iter('item'):
                    if item.text:
                        encrypted_string_value = self.encrypt_string(item.text)
                        item.text = encrypted_string_value

        xml_tree.write(string_array_resources_xml_file, encoding='utf-8') 
开发者ID:ClaudiuGeorgiu,项目名称:Obfuscapk,代码行数:17,代码来源:res_string_encryption.py

示例4: _getXmlDocumentItem

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def _getXmlDocumentItem(self, fileName):
		filePath = '%s/%s.xml' % (self._dbFolder, fileName)
		xmlDoc = self.xmlCache.get(filePath)
		if xmlDoc:
			return xmlDoc
		doc = None

		# try different encoding and configurations
		encodingArray = ['utf-8', 'iso-8859-5']
		for docEncoding in encodingArray:
			try:
				doc = ET.parse(filePath, parser=ET.XMLParser(encoding=docEncoding))
				if doc is not None:
					print('parse %s success. encoding = %s' % (fileName, docEncoding))
					break
			except:
				print('parse %s failed. encoding = %s'% (fileName, docEncoding))
				# traceback.print_exc()
				continue
		if doc is None:
			print('parse %s failed'% (fileName, ))
			return XmlDocItem(None)

		xmlDoc = XmlDocItem(doc)
		self.xmlCache[filePath] = xmlDoc
		return xmlDoc 
开发者ID:league1991,项目名称:CodeAtlasSublime,代码行数:28,代码来源:DoxygenDB.py

示例5: fromstring

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def fromstring(self, string):
		'''Set the contents of this tree from XML representation.'''
		parser = ElementTreeModule.XMLParser()
		parser.feed(string)
		root = parser.close()
		self._etree._setroot(root)
		return self # allow ParseTree().fromstring(..) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:9,代码来源:__init__.py

示例6: check_loading_issues

# 需要导入模块: from xml.etree import cElementTree [as 别名]
# 或者: from xml.etree.cElementTree import XMLParser [as 别名]
def check_loading_issues(self):
        """Check for any loading issues."""
        missing_libs = []
        tips = []
        label = """<html>
              <body style='margin: 10px'>
                <b>The following dependencies could not be loaded successfully:</b><br>
                <ul><li>%s</li></ul><br>
                <b>Tips:</b><br>
                <ul><li>%s</li><br></ul>
                <b>For detailed information on how to load the plugin, see:</b><br>
                <ul>
                  <li>
                    <a href='#'>https://github.com/VirtueSecurity/aws-extender#getting-started</a>
                  </li>
                </ul>
              </body>
            </html>"""

        if not RUN_TESTS:
            missing_libs.append('boto/boto3')
            tips.append('Make sure that the boto/boto3 library is installed properly, and\
                the right path is specified in the "Folder for loading modules" setting.')
        try:
            CET.fromstring('<test></test>')
        except SAXException:
            # a workaround for "http://bugs.jython.org/issue1127"
            try:
                def xml_parser(**_):
                    class Parser(object):
                        def feed(*_):
                            raise XMLParseError
                        @staticmethod
                        def close(*_):
                            return None
                    return Parser()
                CET.XMLParser = xml_parser
            except TypeError:
                missing_libs.append('SAXParser')
                tips.append("""Run Burp Suite using the following command:
                   <br><code style='background: #f7f7f9; color: red'>$ java -classpath 
                   xercesImpl.jar;burpsuite_pro.jar burp.StartBurp</code>""")

        if not missing_libs:
            return
        label %= ('</li><li>'.join(missing_libs), '</li><li>'.join(tips))

        self.show_errors(label) 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:50,代码来源:main.py


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