Utility library to collect files recursively

file, py, traversal, directory, collect, directory-traversal, module, python-files, python-module, python3
pip install pycollect==0.2.3



license GitHub license
docs Documentation Status
tests Build Status Requirements Status Coverage Status
package PyPI Package latest release PyPI Wheel Supported versions Supported implementations Supported Platforms

Utility library dealing with Python files.

  • Collect Python files recursively from a given directory
  • Find the Python module name respective to a Python file


pip install pycollect

Basic Usage

Collect Python files

collector = PythonFileCollector()
python_files = collector.collect()

When no explicit directory is given the parent folder of caller's file will be used.

It is possible to define custom exclusion patterns. See the docs for more.

Get the module name of a Python file

module_name = find_module_name(filepath)

As there can be multiple valid module names for a given file, by default the outermost module name is returned. The inverse behaviour can be enabled with the innermost parameter. See the docs for more.


See the complete docs at

Integration tests can be pretty helpful to understand pycollect usage more in-depth too.

See also

  • CONTRIBUTING: Bug reports, feature requests, documentation & pull requests.
  • CHANGELOG: See what's changed in each version.
  • AUTHORS: Know who's behind the project.