Skip to main content

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

Project description

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])

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

python_console_explorer-1.2.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_console_explorer-1.2.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file python_console_explorer-1.2.0.tar.gz.

File metadata

  • Download URL: python_console_explorer-1.2.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for python_console_explorer-1.2.0.tar.gz
Algorithm Hash digest
SHA256 fe1f50b749769d0104de8874f6fc6c78d809343f95110ac585ff16d031e58332
MD5 1703a94ad821eddd658514c26302dfd6
BLAKE2b-256 df35f4927f211fc348d4e4261fe06b3e00eb4a46170e5a3366f9d94804095df4

See more details on using hashes here.

File details

Details for the file python_console_explorer-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: python_console_explorer-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for python_console_explorer-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcb9df0a0c9beddd139d8de1522bfe0beb8083b98aeaa57486db3b072043578c
MD5 5c3dd873d178613225377af716380182
BLAKE2b-256 136edf25f4e1b2ec76701e9c1a229864a64d4bbdc56123cbeeadf3dbf90e0fa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page