plint

French poetry validator (local mirror of https://gitlab.com/a3nm/plint)
git clone https://a3nm.net/git/plint/
Log | Files | Refs | README

commit 3d3fe2378d91825ec52f8fdce5dfde53057bff87
parent 5e5381366464dd286d7d988084738bc129dacf19
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 22 Mar 2013 15:35:01 +0100

total syllabe range (thanks, p4bl0)

Diffstat:
error.py | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/error.py b/error.py @@ -37,6 +37,18 @@ class ErrorCollection: l = max(len(render(chunk, key)) for key in keys) for key in keys: lines[key] += ('{:^'+str(l)+'}').format(render(chunk, key)) + if 'weights' in keys: + bounds = [0, 0] + for chunk in self.verse.chunks: + weights = chunk.get("weights", [0, 0]) + bounds[0] += weights[0] + if len(weights) == 2: + bounds[1] += weights[1] + else: + bounds[1] += weights[0] + bounds = [str(x) for x in bounds] + lines['weights'] += " (total: " + ('-'.join(bounds) + if bounds[1] > bounds[0] else bounds[0]) + ")" return ["> " + lines[key] for key in keys if len(lines[key].strip()) > 0] def lines(self, short=False):