From 5f18ecf6fcf803e79654c7b15625b9e1a98a0565 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 23 Sep 2014 10:58:33 +0200 Subject: [PATCH] better explanations --- README.md | 8 +++++++- paternoster.py | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 387e8f5..4f7b817 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A command line tool that call the given command for each input line matching the `paternoster` [-h] -`paternoster` [-w] [-e] PATTERN COMMAND(S) +`paternoster` [-w] [-e] [-g] PATTERN COMMAND(S) ## DESCRIPTION @@ -32,15 +32,21 @@ duplicated across remaining groups. * `-w`, `--nowait`: Don't wait for the end of the current command before calling the next one. + This will call commands as soon as they are met in the stream, + If the stream is read fast, commands will most probably be ran quasi-simultaneously. * `-e`, `--end`: Run commands at the end of the input stream. + Note that if the stream don't end (for example if you input from `tail -f`), + nothing will be done until an interruption. * `-g`, `--group`: Capture groups as arguments for the CMD, instead of running CMD for each group. CMD must have as many formating placeholder as captured groups. For example, if you capture 3 groups, you must put 3 formating placeholders in CMD: `paternoster --group "^(.*):(.*):(.*)$" "echo '>>> 1:%s 2:%s 3:%s <<<'"` + If placeholders count does not match the groups count, no substitution is made + and the placeholders are left as is. ## EXAMPLES diff --git a/paternoster.py b/paternoster.py index d60197d..952fccb 100755 --- a/paternoster.py +++ b/paternoster.py @@ -93,11 +93,6 @@ def read_parse( stream_in, stream_out, pattern, cmd, nowait = False, at_end = Fa Read the given file-like object as a non-blocking stream and call the function on each item (line), with the given extra arguments. - - A call to "map_write(sys.stdin, function, *args)" will translate to the - non-blocking equivalent of: - for item in sys.stdin.readlines(): - write( function( *args ) ) """ if at_end: @@ -138,7 +133,6 @@ if __name__ == "__main__": help="A regular expression") parser.add_argument("commands", metavar="CMD", type=str, nargs="+", - default="espeak %s", help="The command to run if REGEX match. \ If CMD contains a string formating placefolder (like \"%%s\"), \ it will be replaced by the matching text. \