Skip to main content

Recursively traverses a source directory and yields tuples of Python module names as used in import statements and their corresponding file paths.

Project description

yield-module-names-and-python-file-paths

Recursively traverses a source directory and yields tuples of Python module names as used in import statements and their corresponding file paths.

Features

  • Handles packages.
  • Skips hidden files and directories.
  • Useful for code analysis tools.

Installation

pip install yield-module-names-and-python-file-paths

Usage

Suppose your project has this structure:

src/
├── foo.py
├── bar.py
├── subpkg/
│   ├── __init__.py
│   └── utils.py
└── scripts/
    └── tool.py

You can enumerate the modules:

from yield_module_names_and_python_file_paths import yield_module_names_and_python_file_paths

for module_name, python_file_path in yield_module_names_and_python_file_paths('src'):
    print(module_name, '->', python_file_path)

Output:

foo -> myproject/foo.py
bar -> myproject/bar.py
subpkg -> myproject/subpkg/__init__.py
subpkg.utils -> myproject/subpkg/utils.py
scripts.tool -> myproject/scripts/tool.py

Contributing

Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file yield_module_names_and_python_file_paths-0.1.0a0.tar.gz.

File metadata

File hashes

Hashes for yield_module_names_and_python_file_paths-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 2bc6f5dc5d1f7f93550201aa8250ba29426d3330119252921c29948fb2640387
MD5 6c94e74cc66e668b76f9b22b0afd131a
BLAKE2b-256 11506ebfd6ab252ad1fddc1df0feea8b2e97e4dd8855d688a4589168c9511813

See more details on using hashes here.

File details

Details for the file yield_module_names_and_python_file_paths-0.1.0a0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for yield_module_names_and_python_file_paths-0.1.0a0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b3ce0fd5b325ff3649919786824fa9154fd7421141919ea5d723df72e663d889
MD5 8430ccc9a9042590312ead27496c9f52
BLAKE2b-256 737f96dce82ae08bf060a1e011299a1ebdf4271ea62070977b610c25d8b795f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page