• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2
3import re
4import sys
5
6def matchFile(f, f_re):
7  for line_re in f_re:
8    line_re = line_re.rstrip()
9    if not line_re:
10      continue
11    if line_re[0] == '#':
12      continue
13    match = False
14    for line in f:
15      line = line.rstrip()
16      print line
17      if re.search(line_re, line):
18        match = True
19#         print 'match: %s =~ %s' % (line, line_re)
20        break
21    if not match:
22      print 'no match for: %s' % (line_re)
23      return False
24  return True
25
26if len(sys.argv) != 2:
27  print >>sys.stderr, 'Usage: %s <template file>'
28  sys.exit(1)
29
30f = sys.stdin
31f_re = open(sys.argv[1])
32
33if not matchFile(f, f_re):
34  print >>sys.stderr, 'File does not match the template'
35  sys.exit(1)
36