cvs2git: Make the --blobfile argument optional.
[cvs2svn.git] / cvs2svn_lib / rcsparser.py
blob325a01451c3817132afbb5393c89151afaff56a2
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2011 CollabNet. All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals. For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 """The interface between cvs2svn and cvs2svn_rcsparse."""
19 # These identifiers are imported to be exported:
20 from cvs2svn_rcsparse.common import Sink
21 from cvs2svn_rcsparse.common import RCSParseError
24 selected_parser = None
26 def select_texttools_parser():
27 """Configure this module to use the texttools parser.
29 The texttools parser is faster but depends on mx.TextTools, which is
30 not part of the Python standard library. If it is not installed,
31 this function will raise an ImportError."""
33 global selected_parser
34 import cvs2svn_rcsparse.texttools
35 selected_parser = cvs2svn_rcsparse.texttools.Parser
38 def select_python_parser():
39 """Configure this module to use the Python parser.
41 The Python parser is slower but works everywhere."""
43 global selected_parser
44 import cvs2svn_rcsparse.default
45 selected_parser = cvs2svn_rcsparse.default.Parser
48 def select_parser():
49 """Configure this module to use the best parser available."""
51 try:
52 select_texttools_parser()
53 except ImportError:
54 select_python_parser()
57 def parse(file, sink):
58 """Parse an RCS file.
60 The arguments are the same as those of
61 cvs2svn_rcsparse.common._Parser.parse() (see that method's docstring
62 for more details).
63 """
65 if selected_parser is None:
66 select_parser()
68 return selected_parser().parse(file, sink)