File: testparse.py

package info (click to toggle)
viewcvs 0.9.2%2Bcvs.1.0.dev.2004.07.28-4.1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 1,452 kB
  • ctags: 1,355
  • sloc: python: 10,099; cpp: 840; ansic: 763; yacc: 526; sh: 163; makefile: 115
file content (51 lines) | stat: -rw-r--r-- 1,131 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
49
50
51

MODULE = '/home/gstein/testing/cvsroot/mod_dav'
OUTPUT = 'rlog-dump'

import sys
sys.path.insert(0, '../lib')

import os
import rlog


def get_files(root):
  all_files = [ ]
  os.path.walk(root, _collect_files, all_files)
  all_files.sort()
  return all_files

def _collect_files(all_files, dir, files):
  for f in files:
    if f[-2:] == ',v':
      all_files.append(os.path.join(dir, f))

def get_config():
  class _blank:
    pass
  cfg = _blank()
  cfg.general = _blank()
  cfg.general.rcs_path = ''
  return cfg


def gen_dump(cfg, out_fname, files, func):
  out = open(out_fname, 'w')
  for f in files:
    data = func(cfg, f)
    out.write(data.filename + '\n')
    tags = data.symbolic_name_hash.keys()
    tags.sort()
    for t in tags:
      out.write('%s:%s\n' % (t, data.symbolic_name_hash[t]))
    for e in data.rlog_entry_list:
      names = dir(e)
      names.sort()
      for n in names:
        out.write('%s=%s\n' % (n, getattr(e, n)))

def _test():
  cfg = get_config()
  files = get_files(MODULE)
  gen_dump(cfg, OUTPUT + '.old', files, rlog.GetRLogData)
  gen_dump(cfg, OUTPUT + '.new', files, rlog.get_data)