/ db / test / bin /
/db/test/bin/dbgress
1 #!/usr/bin/env python3
2 # Copyright (C) 2012 The Meme Factory, Inc. http://www.meme.com/
3 #
4 # This file is part of Gombe-MI.
5 #
6 # Gombe-MI is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Filter sql output using pcre expressions.
20 #
21 # Karl O. Pinc <kop@meme.com>
22 #
23 # Bugs:
24 #
25
26 def main():
27 '''Filter sql test case output using pcre expressions.
28
29 The program expects to find a file in the ./patterns directory
30 named with the test's name. This file contains text and pcre
31 patterns, the pcre patterns being distinguished from the text
32 by being enclosed in delimiters, $$ being the default delimiter.
33
34 The pattern file is used as a template to filter stdin. Text
35 outside of the delimiters must match stdin exactly. Stdin
36 matching the pcre patterns is filtered, not sent to stdout but
37 replaced with the replacement text, which is the empty string by default.
38 Should either the text in the pattern file or any pcre expression
39 fail to match all of stdin is copied to stdout.
40
41 On error nothing is sent to stdout.'''
42
43 import argparse
44
45 parser = argparse.ArgumentParser(
46 description='Filter sql test case output using pcre expressions')
47
48 def usage():
49 '''Display usage summary.'''
50
51 print('''\
52 Usage: dbgress_filter [-d delim] test
53 dbgress_filter -h | --help
54 dbgress_filter -v | --version
55
56 -h --help Print this message
57 -v --version Print version
58 -d delim Use 'delim' (default $$) as the regexp delimiter
59 -r rtxt Replace matching regexps with 'rtxt' (default '')
60 test Name of test to be filtered''')
61
62 def version():
63 '''Display program version.'''
64 print('''\
65 dbgress_filter 0.1
66 Copyright (C) 2012 The Meme Factory, Inc. http://www.meme.com/
67 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
68 This is free software: you are free to change and redistribute it.
69 There is NO WARRANTY, to the extent permitted by law.
70
71 Written by Karl O. Pinc <kop@meme.com>.''')
72
73
74 usage()
75 version()