]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/coverage/parse_gcov_output.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / coverage / parse_gcov_output.py
index 02edc2a591eb0d87e1c394a1e8d11a224e8e1057..b9788ec815bd1f0da78ed287b80562c93f63132b 100644 (file)
@@ -47,35 +47,39 @@ def parse_gcov_report(gcov_input):
 
     return per_file_coverage, total_coverage
 
+
 def get_option_parser():
-    usage = "Parse the gcov output and generate more human-readable code " +\
-            "coverage report."
+    usage = (
+        "Parse the gcov output and generate more human-readable code "
+        + "coverage report."
+    )
     parser = optparse.OptionParser(usage)
 
     parser.add_option(
-        "--interested-files", "-i",
+        "--interested-files",
+        "-i",
         dest="filenames",
-        help="Comma separated files names. if specified, we will display " +
-             "the coverage report only for interested source files. " +
-             "Otherwise we will display the coverage report for all " +
-             "source files."
+        help="Comma separated files names. if specified, we will display "
+        + "the coverage report only for interested source files. "
+        + "Otherwise we will display the coverage report for all "
+        + "source files.",
     )
     return parser
 
+
 def display_file_coverage(per_file_coverage, total_coverage):
     # To print out auto-adjustable column, we need to know the longest
     # length of file names.
-    max_file_name_length = max(
-        len(fname) for fname in per_file_coverage.keys()
-    )
+    max_file_name_length = max(len(fname) for fname in per_file_coverage.keys())
 
     # -- Print header
     # size of separator is determined by 3 column sizes:
     # file name, coverage percentage and lines.
-    header_template = \
-        "%" + str(max_file_name_length) + "s\t%s\t%s"
+    header_template = "%" + str(max_file_name_length) + "s\t%s\t%s"
     separator = "-" * (max_file_name_length + 10 + 20)
-    print(header_template % ("Filename", "Coverage", "Lines"))  # noqa: E999 T25377293 Grandfathered in
+    print(
+        header_template % ("Filename", "Coverage", "Lines")
+    )  # noqa: E999 T25377293 Grandfathered in
     print(separator)
 
     # -- Print body
@@ -91,13 +95,14 @@ def display_file_coverage(per_file_coverage, total_coverage):
         print(separator)
         print(record_template % ("Total", total_coverage[0], total_coverage[1]))
 
+
 def report_coverage():
     parser = get_option_parser()
     (options, args) = parser.parse_args()
 
     interested_files = set()
     if options.filenames is not None:
-        interested_files = set(f.strip() for f in options.filenames.split(','))
+        interested_files = {f.strip() for f in options.filenames.split(",")}
 
     # To make things simple, right now we only read gcov report from the input
     per_file_coverage, total_coverage = parse_gcov_report(sys.stdin)
@@ -105,7 +110,8 @@ def report_coverage():
     # Check if we need to display coverage info for interested files.
     if len(interested_files):
         per_file_coverage = dict(
-            (fname, per_file_coverage[fname]) for fname in interested_files
+            (fname, per_file_coverage[fname])
+            for fname in interested_files
             if fname in per_file_coverage
         )
         # If we only interested in several files, it makes no sense to report
@@ -117,5 +123,6 @@ def report_coverage():
         return
     display_file_coverage(per_file_coverage, total_coverage)
 
+
 if __name__ == "__main__":
     report_coverage()