Skip to main content

Useful tool for generating variable names

Project description

Contributor Covenant License Language

Closed Issues Commit Activity Build Status

EPONYM

Useful tool for generating variable names. Uses wordsapi.com

Getting Started

Source code

git clone https://github.com/seanchristians/eponym
pip3 install -r eponym/src/requirements.txt

PyPI

pip3 install eponym-alloy

Usage

Eponym can be used as part of a project or by itself. Pass a single string sentence to eponym.synonyms to generate an array of synonyms. eponym.rand takes that array as input and returns a word according to some options. Eponym relies on WordsAPI to generate synonyms. To use the service, create an account on RapidAPI and get a free API key for WordsAPI.

API Key

The script can interpret an API key from three different sources:

  • Any environment variable (defaults to $APIKEY)
  • A file
  • Direct input text To set your API key, you can define it in the script or run export APIKEY="[RapidAPI Application Key]"

Script functionality

usage: python3 -m eponym [-h] [-k KEY] [-l] [-w] [-s SEP] [-m MAX] words [words ...]

Variable name generator

positional arguments:
  words              list of input words

optional arguments:
  -h, --help         show this help message and exit
  -k KEY, --key KEY  api key
  -l, --lower        output lowercase
  -w, --words        output word count
  -s SEP, --sep SEP  word separator
  -m MAX, --max MAX  maximum word length for each synonym

Purging the cache

The script will not automatically clear the cache when terms expire after 6 months. Instead, you can write a cron job to do it yourself or do it manually. Run python3 -c "import eponym; eponym.cache.purge()" to clear the cache of expired items.

Caching

Eponym relies on WordsAPI. In order to reduce calls to the API and retain bandwidth, all requests go through cache.get which builds and maintains a local cache of searched results. cache.py refreshes the cache every cache.timeDelta which is currently set to 6 months.

Languages

Currently, the project only supports English. This is due to both sole use of wordsapi.com and a filter which removes non English letters. See CONTRIBUTING to help out!


© 2020 Sean Christians

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

eponym-alloy-1.0.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

eponym_alloy-1.0.1-py3-none-any.whl (17.9 kB view hashes)

Uploaded Python 3

Supported by

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