Attributes to replace name with
(
self, cw: str, prefix: str = "", only_modules: bool = False
)
| 101 | return set(matches) |
| 102 | |
| 103 | def attr_matches( |
| 104 | self, cw: str, prefix: str = "", only_modules: bool = False |
| 105 | ) -> set[str]: |
| 106 | """Attributes to replace name with""" |
| 107 | full = f"{prefix}.{cw}" if prefix else cw |
| 108 | module_name, _, name_after_dot = full.rpartition(".") |
| 109 | if module_name not in sys.modules: |
| 110 | return set() |
| 111 | module = sys.modules[module_name] |
| 112 | if only_modules: |
| 113 | matches = { |
| 114 | name |
| 115 | for name in dir(module) |
| 116 | if name.startswith(name_after_dot) |
| 117 | and f"{module_name}.{name}" in sys.modules |
| 118 | } |
| 119 | else: |
| 120 | matches = { |
| 121 | name for name in dir(module) if name.startswith(name_after_dot) |
| 122 | } |
| 123 | module_part = cw.rpartition(".")[0] |
| 124 | if module_part: |
| 125 | matches = {f"{module_part}.{m}" for m in matches} |
| 126 | |
| 127 | return matches |
| 128 | |
| 129 | def module_attr_matches(self, name: str) -> set[str]: |
| 130 | """Only attributes which are modules to replace name with""" |
no outgoing calls
no test coverage detected