| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import shutil | 6 import shutil |
| 7 import tempfile | 7 import tempfile |
| 8 from xml.etree import ElementTree | 8 from xml.etree import ElementTree |
| 9 | 9 |
| 10 from devil.utils import cmd_helper | 10 from devil.utils import cmd_helper |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 <parameter name="Param" type="int"> | 60 <parameter name="Param" type="int"> |
| 61 </parameter> | 61 </parameter> |
| 62 </method> | 62 </method> |
| 63 </class> | 63 </class> |
| 64 </package> | 64 </package> |
| 65 </api> | 65 </api> |
| 66 """ | 66 """ |
| 67 results = {} | 67 results = {} |
| 68 for child in root: | 68 for child in root: |
| 69 if child.tag == 'package': | 69 if child.tag == 'package': |
| 70 results[child.attrib['name']] = _ParsePackageNode(child) | 70 package_name = child.attrib['name'] |
| 71 parsed_node = _ParsePackageNode(child) |
| 72 if package_name in results: |
| 73 results[package_name]['classes'].update(parsed_node['classes']) |
| 74 else: |
| 75 results[package_name] = parsed_node |
| 71 return results | 76 return results |
| 72 | 77 |
| 73 | 78 |
| 74 def _ParsePackageNode(package_node): | 79 def _ParsePackageNode(package_node): |
| 75 """Parses a <package> node from the dexdump xml output. | 80 """Parses a <package> node from the dexdump xml output. |
| 76 | 81 |
| 77 Returns: | 82 Returns: |
| 78 A dict in the format: | 83 A dict in the format: |
| 79 { | 84 { |
| 80 'classes': { | 85 'classes': { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 Returns: | 105 Returns: |
| 101 A dict in the format: | 106 A dict in the format: |
| 102 { | 107 { |
| 103 'methods': [<method_1>, <method_2>] | 108 'methods': [<method_1>, <method_2>] |
| 104 } | 109 } |
| 105 """ | 110 """ |
| 106 methods = [] | 111 methods = [] |
| 107 for child in class_node: | 112 for child in class_node: |
| 108 if child.tag == 'method': | 113 if child.tag == 'method': |
| 109 methods.append(child.attrib['name']) | 114 methods.append(child.attrib['name']) |
| 110 return {'methods': methods} | 115 return {'methods': methods, 'superclass': class_node.attrib['extends']} |
| OLD | NEW |