From cc49c6b8cd1ebe2ee59ec04f51755d065ea33c75 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 26 May 2020 03:30:02 +0900 Subject: [PATCH] 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 --- tools/post_process_props.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/post_process_props.py b/tools/post_process_props.py index b2210416c3..4fa15bcd61 100755 --- a/tools/post_process_props.py +++ b/tools/post_process_props.py @@ -108,7 +108,10 @@ class PropList: 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: