mansel
mansel is a Python library and command line tool for manually selecting files and directories from a tree view.
Features
- Graphical user interface with a tree view of the directory structure.
- Support for pre-selection of paths in the directory tree.
- Running total of the size of selected directories and files.
- Running total of selection size calculated in a background thread.
Installation
mansel can be installed with pip:
pip install mansel
The mansel package depends on PySide2 which packages the Qt runtime and Python bindings to it.
Alternatively, the mansel command line tool can be installed with
pip install mansel-pyqt
mansel-pyqt depends on PyQt5 and requires that the Qt runtime be installed separately.
Both mansel and mansel-pyqt depend on the mansel-lib package which can be installed directly if you want to use mansel's features in another project without installing the command line tool.
Usage
mansel can be run from the command-line with
mansel --path PATH --selection SELECTION
where PATH is the root path to use for file selection and SELECTION is a file containing a newline delimited list of paths relative to PATH which should be selected when the file selection window opens. Invoking mansel opens a dialog window with the contents of PATH shown as an expandable tree view with checkboxes by every file and directory. Individual files and directories can be selected and unselected and directories can be expanded to select individual files on paths below PATH. When OK is pressed to exit the window, the list of selected files and directories is printed to stdout.
Usage notes
- If
SELECTIONis-, then the selection list is read fromstdin. - A running tally of the current selection size is shown at the bottom of the window. The calculation is performed on a background thread. The size total is followed by "(Calculating)" while the selection size is being re-tallied.
Cancel,Ctrl+W,Ctrl+Qall close the window without printing tostdout.Ctrl+Enteris equivalent to pressingOK.mansel-cliis a wrapper formansel. Effectively, installingmansel-cliinsteallsmanselandPySide2(manseldoes not listPySide2as a dependency to allow it to be used withPyQt5as well) and sets up a wrapper sript that callspython -m mansel.
API
When using mansel in a larger Qt project, there are two main classes for interfaces for working with the manual file selection:
UIDialog(root_path, selection, parent): a complete dialog window displaying a tree view of a file system with checkboxes for all entries.
root_path: top level directory to show in the tree view of the file ssytem.selection: list of paths relative to theroot_pathof files that should be selected when the dialog window is first shown.parent: parent Qt object for the dialog window.
CheckableFileSystemModel: a data model of a file system that supports selecting items from a tree view.
Contributing
mansel is distributed under the permissive 0BSD license.
Outside contirubtions are welcome.
Contributions should be licensed under the 0BSD license.
If you want your name added to the contributors list, add it to AUTHORS.md as part of your submission.
While the license does not require acknowledgement, acknowledgement is still appreciated if you use mansel in your project.
If you make improvements to mansel, please share them if sharing is feasible.
Related projects
- treesel provides a terminal-based tree view of a directory for selecting a file to print to stdout. However, it only allows for a single file to be selected. Before writing
manselsome effort was spent looking for an existing project that could select and print files buttreeselwas not found. It was found later when doing a search to see if the nametreeselectwas available for a Python package. - Urwid is a Python terminal interface library. One of the example projects in the Urwid documentation is a file browser naemd
browse.pywhich allows for multiple selection of files and then prints out the file paths on exit. - fzf is a terminal program that allows for selection of file paths through fuzzy finding of the path strings. There are many similar projects (see
fzf's releated projects list).fzfdoes not have a tree view but it does allow selecting and printing multiple file paths to stdout.
Future directions
mansel meets its original design requirements (tree view file selection with the ability to preselect some files and with a running sum of the selected files' sizes). Here are some possible future improvements that could be made:
-
Implement a console version. This implementation would likely be based on
treesel(using thecursesmodule) or Urwid'sbrowse.py. Alternatively, it could use Prompt Toolkit. -
Improve continuous integration:
- Run tests on new commits
- Run nightly tests against latest versions of dependencies
- Add pylint and pycodestyle tests
- Add UI tests that click on checkboxes and buttons
-
Improve packaging:
- Create PyPI package
- Create conda package
- Create other packages (PyInstaller? Linux snap package?)
Metadata
Release files for mansel 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mansel-0.1.0.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mansel-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / mansel-0.1.0.tar.gz
| Download URL | mansel-0.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69b81a1dbb3562ab0d45c7bb2e529a8d186e2f87afd380036f2976b739b685f6
|
|
BLAKE2b-256 checksum How to use checksums |
2c2fbc29023bc1eaa89ae28e1d5525a74500bc3158382177753741421d595bc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / mansel-0.1.0-py3-none-any.whl
| Download URL | mansel-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14fa0a8be39eff0ef3bba036eaf0227af37e1a15ffbe2ec45927076b08f844d4
|
|
BLAKE2b-256 checksum How to use checksums |
980e1632ffb1cc39ca0482ec900e57b7f0a04266693ec0ebc42d83f9db44bdae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for mansel 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.