Package: mansel-lib
manselmanselis a Python library and command line tool for manually selecting files and directories from a tree view.FeaturesGraphical 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.Installationmanselcan be installed withpip:pip install manselThemanselpackage depends onPySide2which packages the Qt runtime and Python bindings to it.
Alternatively, themanselcommand line tool can be installed withpip install mansel-pyqtmansel-pyqtdepends onPyQt5and requires that the Qt runtime be installed separately.Bothmanselandmansel-pyqtdepend on themansel-libpackage which can be installed directly if you want to usemansel's features in another project without installing the command line tool.Usagemanselcan be run from the command-line withmansel --path PATH --selection SELECTIONwherePATHis the root path to use for file selection andSELECTIONis a file containing a newline delimited list of paths relative toPATHwhich should be selected when the file selection window opens. Invokingmanselopens a dialog window with the contents ofPATHshown 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 belowPATH.  WhenOKis pressed to exit the window, the list of selected files and directories is printed tostdout.Usage notesIfSELECTIONis-, 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.APIWhen usingmanselin 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.Contributingmanselis 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 usemanselin your project.
If you make improvements tomansel, please share them if sharing is feasible.Related projectstreeselprovides 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 writingmanselsome 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.Urwidis a Python terminal interface library. One of the example projects in the Urwid documentation is a file browser naemdbrowse.pywhich allows for multiple selection of files and then prints out the file paths on exit.fzfis a terminal program that allows for selection of file paths through fuzzy finding of the path strings. There are many similar projects (seefzf's releated projects list).fzfdoes not have a tree view but it does allow selecting and printing multiple file paths to stdout.Future directionsmanselmeets 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 ontreesel(using thecursesmodule) or Urwid'sbrowse.py. Alternatively, it could usePrompt Toolkit.Improve continuous integration:Run tests on new commitsRun nightly tests against latest versions of dependenciesAdd pylint and pycodestyle testsAdd UI tests that click on checkboxes and buttonsImprove packaging:Create PyPI packageCreate conda packageCreate other packages (PyInstaller? Linux snap package?)