An open API service indexing awesome lists of open source software.

https://github.com/gabrielstork/directory-structure

:package: Print a directory tree structure in your Python code.
https://github.com/gabrielstork/directory-structure

directory emoji file folder structure tree

Last synced: 9 days ago
JSON representation

:package: Print a directory tree structure in your Python code.

Awesome Lists containing this project

README

          

# directory-structure

![PyPI](https://img.shields.io/pypi/v/directory-structure?color=blue)
![PyPI - Downloads](https://img.shields.io/pypi/dm/directory-structure?color=blue)
![PyPI - License](https://img.shields.io/pypi/l/directory-structure?color=blue)
![GitHub watchers](https://img.shields.io/github/watchers/gabrielstork/directory-structure?color=blue)
![GitHub Repo stars](https://img.shields.io/github/stars/gabrielstork/directory-structure?color=blue)
![GitHub forks](https://img.shields.io/github/forks/gabrielstork/directory-structure?color=blue)

Print a directory tree structure in your Python code.

## Download

You can simply:

```sh
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.

```sh
git clone https://github.com/gabrielstork/directory-structure.git
cd directory-structure
pip install -r requirements.txt
```

## Examples

```python
from directory_structure import Tree
```

Using absolute path as an argument.

```python
path = Tree('C:/Users/User/Desktop/directory-structure', absolute=True)
print(path)
```

```text
📂 C:
|_📂 Users
|_📂 User
|_📂 Desktop
|_📂 directory-structure
|_📁 .git
|_📁 directory_structure
|_📄 .gitignore
|_📄 LICENSE
|_📄 pyproject.toml
|_📄 README.md
|_📄 requirements.txt
|_📄 setup.py
```

```python
path = Tree('C:/Users/User/Desktop/directory-structure', absolute=False)
print(path)
```

```text
📂 directory-structure
|_📁 .git
|_📁 directory_structure
|_📄 .gitignore
|_📄 LICENSE
|_📄 pyproject.toml
|_📄 README.md
|_📄 requirements.txt
|_📄 setup.py
```

Accessing a folder in current working directory.

```python
path = Tree('./directory_structure', absolute=True)
print(path)
```

```text
📂 C:
|_📂 Users
|_📂 User
|_📂 Desktop
|_📂 directory-structure
|_📂 directory_structure
|_📄 tree.py
|_📄 __init__.py
```

```python
path = Tree('./directory_structure', absolute=False)
print(path)
```

```text
📂 directory_structure
|_📄 tree.py
|_📄 __init__.py
```

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

```python
path = Tree('../', absolute=True)
print(path)
```

```text
📂 C:
|_📂 Users
|_📂 User
|_📂 Desktop
|_📁 directory-structure
|_📄 Discord.lnk
|_📄 Spotify.lnk
|_📄 Steam.lnk
|_📄 Telegram.lnk
|_📄 Visual Studio Code.lnk
|_📄 WhatsApp.lnk
```

```python
path = Tree('../', absolute=False)
print(path)
```

```text
📂 Desktop
|_📁 directory-structure
|_📄 Discord.lnk
|_📄 Spotify.lnk
|_📄 Steam.lnk
|_📄 Telegram.lnk
|_📄 Visual Studio Code.lnk
|_📄 WhatsApp.lnk
```

[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://github.com/gabrielstork)
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://github.com/gabrielstork)