(imports, encoding=None)
| 252 | |
| 253 | |
| 254 | def get_import_local(imports, encoding=None): |
| 255 | local = get_locally_installed_packages() |
| 256 | result = [] |
| 257 | for item in imports: |
| 258 | # search through local packages |
| 259 | for package in local: |
| 260 | # if candidate import name matches export name |
| 261 | # or candidate import name equals to the package name |
| 262 | # append it to the result |
| 263 | if item in package['exports'] or item == package['name']: |
| 264 | result.append(package) |
| 265 | |
| 266 | # removing duplicates of package/version |
| 267 | # had to use second method instead of the previous one, |
| 268 | # because we have a list in the 'exports' field |
| 269 | # https://stackoverflow.com/questions/9427163/remove-duplicate-dict-in-list-in-python |
| 270 | result_unique = [i for n, i in enumerate(result) if i not in result[n+1:]] |
| 271 | |
| 272 | return result_unique |
| 273 | |
| 274 | |
| 275 | def get_pkg_names(pkgs): |
no test coverage detected