Return a list of all functions marked with the @deprecated decorator, and classes with an immediate Deprecated base class, in all Python files in the given directory.
(pkg_dir)
| 114 | |
| 115 | |
| 116 | def find_deprecated_defs(pkg_dir): |
| 117 | """ |
| 118 | Return a list of all functions marked with the @deprecated |
| 119 | decorator, and classes with an immediate Deprecated base class, in |
| 120 | all Python files in the given directory. |
| 121 | """ |
| 122 | # Walk through the directory, finding python files. |
| 123 | for root, dirs, files in os.walk(pkg_dir): |
| 124 | for filename in files: |
| 125 | if filename.endswith(".py"): |
| 126 | # Search the file for any deprecated definitions. |
| 127 | s = open(os.path.join(root, filename)).read() |
| 128 | for m in DEPRECATED_DEF_RE.finditer(s): |
| 129 | if m.group(2): |
| 130 | name = m.group(2) |
| 131 | msg = " ".join( |
| 132 | strip_quotes(s) for s in STRING_RE.findall(m.group(1)) |
| 133 | ) |
| 134 | msg = " ".join(msg.split()) |
| 135 | if m.group()[0] in " \t": |
| 136 | cls = find_class(s, m.start()) |
| 137 | deprecated_methods[name].add((msg, cls, "()")) |
| 138 | else: |
| 139 | deprecated_funcs[name].add((msg, "", "()")) |
| 140 | else: |
| 141 | name = m.group(3) |
| 142 | m2 = STRING_RE.match(s, m.end()) |
| 143 | if m2: |
| 144 | msg = strip_quotes(m2.group()) |
| 145 | else: |
| 146 | msg = "" |
| 147 | msg = " ".join(msg.split()) |
| 148 | deprecated_classes[name].add((msg, "", "")) |
| 149 | |
| 150 | |
| 151 | def print_deprecated_uses(paths): |
no test coverage detected
searching dependent graphs…