verify-cvs2svn.py: Make split_output() a file-level function.
[cvs2svn.git] / contrib / find_illegal_filenames.py
blob753de73ad2e259ae798f25ef353bc6f67fb44de8
1 #! /usr/bin/python
3 # (Be in -*- python -*- mode.)
5 # ====================================================================
6 # Copyright (c) 2006 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 """Search a directory for files whose names contain illegal characters.
21 Usage: find_illegal_filenames.py PATH ...
23 PATH should be a directory. It will be traversed looking for
24 filenames that contain characters that are not allowed in paths in an
25 SVN archive."""
27 import sys
28 import os
30 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
32 from cvs2svn_lib.common import FatalError
33 from cvs2svn_lib.output_option import OutputOption
36 def visit_directory(unused, dirname, files):
37 for file in files:
38 path = os.path.join(dirname, file)
39 try:
40 OutputOption().verify_filename_legal(file)
41 except FatalError:
42 sys.stderr.write('File %r contains illegal characters!\n' % path)
45 if not sys.argv[1:]:
46 sys.stderr.write('usage: %s PATH ...\n' % sys.argv[0])
47 sys.exit(1)
49 for path in sys.argv[1:]:
50 os.path.walk(path, visit_directory, None)