Skip to main content

This package will help impart autocompletion to your python script inputs.

Project description

Tab Auto-Completion

(requires pynput Package, getch and runs in python3 )

It is a python module which will help the user to import the Press tab to auto complete feature into their python scripts.

The basic purpose for such a module was that, I needed to impart auto complete feature into a python script of mine, so that the user doesn't always have to type in the complete phrase each and everytime and at the same time will hwlp to standardise my input in the program.

The module requires a json file or a dictionary which has to loaded onto so the object which can search for possible values of the input based on history of user's input. Each and every time the user inputs a new possible value, it is recorded in the json files (this feature is not available if you pass a dictionary to the object) and the recomendations will be shown from the nexttime onwards.

The json file will have to contain a dictionary in the following structure:

{"typeName1":[list, of, possible, values, in, a python, list],
 "typeName2":[list, of, possible, values, in, a python, list],
 "typeName3":[list, of, possible, values, in, a python, list]}

The script is able to handle more than one type of names tags under which their possible values are listed.

Note: The script uses ASCCI escape codes for controlling the postion of the cursor in the command line.

Usage:

The module is made as simple as possible so that th user will have to just import it into their script and call the function though the object initialised. To import the module into your script please place the script in the same directory of that of your script or add the python module globally (method specified below).

  • import the module :

from tabCompletion import Tabcomplete
  • initialise the object :

The object can be initialised either by using a path to the json file that contains a dictionary or by passing a dictionary directly. If you wish to pass the path to json file the:

ObjectName = Tabcomplete("pathToJsonFile.json")

Or if you wish to pass a dictionary directly to the object, then:

sampleDict = {"sample Id":[list, of, sample, items], "sample Id2": [list]}
ObjectName = Tabcomplete(sampleDict)

At present the module will not support dynamic update of the dict passed on. But at the same time, if you pass on a json file, new entries will be updated onto the json file.

  • get inputs using the initialised class :

inputVariable = ObjectName.getip("displayText", "typeName")

ObjectName.getip() function has 3 default parameter:

  • caseSensitive - default value = 'n' - suggestions are caseSensitive if the value is 'y'
  • compulsoryInput - default value = 'y' - the user cannot pass an empty string as input if the value is set to 'y'
  • dynamicUpdation - default value = 'y' - if new user inputs are entered that are not in the suggestions lists, the json files passed will be updated

typeName refers to the nameTag underwhich the possible values are stored in the json file.

Note: A json file is a must for the program to run. So initially even if you sont have any possible values Please create a json file containing a dictionary which will follow the proposed structure (where the list of possible values can be left empty).

The list of possible values unser each nametag can be left empty as these values will be updated in the json based on the user's input.

How to Install the required modules:

To run this modules, you would require to install some python modules using pip3.

pip3 install pynput
pip3 install getch

How to add tabCompletion module globally:

To make this module available globally in your local system, add the path of you module to .basrc

cd ~/folder/where/the/project/is/cloned
echo "#Python module for tab completion" >> ~/.bashrc
echo "export PYTHONPATH=$PWD/" >> ~/.bashrc

Now that you have linked the module globally, please restart your terminal and check if the module is linked:

python3
import tabCompletion

If no error are shown, then you have linked the module succefully.

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

tabCompletion-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

tabCompletion-1.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file tabCompletion-1.0.0.tar.gz.

File metadata

  • Download URL: tabCompletion-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5rc1

File hashes

Hashes for tabCompletion-1.0.0.tar.gz
Algorithm Hash digest
SHA256 80d0354a2f89b1a04e01ef7f4203ecdf30692ca2f78f49fba70f4d32dd4e1a67
MD5 7604c529610e0b63bd4b4cb070581359
BLAKE2b-256 0ed5163247acb7c9d8883a37adce6dfed6419fbf0d9fa022768072be17123daa

See more details on using hashes here.

File details

Details for the file tabCompletion-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tabCompletion-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5rc1

File hashes

Hashes for tabCompletion-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70f9d56bc08bd6d90ce4abf3759a8b2f3cbd06a9f96a8ebb3aa083dee1cb3e34
MD5 6f48eae924bd1f08287b6a5dcf1de2e8
BLAKE2b-256 d30d962b2231f35cd63ae2596b9c9d12d84b52caf37d12bdfec719dc12f6adee

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