This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit 4457e78b8470ce6991d5046e7d4a0a579236a920 Author: Greg Stein <[email protected]> AuthorDate: Mon May 30 21:51:22 2022 -0500 draft impl, based on v2 --- v3/steve/vtypes/yna.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/v3/steve/vtypes/yna.py b/v3/steve/vtypes/yna.py index cf459bc..c5e135f 100644 --- a/v3/steve/vtypes/yna.py +++ b/v3/steve/vtypes/yna.py @@ -18,3 +18,26 @@ # # ### TBD: DOCCO # + +# The votestring will be lower-cased. What is the result? +YES = { 'y', 'yes', '1', 'true', } +NO = { 'n', 'no', '0', 'false', } +# "abstain" is any other (non-affirmative) value. + + +def tally(votestrings, kv): + y = n = a = 0 + for v in votestrings: + if v in YES: + y += 1 + elif v in NO: + n += 1 + else: + a += 1 + + human = f'''\ +Yes: {y:#4} +No: {n:#4} +Abstain: {a:#4}''' + + return human, {'y': y, 'n': n, 'a': a,}
