Command line tool for organizing and displaying hierarchical relationships using a folder-based structure and text files.
Project description
txttree
txttree is a command line tool for organizing and displaying hierarchical relationships using a folder-based structure and text files.
Basically, txttree is like tree for text files with some added features for interpreting file contents like properties and values.
Example
txttree can be used to maintain information or organizational structure in a text based format.
For example, we could display the structure of Easy Company, a U.S. Army unit which was described in the series Band of Brothers.
$ python -m txttree "test/Easy Company"
Easy Company
│ CO: Capt. Richard Winters (1944-06-07)
│ XO: 1st Lt. Harry Welsh (1944-06-08)
│ First Sergeant: SFC Carwood Lipton (1944-06-08)
├─ 1st Platoon
│ │ Platoon Leader: 1st Lt. Thomas Peacock
│ │ Assistant Leader: 2nd Lt. Charles Hudson
│ │ Platoon Sergeant: SFC Floyd Talbert
│ ├─ 1st Squad
│ ├─ 2nd Squad
│ ├─ 3rd Squad
│ └─ Mortar Squad
├─ 2nd Platoon
│ │ Platoon Leader: 1st Lt. Lynn Compton
│ │ Assistant Leader: 2nd Lt. John Pisanchin
│ │ Platoon Sergeant: SFC William Guarnere
│ ├─ 1st Squad
│ ├─ 2nd Squad
│ ├─ 3rd Squad
│ └─ Mortar Squad
└─ 3rd Platoon
│ Platoon Leader: 1st Lt. Robert Brewer
│ Assistant Leader: 2nd Lt. Ben Perkins
│ Platoon Sergeant: SFC Amos Taylor
├─ 1st Squad
├─ 2nd Squad
├─ 3rd Squad
└─ Mortar Squad
The txttree command takes a root folder: in this case test/Easy Company.
txttree then recurses through the directory structure and prints the contents of folders and properties in text files, like the tree command in linux.
See below how txttree interprets text files.
The example data is in the test/ folder in this repository.
Usage
Usage: python -m txttree [OPTIONS] ROOT_DIRECTORY_PATH
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│ * root_directory_path PATH Root directory for the hierarchy. │
│ [default: None] │
│ [required] │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
File and folder structure
txttree uses folder structure for the hierarchy and the information in text files for the properties.
All text files (with extension .txt) in subfolders will be searched for properties and displayed as a node.
The text files describe data in a log-style format.
This is an example of a text file with parameters that can be interpreted by txttree.
This fictional example file describes the structure of Easy Company in a log.
The command structure of Easy Company is as follows:
CO: 1st Lt. Thomas Meehan
XO: 1st Lt. Richard Winters
First Sergeant: William Evans
1944-06-06
It is D-Day.
The landings have begun.
1944-06-07
No sign of 1st Lt. Thomas Meehan.
Capt. Richard Winters assumes the role of commanding officer.
CO: Capt. Richard Winters
This file demonstrates three possible line types in a text file:
- A property is a line in a text file that starts with a property key like "CO", a colon ":" and a property value like "1st Lt. Thomas Meehan".
For example:
CO: 1st Lt. Thomas Meehan. You are free to chose which property keys make sense for your use case.- If the same property is defined multiple times in the file, the last value of the property is taken. This makes it easy to update data in the future.
- A property key can be one to three words long.
- An optional date line indicates the date of the text or properties.
The date will be shown in
txttreeoutput in parentheses after the property, for example:CO: Capt. Richard Winters (1944-06-07). A date line can be in three formats:- ISO format: for example "1944-06-06",
- Short format: for example "440606",
- Long format: for example "19440606".
- A normal text line, which is neither a property nor a date line.
Normal text lines are ignored by
txttree.
Text files in a folder will be displayed as separate nodes. The only exception is a text file with the same name as the parent folder: these properties are displayed under the parent folder.
Installation
Releases are made available on PyPi.
The recommended installation method is via pip:
pip install txttree
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file txttree-0.0.1.tar.gz.
File metadata
- Download URL: txttree-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e6032f9ce532d50933f6bf49bedb63fa96172ea6c7d6f3e9a4367dc5ecabfa8
|
|
| MD5 |
07dcd3b5fb75ae951160c5063038eea1
|
|
| BLAKE2b-256 |
88666606b483f67c558260d19f8b182ac35dd366fb16c684a9840295666d6b0e
|
File details
Details for the file txttree-0.0.1-py3-none-any.whl.
File metadata
- Download URL: txttree-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caa1c29c69c226f7d9a5a71943079832cbe071fec39d743eac591b29c9a852d2
|
|
| MD5 |
332cd0e4e0211aec3882856ea549af13
|
|
| BLAKE2b-256 |
501ee4198484880c4c0b6d59e0fcea501f796d3e43e01d25677d40dc31ec2f91
|