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

Adding a String type token #156

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion testimony/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
- Automated
...

Currently only supported type is 'choice', but in the future more can be added.
Currently only supported types are 'choice' and 'string'
but in the future more can be added.
"""

import yaml
Expand Down Expand Up @@ -79,6 +80,9 @@ def __init__(self, name, config):
self.choices = [i if self.casesensitive else i.lower()
for i in config['choices']]

elif self.token_type == 'string':
pass

def update(self, new_values):
"""Update token configuration with dictionary of new values."""
for key, value in new_values.items():
Expand All @@ -90,4 +94,6 @@ def validate(self, what):
if not self.casesensitive:
what = what.lower()
return what in self.choices
elif self.token_type == 'string':
return isinstance(what, str) # validate it's a string
return True # assume valid for unknown types
1 change: 1 addition & 0 deletions testimony/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

TOKEN_TYPES = [
'choice',
'string'
]

DEFAULT_TOKENS = (
Expand Down
Loading