Index: Demo/comparisons/regextest.py =================================================================== --- Demo/comparisons/regextest.py (revisão 86649) +++ Demo/comparisons/regextest.py (cópia de trabalho) @@ -16,6 +16,15 @@ # - is only about 2.5 times as slow as egrep (though I couldn't run # Tom's test -- this system, a vanilla SGI, only has /etc/terminfo) +# Usage: +# +# $ cat pattern | python3 regextest.py FILENAME +# +# You can use bash substitution wildcards: +# +# $ cat pattern | python3 regextest.py * +# + import string import sys import re @@ -25,6 +34,9 @@ bigpat = '(' + '|'.join(pats) + ')' prog = re.compile(bigpat) + if len(sys.argv) < 2: + usage() + for file in sys.argv[1:]: try: fp = open(file, 'r') @@ -40,6 +52,16 @@ if prog.search(line): print("%s:%s:%s" % (file, lineno, line), end=' ') +def usage(): + print('''Usage: + + $ cat pattern | python3 regextest.py FILENAME + +You can use bash substitution wildcards: + + $ cat pattern | python3 regextest.py * +''') + def chomp(s): return s.rstrip('\n')