padl.dumptools.packagefinder

Utilities for finding packages used in code.

padl.dumptools.packagefinder.dump_packages_versions(nodes)

Dump packages and their versions to a string.

Format of the string is:

<package>==<version>

[…]

Parameters

nodes – List of ast nodes in a module.

Returns

String with packages and versions.

padl.dumptools.packagefinder.get_packages(nodes)

Get a list of package names given a list of ast nodes nodes.

Example:

>>> import ast
>>> source = '''
... import foo.bla as blu
... import bup
... from blip import blop
... ...'''
>>> get_packages(ast.parse(source).body) == {'foo', 'blip', 'bup'}
True
padl.dumptools.packagefinder.get_version(package)

Get a package’s version (defaults to ‘?’).