3 # (Be in -*- python -*- mode.)
5 # ====================================================================
6 # Copyright (c) 2006-2007 CollabNet. All rights reserved.
8 # This software is licensed as described in the file COPYING, which
9 # you should have received as part of this distribution. The terms
10 # are also available at http://subversion.tigris.org/license-1.html.
11 # If newer versions of this license are posted there, you may use a
12 # newer version instead, at your option.
14 # This software consists of voluntary contributions made by many
15 # individuals. For exact contribution history, see the revision
16 # history and logs, available at http://cvs2svn.tigris.org/.
17 # ====================================================================
19 """Parse an RCS file, showing the rcsparse callbacks that are called.
21 This program is useful to see whether an RCS file has a problem (in
22 the sense of not being parseable by rcsparse) and also to illuminate
23 the correspondence between RCS file contents and rcsparse callbacks.
25 The output of this program can also be considered to be a kind of
26 'canonical' format for RCS files, at least in so far as rcsparse
27 returns all relevant information in the file and provided that the
28 order of callbacks is always the same."""
36 def __init__(self
, f
, name
):
40 def __call__(self
, *args
):
42 '%s(%s)\n' % (self
.name
, ', '.join(['%r' % arg
for arg
in args
]),)
47 def __init__(self
, f
):
50 def __getattr__(self
, name
):
51 return Logger(self
.f
, name
)
54 if __name__
== '__main__':
55 # Since there is nontrivial logic in __init__.py, we have to import
56 # parse() via that file. First make sure that the directory
57 # containing this script is in the path:
58 sys
.path
.insert(0, os
.path
.dirname(sys
.argv
[0]))
60 from __init__
import parse
63 for path
in sys
.argv
[1:]:
64 if os
.path
.isfile(path
) and path
.endswith(',v'):
66 open(path
, 'rb'), LoggingSink(sys
.stdout
)
69 sys
.stderr
.write('%r is being ignored.\n' % path
)
71 parse(sys
.stdin
, LoggingSink(sys
.stdout
))