Skip to content

Commit

Permalink
Add parsing for 'productRef' to __unique_build_file, refactor it a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JanNash committed Nov 12, 2020
1 parent 9533101 commit 8a8e0dd
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions xUnique.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,29 @@ def __unique_build_file(self, parent_hex, build_file_hex):
"""PBXBuildFile"""
current_node = self.nodes.get(build_file_hex)
if not current_node:
self.vprint("No node could be found for '{}'. It will be removed.".format(build_file_hex))
self.__result.setdefault('to_be_removed', []).append(build_file_hex)
else:
file_ref_hex = current_node.get('fileRef')
if not file_ref_hex:
self.vprint("PBXFileReference '", file_ref_hex, "' not found, it will be removed.")
self.__result.setdefault('to_be_removed', []).append(build_file_hex)
else:
if self.__result.get(file_ref_hex):
cur_path_key = self.__result[file_ref_hex]['path']
self.__set_to_result(parent_hex, build_file_hex, cur_path_key)
else:
self.vprint("PBXFileReference '", file_ref_hex, "' not found in PBXBuildFile '", build_file_hex,
"'. To be removed.", sep='')
self.__result.setdefault('to_be_removed', []).extend((build_file_hex, file_ref_hex))
return

def __set_result(ref):
cur_path_key = self.__result[ref]['path']
self.__set_to_result(parent_hex, build_file_hex, cur_path_key)

file_ref_hex = current_node.get('fileRef')
if file_ref_hex:
if self.__result.get(file_ref_hex):
__set_result(file_ref_hex)
return

product_ref_hex = current_node.get('productRef')
if product_ref_hex:
if self.__result.get(product_ref_hex):
__set_result(product_ref_hex)
return

self.vprint("Neither 'fileRef' nor 'productRef' could be found in '{}'. It will be removed.".format(build_file_hex))
self.__result.setdefault('to_be_removed', []).append(build_file_hex)


def __unique_build_rules(self, parent_hex, build_rule_hex):
"""PBXBuildRule"""
Expand Down

0 comments on commit 8a8e0dd

Please sign in to comment.