Create a directory listing diagram from text file
Project description
dirlisting
Create a directory tree listing from a text file for use in documentation.
There are plenty of good tools out there to produce directory tree listings from an existing directory structure. This tool handles the situation when you don't have and don't want to create a directory structure for the sole purpose of producing a directory tree listing for a document or email.
Read the documentation on ReadTheDocs!
Installation
$ pip install dirlisting
Usage
dirlisting
can be used to create a directory tree listing that looks like those
created with the tree
command, but from a text file instead of walking an actual
directory tree.
From code
Reading a file
from dirlisting.dirlisting import Dirlisting
with open("input.yaml") as f:
listing = Dirlisting(f)
listing.print()
From a string
from dirlisting.dirlisting import Dirlisting
input = """
- topdir:
- subdir1:
- file1.txt
- file2.txt
"""
Dirlisting(input).print()
From the command line
Just use dirlisting <filename>
.
dirlisting [OPTIONS] FILE
Create a directory listing given an input FILE.
Options:
--version Show the version and exit.
-s, --sort Sort the directory entries.
-d, --dirsfirst List directories before files.
-o, --output FILENAME Output to this file.
--help Show this message and exit.
File format
The input file is a yaml file. Each of the entries is treated as
part of a sequence and starts with a -
. The files are final strings and the file name
comes after the dash (- filename
). The directories are mappings and the directory name
is followed by a colon (- dirname:
). A listing would look like the following.
:::::{grid} 2 ::::{grid-item-card} YAML File
- topdir:
- emptydir:
- file1.txt
- file2.txt
- subdir:
- file3.txt
:::: ::::{grid-item-card} Output
topdir
├── emptydir
├── file1.txt
├── file2.txt
└── subdir
└── file3.txt
:::: :::::
When using the output option to save to a file, the file will be saved with "utf-8" encoding. On a Mac or Linux machine this works seamlessly. There can be problems with the console on Windows, but most modern editors can open the file with "utf-8" encoding.
Contributing
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
dirlisting
was created by Stephan Poole. It is licensed under the terms of the MIT
license.
Credits
dirlisting
was created with
cookiecutter
and the
py-pkgs-cookiecutter
template.
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
File details
Details for the file dirlisting-0.4.0.tar.gz
.
File metadata
- Download URL: dirlisting-0.4.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57587153de30306bc7b9add5ae8eb4967edd58c23dc1f360d3b4e008525fd88d |
|
MD5 | 8bdce5c90618e0ba5894ec675ab5086a |
|
BLAKE2b-256 | cea00386bfd2961d2b2e7b9f0c713bd5bd5e3b9e3d57a06c8cc1344652abbc0a |
File details
Details for the file dirlisting-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: dirlisting-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fa1e5826c347802921c7b0150e304def70b6a6f59ca73f75c6ebb3eec807033 |
|
MD5 | ce56f5397591069c873e49f62b8e5753 |
|
BLAKE2b-256 | 0d5646ba4e5cc91589078c2988507830f97e14f20cea50082cefcfa7e5690d3f |