Apply pylint to build/soong/bloaty
1. Run black --line-length 80 -S build/soong/bloaty to fix formatting 2. Annotate # pylint: disable=import-error to skip checks for imports. The imports are provided by Soong during m <target> Test: m bloaty_merger_test Test: pylint --rcfile tools/repohooks/tools/pylintrc build/soong/bloaty/bloaty_merger.py build/soong/bloaty/bloaty_merger_test.py Bug: 195738175 Change-Id: I4579a80203de41d48992424f264dd1cdbafc854c
This commit is contained in:
parent
eaf5e1b3ec
commit
16c2b8c3d3
2 changed files with 78 additions and 72 deletions
|
@ -24,12 +24,14 @@ import argparse
|
||||||
import csv
|
import csv
|
||||||
import gzip
|
import gzip
|
||||||
|
|
||||||
|
# pylint: disable=import-error
|
||||||
import ninja_rsp
|
import ninja_rsp
|
||||||
|
|
||||||
import file_sections_pb2
|
import file_sections_pb2
|
||||||
|
|
||||||
BLOATY_EXTENSION = ".bloaty.csv"
|
BLOATY_EXTENSION = ".bloaty.csv"
|
||||||
|
|
||||||
|
|
||||||
def parse_csv(path):
|
def parse_csv(path):
|
||||||
"""Parses a Bloaty-generated CSV file into a protobuf.
|
"""Parses a Bloaty-generated CSV file into a protobuf.
|
||||||
|
|
||||||
|
@ -52,14 +54,15 @@ def parse_csv(path):
|
||||||
section.file_size = int(row["filesize"])
|
section.file_size = int(row["filesize"])
|
||||||
return file_proto
|
return file_proto
|
||||||
|
|
||||||
|
|
||||||
def create_file_size_metrics(input_list, output_proto):
|
def create_file_size_metrics(input_list, output_proto):
|
||||||
"""Creates a FileSizeMetrics proto from a list of CSV files.
|
"""Creates a FileSizeMetrics proto from a list of CSV files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
input_list: The path to the file which contains the list of CSV files. Each
|
input_list: The path to the file which contains the list of CSV files.
|
||||||
filepath is separated by a space.
|
Each filepath is separated by a space.
|
||||||
output_proto: The path for the output protobuf. It will be compressed using
|
output_proto: The path for the output protobuf. It will be compressed
|
||||||
gzip.
|
using gzip.
|
||||||
"""
|
"""
|
||||||
metrics = file_sections_pb2.FileSizeMetrics()
|
metrics = file_sections_pb2.FileSizeMetrics()
|
||||||
reader = ninja_rsp.NinjaRspFileReader(input_list)
|
reader = ninja_rsp.NinjaRspFileReader(input_list)
|
||||||
|
@ -70,6 +73,7 @@ def create_file_size_metrics(input_list, output_proto):
|
||||||
with gzip.open(output_proto, "wb") as output:
|
with gzip.open(output_proto, "wb") as output:
|
||||||
output.write(metrics.SerializeToString())
|
output.write(metrics.SerializeToString())
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("input_list_file", help="List of bloaty csv files.")
|
parser.add_argument("input_list_file", help="List of bloaty csv files.")
|
||||||
|
@ -77,5 +81,6 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
create_file_size_metrics(args.input_list_file, args.output_proto)
|
create_file_size_metrics(args.input_list_file, args.output_proto)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
import gzip
|
import gzip
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
# pylint: disable=import-error
|
||||||
from pyfakefs import fake_filesystem_unittest
|
from pyfakefs import fake_filesystem_unittest
|
||||||
|
|
||||||
import bloaty_merger
|
import bloaty_merger
|
||||||
|
|
Loading…
Reference in a new issue