Get PyPI package names from a list of imports. Args: pkgs (List[str]): List of import names. Returns: List[str]: The corresponding PyPI package names.
(pkgs)
| 273 | |
| 274 | |
| 275 | def get_pkg_names(pkgs): |
| 276 | """Get PyPI package names from a list of imports. |
| 277 | |
| 278 | Args: |
| 279 | pkgs (List[str]): List of import names. |
| 280 | |
| 281 | Returns: |
| 282 | List[str]: The corresponding PyPI package names. |
| 283 | |
| 284 | """ |
| 285 | result = set() |
| 286 | with open(join("mapping"), "r") as f: |
| 287 | data = dict(x.strip().split(":") for x in f) |
| 288 | for pkg in pkgs: |
| 289 | # Look up the mapped requirement. If a mapping isn't found, |
| 290 | # simply use the package name. |
| 291 | result.add(data.get(pkg, pkg)) |
| 292 | # Return a sorted list for backward compatibility. |
| 293 | return sorted(result, key=lambda s: s.lower()) |
| 294 | |
| 295 | |
| 296 | def get_name_without_alias(name): |