Return a copy of the __all__ dict with irrelevant items removed. Parameters ---------- module : ModuleType The module whose __all__ dict has to be processed Returns ------- deprecated : list List of callable and deprecated sub modules not_deprecated
(module)
| 233 | |
| 234 | |
| 235 | def get_all_dict(module): |
| 236 | """ |
| 237 | Return a copy of the __all__ dict with irrelevant items removed. |
| 238 | |
| 239 | Parameters |
| 240 | ---------- |
| 241 | module : ModuleType |
| 242 | The module whose __all__ dict has to be processed |
| 243 | |
| 244 | Returns |
| 245 | ------- |
| 246 | deprecated : list |
| 247 | List of callable and deprecated sub modules |
| 248 | not_deprecated : list |
| 249 | List of non callable or non deprecated sub modules |
| 250 | others : list |
| 251 | List of remaining types of sub modules |
| 252 | """ |
| 253 | if hasattr(module, "__all__"): |
| 254 | all_dict = copy.deepcopy(module.__all__) |
| 255 | else: |
| 256 | all_dict = copy.deepcopy(dir(module)) |
| 257 | all_dict = [name for name in all_dict |
| 258 | if not name.startswith("_")] |
| 259 | for name in ['absolute_import', 'division', 'print_function']: |
| 260 | try: |
| 261 | all_dict.remove(name) |
| 262 | except ValueError: |
| 263 | pass |
| 264 | if not all_dict: |
| 265 | # Must be a pure documentation module |
| 266 | all_dict.append('__doc__') |
| 267 | |
| 268 | # Modules are almost always private; real submodules need a separate |
| 269 | # run of refguide_check. |
| 270 | all_dict = [name for name in all_dict |
| 271 | if not inspect.ismodule(getattr(module, name, None))] |
| 272 | |
| 273 | deprecated = [] |
| 274 | not_deprecated = [] |
| 275 | for name in all_dict: |
| 276 | f = getattr(module, name, None) |
| 277 | if callable(f) and is_deprecated(f): |
| 278 | deprecated.append(name) |
| 279 | else: |
| 280 | not_deprecated.append(name) |
| 281 | |
| 282 | others = set(dir(module)).difference(set(deprecated)).difference(set(not_deprecated)) |
| 283 | |
| 284 | return not_deprecated, deprecated, others |
| 285 | |
| 286 | |
| 287 | def compare(all_dict, others, names, module_name): |
no test coverage detected