(refcount_filename: Path)
| 79 | |
| 80 | |
| 81 | def read_refcount_data(refcount_filename: Path) -> dict[str, RefCountEntry]: |
| 82 | refcount_data = {} |
| 83 | refcounts = refcount_filename.read_text(encoding="utf8") |
| 84 | for line in refcounts.splitlines(): |
| 85 | line = line.strip() |
| 86 | if not line or line.startswith("#"): |
| 87 | # blank lines and comments |
| 88 | continue |
| 89 | |
| 90 | # Each line is of the form |
| 91 | # function ':' type ':' [param name] ':' [refcount effect] ':' [comment] |
| 92 | parts = line.split(":", 4) |
| 93 | if len(parts) != 5: |
| 94 | raise ValueError(f"Wrong field count in {line!r}") |
| 95 | function, type, arg, refcount, _comment = parts |
| 96 | |
| 97 | # Get the entry, creating it if needed: |
| 98 | try: |
| 99 | entry = refcount_data[function] |
| 100 | except KeyError: |
| 101 | entry = refcount_data[function] = RefCountEntry(function) |
| 102 | if not refcount or refcount == "null": |
| 103 | refcount = None |
| 104 | else: |
| 105 | refcount = int(refcount) |
| 106 | # Update the entry with the new parameter |
| 107 | # or the result information. |
| 108 | if arg: |
| 109 | entry.args.append((arg, type, refcount)) |
| 110 | else: |
| 111 | entry.result_type = type |
| 112 | entry.result_refs = refcount |
| 113 | |
| 114 | return refcount_data |
| 115 | |
| 116 | |
| 117 | def read_stable_abi_data(stable_abi_file: Path) -> dict[str, StableABIEntry]: |
no test coverage detected
searching dependent graphs…