MCPcopy
hub / github.com/bndr/pipreqs / get_import_local

Function get_import_local

pipreqs/pipreqs.py:254–272  ·  view source on GitHub ↗
(imports, encoding=None)

Source from the content-addressed store, hash-verified

252
253
254def 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
275def get_pkg_names(pkgs):

Callers 1

initFunction · 0.85

Calls 1

Tested by

no test coverage detected