Skip to main content

A project that when given a folder path, generates a tree of all the files inside

Project description

Supa File Tree

A project that when given a folder path, generates a tree of all the files inside it. I created this using pure python and its base packages.

I made it because I couldn't find any python packages that did this. I intend to publish it into pip soon (whenever their website allows me to)

Project Output

I ran the program on a local copy of my tic-tac-toe project. Here is the generated output

├── assests
│   ├── null
│   │   └── null.png
│   ├── O_Assets
│   │   ├── O.png
│   │   ├── O_diag.png
│   │   ├── O_diag2.png
│   │   ├── O_hor.png
│   │   ├── O_hor2.png
│   │   ├── O_vert.png
│   │   └── O_vert2.png
│   ├── sounds
│   │   ├── Button_Sound.wav
│   │   └── license.txt
│   └── X_Assets
│       ├── X.png
│       ├── X_diag.png
│       ├── X_diag2.png
│       ├── X_hor.png
│       └── X_vert.png
├── ReadMe.txt
└── tic_tac_toe_GUI.py

Run this project and get output in input path

Let's say you want the file tree of _C:\Users\otherfile\project. So create a test.py or a python file, then write and run the following code

input_path = "C:\\Users\\otherfile\\project"

ftree = FileTree(input_path=input_path)
ftree.create()

This will create a file tree and store the output at _C:\Users\otherfile\project\out.txt. Alternatively, you can also modify the last line to have a variable take the result of ftree.create() to capute the output like so

...
output = ftree.create()

Run this project with a .treeignore file

Let's say you don't want certain files/folders to be shown in the file tree. Then you can create a .treeignore file and add it either in the input path or anywhere accessabile by your test.py file. For convience, I have mine where I'm running test.py file.

The .treeignore file works essentially like a .gitignore except you need to put subfolders as their own. So instead of src/node_modules you would put node_modules in the tree ignore.

input_path = "C:\\Users\\otherfile\\project"
tree_ignore_path = ".//"

ftree = FileTree(input_path=input_path, tree_ignore_path=tree_ignore_path)
ftree.create()  # Generates output and stores it at `C:\Users\otherfile\project\out.txt`

Run the file and store the output elsewhere

You can also run the file and store the output in another location. For convience, I storing mine where I'm running test.py file.

input_path = "C:\\Users\\otherfile\\project"
out_path = ".//"

ftree = FileTree(input_path=input_path, out_path=out_path)
ftree.create()  # Generates output and stores it at `C:\Users\otherfile\project\out.txt`

Debug while running the file

input_path = "C:\\Users\\otherfile\\project"

ftree = FileTree(input_path=input_path, debug=True)
ftree.create()  # Generates output and stores it at `C:\Users\otherfile\project\out.txt`

Summary of FileTree variables

input_path is (REQUIRED)
out_path is (OPTIONAL) (Defaults to input path)
tree_ignore_path is (OPTIONAL)  (Defaults to input path)

How to not include some files in tree

Create .treeignore and add the file/folders you don't want to see in the tree.

The .treeignore file works essentially like a .gitignore except you need to put subfolders as their own. So instead of src/node_modules you would put node_modules in the tree ignore.

Example .treeignore file

.git
.gitignore

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

SupaFileTree-0.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

SupaFileTree-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file SupaFileTree-0.2.0.tar.gz.

File metadata

  • Download URL: SupaFileTree-0.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for SupaFileTree-0.2.0.tar.gz
Algorithm Hash digest
SHA256 06b59f6d4f5d9c1186f085cc1363aa184b6bf30d0548a1dfc9831892378dd5a0
MD5 0a916b5c10a58e7d2de6944f36e7346b
BLAKE2b-256 6d1a697ab74d3f20c244a3199cbe652b2bf2de89b0df80998e1b74be5880088c

See more details on using hashes here.

File details

Details for the file SupaFileTree-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: SupaFileTree-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for SupaFileTree-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeb735d8e7e4a6703a68e962bcb0c6982f9f85cc82943e2beb6e834128ed49ff
MD5 a67b1a70cbbd367529370e9634864cf8
BLAKE2b-256 4c91a962334df86be70d7c2626ef28dbedc41e8f2b83324cc926f3e517e800a4

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