|
LibInsult - Python
|
Object that can generate insults. More...
Public Member Functions | |
| def | __init__ (self) |
| def | word_list (self, wl_id, add=False) |
| Returns a matching word list. More... | |
| def | load_directory (self, path) |
Loads all word lists in path. More... | |
| def | add_words (self, wl_id, words) |
| Adds words to a word list. More... | |
| def | get (self, wl_id, max_count=1, min_count=None) |
| Retrieves a random subset of words form a word list. More... | |
| def | format (self, string) |
| Formats an insult string. More... | |
| def | set_max (self, max_count, word_list=None) |
| Set the maximum number of repetitions for get() More... | |
| def | set_rules (self, name, rules) |
| Sets some language rules for the given identifier. More... | |
Public Attributes | |
| word_lists | |
| Word lists to look up. More... | |
| max_count | |
| Maximum number of repetitions allowed. More... | |
| list_max_count | |
| Maximum number of repetitions allowed for a specific word list. More... | |
| rules | |
| Language rules. More... | |
Static Public Attributes | |
| regex_word_file = re.compile(r'^[a-z_]+$') | |
| Regex used to recognize valid word file names. More... | |
| string | rules_file = "rules.json" |
| File name for language rules. More... | |
Object that can generate insults.
| def insult.Insulter.add_words | ( | self, | |
| wl_id, | |||
| words | |||
| ) |
Adds words to a word list.
| wl_id | WordListId to match the list |
| words | Iterable with words to be added |
Definition at line 165 of file insult.py.
Referenced by insult.Insulter.load_directory().
| def insult.Insulter.format | ( | self, | |
| string | |||
| ) |
| def insult.Insulter.get | ( | self, | |
| wl_id, | |||
max_count = 1, |
|||
min_count = None |
|||
| ) |
Retrieves a random subset of words form a word list.
| wl_id | WordListId to match the list |
| max_count | Maximum number of words to return, note that it will be checked against the value set with set_max() |
| min_count | Minimum number of words to return, if omitted, returns exactly max_count words |
Definition at line 173 of file insult.py.
Referenced by insult.Insulter.format().
| def insult.Insulter.load_directory | ( | self, | |
| path | |||
| ) |
| def insult.Insulter.set_max | ( | self, | |
| max_count, | |||
word_list = None |
|||
| ) |
Set the maximum number of repetitions for get()
| max_count | Maximum to be set, if None will disable the maximum limit |
| word_list | Word list name (note: not a WordListId) |
| def insult.Insulter.set_rules | ( | self, | |
| name, | |||
| rules | |||
| ) |
Sets some language rules for the given identifier.
Definition at line 252 of file insult.py.
Referenced by insult.Insulter.load_directory().
| def insult.Insulter.word_list | ( | self, | |
| wl_id, | |||
add = False |
|||
| ) |
Returns a matching word list.
| wl_id | WordListId to match the list |
| add | if True, missing lists will be added to the insulter |
| Exception | if the list cannot be retrieved |
Definition at line 126 of file insult.py.
Referenced by insult.Insulter.add_words(), and insult.Insulter.get().
| insult.Insulter.list_max_count |
Maximum number of repetitions allowed for a specific word list.
Definition at line 122 of file insult.py.
Referenced by insult.Insulter.get(), and insult.Insulter.set_max().
| insult.Insulter.max_count |
Maximum number of repetitions allowed.
Definition at line 120 of file insult.py.
Referenced by insult.Insulter.get(), and insult.Insulter.set_max().
|
static |
| insult.Insulter.rules |
Language rules.
Definition at line 124 of file insult.py.
Referenced by insult.Insulter.format(), and insult.Insulter.set_rules().
|
static |
| insult.Insulter.word_lists |
Word lists to look up.
Definition at line 118 of file insult.py.
Referenced by insult.Insulter.word_list().
1.8.11