Skip to main content

Print a directory tree structure in your Python code.

Project description

directory-structure

PyPI PyPI - Downloads PyPI - License GitHub watchers GitHub Repo stars GitHub forks

Print a directory tree structure in your Python code.

Download

You can simply:

pip install directory-structure

Or you can also:

  1. Clone the repository to your local machine.
  2. Enter the directory.
  3. Download necessary modules/libraries.
git clone https://github.com/gabrielstork/directory-structure.git
cd directory-structure
pip install -r requirements.txt

Examples

from directory_structure import Tree

Using absolute path as an argument.

path = Tree('C:/Users/User/Desktop/directory-structure', absolute=True)
print(path)
๐Ÿ“‚ C:
|_๐Ÿ“‚ Users
  |_๐Ÿ“‚ User
    |_๐Ÿ“‚ Desktop
      |_๐Ÿ“‚ directory-structure
        |_๐Ÿ“ .git
        |_๐Ÿ“ directory_structure
        |_๐Ÿ“„ .gitignore
        |_๐Ÿ“„ LICENSE
        |_๐Ÿ“„ pyproject.toml
        |_๐Ÿ“„ README.md
        |_๐Ÿ“„ requirements.txt
        |_๐Ÿ“„ setup.py
path = Tree('C:/Users/User/Desktop/directory-structure', absolute=False)
print(path)
๐Ÿ“‚ directory-structure
|_๐Ÿ“ .git
|_๐Ÿ“ directory_structure
|_๐Ÿ“„ .gitignore
|_๐Ÿ“„ LICENSE
|_๐Ÿ“„ pyproject.toml
|_๐Ÿ“„ README.md
|_๐Ÿ“„ requirements.txt
|_๐Ÿ“„ setup.py

Accessing a folder in current working directory.

path = Tree('./directory_structure', absolute=True)
print(path)
๐Ÿ“‚ C:
|_๐Ÿ“‚ Users
  |_๐Ÿ“‚ User
    |_๐Ÿ“‚ Desktop
      |_๐Ÿ“‚ directory-structure
        |_๐Ÿ“‚ directory_structure
          |_๐Ÿ“„ tree.py
          |_๐Ÿ“„ __init__.py
path = Tree('./directory_structure', absolute=False)
print(path)
๐Ÿ“‚ directory_structure
|_๐Ÿ“„ tree.py
|_๐Ÿ“„ __init__.py

Getting all from the directory where your current working directory is.

path = Tree('../', absolute=True)
print(path)
๐Ÿ“‚ C:
|_๐Ÿ“‚ Users
  |_๐Ÿ“‚ User
    |_๐Ÿ“‚ Desktop
      |_๐Ÿ“ directory-structure
      |_๐Ÿ“„ Discord.lnk
      |_๐Ÿ“„ Spotify.lnk
      |_๐Ÿ“„ Steam.lnk
      |_๐Ÿ“„ Telegram.lnk
      |_๐Ÿ“„ Visual Studio Code.lnk
      |_๐Ÿ“„ WhatsApp.lnk
path = Tree('../', absolute=False)
print(path)
๐Ÿ“‚ Desktop
|_๐Ÿ“ directory-structure
|_๐Ÿ“„ Discord.lnk
|_๐Ÿ“„ Spotify.lnk
|_๐Ÿ“„ Steam.lnk
|_๐Ÿ“„ Telegram.lnk
|_๐Ÿ“„ Visual Studio Code.lnk
|_๐Ÿ“„ WhatsApp.lnk

forthebadge forthebadge

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

directory-structure-1.1.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

directory_structure-1.1.2-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

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