tools: Better dependency fixing

Lines like 'deps = [ "foo" ]' would fail to be fixed.
Just insert the new dependencies in front and let the formatter have fun
with this after.

Bug: None
Change-Id: I747925cd0a1de93715a00b9ff3490b555f237e97
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257906
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36429}
This commit is contained in:
Florent Castelli
2022-04-04 15:18:25 +02:00
committed by WebRTC LUCI CQ
parent 429c1bd74d
commit 81acd03f89

View File

@ -81,11 +81,10 @@ def FixErrors(filename, missing_deps, deleted_sources):
for dep in missing_deps[target]) +
']\n') + line
indentation_level = None
elif line.strip().startswith('deps'):
is_empty_deps = line.strip() == 'deps = []'
line = 'deps = [\n' if is_empty_deps else line
line += ''.join(' "' + dep + '",\n' for dep in missing_deps[target])
line += ']\n' if is_empty_deps else ''
elif line.strip().startswith('deps = ['):
joined_deps = ''.join(' "' + dep + '",\n'
for dep in missing_deps[target])
line = line.replace('deps = [', 'deps = [' + joined_deps)
indentation_level = None
if line.strip() not in deleted_sources: