Leave a comment when removing a prop
post_process_prop.py doesn't simply drop a line when deleting a prop.
Instead, it makes the line as comment and leave a comment to clearly
mark that the prop was force removed. This is to aid the debugging.
Bug: 117892318
Test: m
Change-Id: I53c05800ff71d431a56dc370bcfe8bfc95c03bfc
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index b221041..4fa15bc 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -108,7 +108,10 @@
self.props[index].value = value
def delete(self, name):
- self.props = [p for p in self.props if p.name != name]
+ index = next((i for i,p in enumerate(self.props) if p.name == name), -1)
+ if index != -1:
+ new_comment = "# removed by post_process_props.py\n#" + str(self.props[index])
+ self.props[index] = Prop.from_line(new_comment)
def write(self, filename):
with open(filename, 'w+') as f: