#!/usr/bin/env python3 # Copyright (C) 2012 The Meme Factory, Inc. http://www.meme.com/ # # This file is part of Gombe-MI. # # Gombe-MI is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Gombe-MI. If not, see . # # Filter sql output using pcre expressions. # # Karl O. Pinc # # Bugs: # def main(): '''Filter sql test case output using pcre expressions. The program expects to find a file in the ./patterns directory named with the test's name. This file contains text and pcre patterns, the pcre patterns being distinguished from the text by being enclosed in delimiters, $$ being the default delimiter. The pattern file is used as a template to filter stdin. Text outside of the delimiters must match stdin exactly. Stdin matching the pcre patterns is filtered, not sent to stdout but replaced with the replacement text, which is the empty string by default. Should either the text in the pattern file or any pcre expression fail to match all of stdin is copied to stdout. On error nothing is sent to stdout.''' import argparse parser = argparse.ArgumentParser( description='Filter sql test case output using pcre expressions') def usage(): '''Display usage summary.''' print('''\ Usage: dbgress_filter [-d delim] test dbgress_filter -h | --help dbgress_filter -v | --version -h --help Print this message -v --version Print version -d delim Use 'delim' (default $$) as the regexp delimiter -r rtxt Replace matching regexps with 'rtxt' (default '') test Name of test to be filtered''') def version(): '''Display program version.''' print('''\ dbgress_filter 0.1 Copyright (C) 2012 The Meme Factory, Inc. http://www.meme.com/ License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Karl O. Pinc .''') usage() version()