File: test_hiermatch.py

package info (click to toggle)
reportbug 3.31%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 716 kB
  • ctags: 346
  • sloc: python: 5,506; makefile: 56; sh: 37; lisp: 23
file content (48 lines) | stat: -rw-r--r-- 991 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# $Id: test_hiermatch.py,v 1.1.1.1 2004/02/05 04:29:08 lawrencc Exp $

import hiermatch as hier

def test_list():
    import sys
    a = file(sys.argv[0]).readlines()
    b = hier.grep_list(a, '\[.*\]')
    for i in b:
        print a[i].rstrip()
    print '*'*40
    c = hier.grep_list(a, 'print', b)
    for i in c:
        print a[i].rstrip()


def test_hier():
    import sys
    a = file(sys.argv[0]).readlines()
    b = [(1, a)]
    c = hier.egrep_hierarchy(b, 'print', )
    print c
    for i in range(len(c)):
        for k in c[i]:
            print b[i][1][k].rstrip()
    d = hier.egrep_hierarchy(b, '\[.*\]', c)
    print d
    for i in range(len(d)):
        for k in d[i]:
            print b[i][1][k].rstrip()

def test_mhier():
    import sys
    a = file(sys.argv[0]).readlines()
    b = [(1, a)]
    c = hier.matched_hierarchy(b, 'print', )
    print c
    d = [len(i[1]) for i in c]
    print reduce(lambda x, y: x+y, d)

    

test_mhier()



# vim:ts=8:sw=4:expandtab: