#!/usr/bin/env python
#
# Imports
import sys
import getopt
import sgreplib
#
# Globals and constants
#
# Classes
class Collector:
def __init__(self):
pass
def write(self, msg):
print '(Collector.write)', msg,
#
# Functions
def test():
test1()
test1()
test1()
# sgrep -o "%f %i %j %l (%r)\n" '"" .. ""'
def test1():
query = '"" __ ""'
options = (
'-o',
'%f %i %j %l "%r"\\n',
#'-F',
#'files1.dat',
query,
'data/people.xml',
'data/outline.xml',
'data/people_1.xml',
)
sgreplib.set_callback_object(Collector())
sgreplib.execute_query_with_args(options)
print '*' * 30
USAGE_TEXT = """
Usage:
python ???.py [options]
Options:
-h, --help Display this help message.
Example:
python ???.py ???
"""
def usage():
print USAGE_TEXT
sys.exit(-1)
def main():
args = sys.argv[1:]
try:
opts, args = getopt.getopt(args, 'h', ['help', ])
except:
usage()
name = 'nobody'
for opt, val in opts:
if opt in ('-h', '--help'):
usage()
if len(args) != 0:
usage()
test()
if __name__ == '__main__':
#import pdb; pdb.set_trace()
main()