Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module support #19

Merged
merged 4 commits into from
Nov 28, 2015
Merged

Module support #19

merged 4 commits into from
Nov 28, 2015

Conversation

LeonardMH
Copy link
Owner

This PR is intended to add better support for using this tool as an importable Python module. It is related to issue #6.

This commit is the first in a series of attempts to make this project
more useful as a Python module. It adds the `namealizer.WordGenerator`
class which is fairly simple and implements all of the same
functionality available from the command line. The object is created as
follows:

    wg = namealizer.WordGenerator("path_to_dictionary")

With other optional initializers of:

    wordstyle -> "lowercase", "uppercase", "capitalize", "mixedcase"
    separator -> Any ascii character to use as a word separator
    seed -> Number to seed the PRNG with, or None to auto-generate

You can then retrieve words in one of two ways:

    wg["abc"] -> returns three words where the words start with each
                 letter given. Raises an NoWordForLetter exception if a
                 word with the desired start letter doesn't exist.

    wg[3] -> returns three words where each word starts with a random
             letter

The `wordstyle` or `separator` can the be changed by accessing these
properties directly, such as:

    wg.separator = "-"
    wg.wordstyle = "uppercase"

Related to issue #6
The previous commit added a new class for using this tool as an
importable module. This commit adds tests to cover that new class.

Test coverage at 98%. Related to issue #6.
@LeonardMH LeonardMH self-assigned this Nov 28, 2015
LeonardMH added a commit that referenced this pull request Nov 28, 2015
@LeonardMH LeonardMH merged commit ef82f81 into master Nov 28, 2015
@LeonardMH LeonardMH deleted the module-support branch November 28, 2015 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant