plint

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

commit 7fda525b10a7b3651252dce11eba21bfb05090c0
parent b69b82558b660308399d1063f9dc6207b211942f
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue, 10 Jul 2012 22:10:49 +0200

add support for offset

Diffstat:
plint_irc.py | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/plint_irc.py b/plint_irc.py @@ -78,10 +78,12 @@ def manage(line, silent=False): lbuf = [] return len(errors) == 0 -if len(sys.argv) != 3: - print("Usage: %s TEMPLATE POEM" % sys.argv[0], file=sys.stderr) +if len(sys.argv) not in [3, 4]: + print("Usage: %s TEMPLATE POEM [OFFSET]" % sys.argv[0], file=sys.stderr) print("Check POEM according to TEMPLATE, add valid verse from stdin to POEM", file=sys.stderr) + print("Ignore OFFSET lines from POEM", + file=sys.stderr) sys.exit(1) f = open(sys.argv[1]) @@ -91,8 +93,17 @@ template = Template(x) template.reject_errors = True +offset = 0 +if len(sys.argv) == 4: + offset = int(sys.argv[3]) + +pos = 0 + f = open(sys.argv[2], 'r') for line in f.readlines(): + pos += 1 + if pos <= offset: + continue # ignore first lines print("Read: %s" % line, file=sys.stderr) if not manage(line, True): print("Existing poem is wrong!", file=sys.stderr)