msg += f".. _{key}:\n\n" max_len = 0 for i in range(0, len(names)): # pylint: disable=C0200 names[i] = "**" + self.re_escape.sub(r"\\\1", names[i]) + "**" max_len = max(max_len, len(names[i])) msg += "+-" + "-" * max_len + "-+\n" for name in names: msg += f"| {name}" + " " * (max_len - len(name)) + " |\n" msg += "+-" + "-" * max_len + "-+\n" msg += "\n" for ref in file_ref: if wtype == "File": msg += f".. _{ref[1]}:\n\n" else: base = os.path.basename(ref[0]) msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n" if wtype == "File": msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n" desc = v.get("description") if not desc and wtype != "File": msg += f"DESCRIPTION MISSING for {names[0]}\n\n" if desc: if output_in_txt: msg += self.desc_txt(desc) else: msg += self.desc_rst(desc) symbols = v.get("symbols") if symbols: msg += "Has the following ABI:\n\n" for w, label in symbols: # Escape special chars from content content = self.re_escape.sub(r"\\\1", w) msg += f"- :ref:`{content} <{label}>`\n\n" users = v.get("users") if users and users.strip(" \t\n"): users = users.strip("\n").replace('\n', '\n\t') msg += f"Users:\n\t{users}\n\n" ln = v.get("line_no", 1) yield (msg, file_ref[0][0], ln) def check_issues(self): """Warn about duplicated ABI entries.""" for what, v in self.what_symbols.items(): files = v.get("file") if not files: # Should never happen if the parser works properly self.log.warning("%s doesn't have a file associated", what) continue if len(files) == 1: continue f = [] for fname, lines in sorted(files.items()): if not lines: f.append(f"{fname}") elif len(lines) == 1: f.append(f"{fname}:{lines[0]}") else: m = fname + "lines " m += ", ".join(str(x) for x in lines) f.append(m) self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f)) def search_symbols(self, expr): """ Searches for ABI symbols.""" regex = re.compile(expr, re.I) found_keys = 0 for t in sorted(self.data.items(), key=lambda x: [0]): v = t[1] wtype = v.get("type", "") if wtype == "File": continue for what in v.get("what", [""]): if regex.search(what): found_keys += 1 kernelversion = v.get("kernelversion", "").strip(" \t\n") date = v.get("date", "").strip(" \t\n") contact = v.get("contact", "").strip(" \t\n") users = v.get("users", "").strip(" \t\n") desc = v.get("description", "").strip(" \t\n") files = [] for f in v.get("file", ()): files.append(f[0]) what = str(found_keys) + ". " + what title_tag = "-" * len(what) print(f"\n{what}\n{title_tag}\n") if kernelversion: print(f"Kernel version:\t\t{kernelversion}") if date: print(f"Date:\t\t\t{date}") if contact: print(f"Contact:\t\t{contact}") if users: print(f"Users:\t\t\t{users}") print("Defined on file(s):\t" + ", ".join(files)) if desc: desc = desc.strip("\n") print(f"\n{desc}\n") if not found_keys: print(f"Regular expression /{expr}/ not found.")Lines 501–631 of 631. Previous lines
msg += f".. _{key}:\n\n" max_len = 0 for i in range(0, len(names)): # pylint: disable=C0200 names[i] = "**" + self.re_escape.sub(r"\\\1", names[i]) + "**" max_len = max(max_len, len(names[i])) msg += "+-" + "-" * max_len + "-+\n" for name in names: msg += f"| {name}" + " " * (max_len - len(name)) + " |\n" msg += "+-" + "-" * max_len + "-+\n" msg += "\n" for ref in file_ref: if wtype == "File": msg += f".. _{ref[1]}:\n\n" else: base = os.path.basename(ref[0]) msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n" if wtype == "File": msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n" desc = v.get("description") if not desc and wtype != "File": msg += f"DESCRIPTION MISSING for {names[0]}\n\n" if desc: if output_in_txt: msg += self.desc_txt(desc) else: msg += self.desc_rst(desc) symbols = v.get("symbols") if symbols: msg += "Has the following ABI:\n\n" for w, label in symbols: # Escape special chars from content content = self.re_escape.sub(r"\\\1", w) msg += f"- :ref:`{content} <{label}>`\n\n" users = v.get("users") if users and users.strip(" \t\n"): users = users.strip("\n").replace('\n', '\n\t') msg += f"Users:\n\t{users}\n\n" ln = v.get("line_no", 1) yield (msg, file_ref[0][0], ln) def check_issues(self): """Warn about duplicated ABI entries.""" for what, v in self.what_symbols.items(): files = v.get("file") if not files: # Should never happen if the parser works properly self.log.warning("%s doesn't have a file associated", what) continue if len(files) == 1: continue f = [] for fname, lines in sorted(files.items()): if not lines: f.append(f"{fname}") elif len(lines) == 1: f.append(f"{fname}:{lines[0]}") else: m = fname + "lines " m += ", ".join(str(x) for x in lines) f.append(m) self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f)) def search_symbols(self, expr): """ Searches for ABI symbols.""" regex = re.compile(expr, re.I) found_keys = 0 for t in sorted(self.data.items(), key=lambda x: [0]): v = t[1] wtype = v.get("type", "") if wtype == "File": continue for what in v.get("what", [""]): if regex.search(what): found_keys += 1 kernelversion = v.get("kernelversion", "").strip(" \t\n") date = v.get("date", "").strip(" \t\n") contact = v.get("contact", "").strip(" \t\n") users = v.get("users", "").strip(" \t\n") desc = v.get("description", "").strip(" \t\n") files = [] for f in v.get("file", ()): files.append(f[0]) what = str(found_keys) + ". " + what title_tag = "-" * len(what) print(f"\n{what}\n{title_tag}\n") if kernelversion: print(f"Kernel version:\t\t{kernelversion}") if date: print(f"Date:\t\t\t{date}") if contact: print(f"Contact:\t\t{contact}") if users: print(f"Users:\t\t\t{users}") print("Defined on file(s):\t" + ", ".join(files)) if desc: desc = desc.strip("\n") print(f"\n{desc}\n") if not found_keys: print(f"Regular expression /{expr}/ not found.")