Skip to main content

CLI_Explorer

A Python lib that enables you to load a command-line file explorer for your users !

This lib allows you to ask the user to look for a specific file, folder, or a location in which to save a file !
The lib also comes with a built-in duplicate system, which lets you or the user choose what to do if a file with the same filename already exists, and much more features !

Install

Install from PyPI

To install the library, just type pip install python-console-explorer and this should be ok.

Visit PyPI for more info.

Install from source

Just download the file at this link, and import it in your project.

Usage

See examples if wanted.

The library gives access to two functions. The first allows to browse for a file, the second for a folder.

The browse_for_file function

This function will return the path to a file. This file might be non-existent, if the parameter existence_required is set to False (default).

Parameters :

  • path : The default path in which the explorer will be opened.
  • existence_required : Boolean indicating whether or not the file should already exist.
  • handle_same_file : Boolean indicating whether or not to warn the user if the file he selected already exists.
    • Automatically False if existence_required is True.
  • enable_commands : Boolean indicating whether or not commands (MKDIR/RMDIR) are enabled.
  • extensions_list : A tuple of extensions the user can open. By default, any.
  • cancel_enabled : Boolean indicating if the CANCEL command should be enabled or not.

The browse_for_folder function

This function will return the path to a folder.

Parameters :

  • path : The default path in which the explorer will be opened.
  • enable_commands : Boolean indicating whether or not commands (MKDIR/RMDIR) are enabled.
  • cancel_enabled : Boolean indicating if the CANCEL command should be enabled or not.

Example

Creating a basic text editor.

This program is a text editor, the user will input each line, one by one, then type EXIT when he's finished.

Afterwards, he will look for a place to save the file.

File available on GitHub

from console_explorer import *

# Creating the two required variables
text = ""  # The file's text
user_input = ""  # The user input (just initialized, here)

# Looping until the user types 'EXIT'
while user_input != "EXIT":
    # Asking him a line
    user_input = input("")
    # If the line is not 'EXIT' (which would mean we are done writing the text), we add the
    # inputted line to the text
    if not user_input == "EXIT": text += user_input + "\n"

# We ask the user to choose the file destination.
# Also, we only want it to be a plain text (.txt) file or Markdown file (.md)
file_to_save_in = browse_for_file(extensions_list=("txt", "md"))

# If the user cancelled the save, we simply pass
if file_to_save_in is None:
    pass
# Otherwise, we open the file he selected, and we put the text inside.
else:
    with open(file_to_save_in, "w") as file:
        file.write(text[:-1])

Release files for python-console-explorer 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-console-explorer 1.2.0
File Size Uploaded
python_console_explorer-1.2.0.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-console-explorer 1.2.0
File Interpreter ABI Platform
python_console_explorer-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.0 kB

Release files / python_console_explorer-1.2.0.tar.gz

Download URL python_console_explorer-1.2.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fe1f50b749769d0104de8874f6fc6c78d809343f95110ac585ff16d031e58332
BLAKE2b-256 checksum
How to use checksums
df35f4927f211fc348d4e4261fe06b3e00eb4a46170e5a3366f9d94804095df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / python_console_explorer-1.2.0-py3-none-any.whl

Download URL python_console_explorer-1.2.0-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcb9df0a0c9beddd139d8de1522bfe0beb8083b98aeaa57486db3b072043578c
BLAKE2b-256 checksum
How to use checksums
136edf25f4e1b2ec76701e9c1a229864a64d4bbdc56123cbeeadf3dbf90e0fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page