當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。