~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to tools/dev/gen-py-errors.py

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# gen-py-errors.py: Generate a python module which maps error names to numbers.
 
4
#                   (The purpose being easier writing of the python tests.)
 
5
#
 
6
# ====================================================================
 
7
#    Licensed to the Apache Software Foundation (ASF) under one
 
8
#    or more contributor license agreements.  See the NOTICE file
 
9
#    distributed with this work for additional information
 
10
#    regarding copyright ownership.  The ASF licenses this file
 
11
#    to you under the Apache License, Version 2.0 (the
 
12
#    "License"); you may not use this file except in compliance
 
13
#    with the License.  You may obtain a copy of the License at
 
14
#
 
15
#      http://www.apache.org/licenses/LICENSE-2.0
 
16
#
 
17
#    Unless required by applicable law or agreed to in writing,
 
18
#    software distributed under the License is distributed on an
 
19
#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
20
#    KIND, either express or implied.  See the License for the
 
21
#    specific language governing permissions and limitations
 
22
#    under the License.
 
23
# ====================================================================
 
24
#
 
25
#
 
26
#  Meant to be run from the root of a Subversion working copy.  If anybody
 
27
#  wants to do some path magic to improve that use, feel free.
 
28
 
 
29
import sys, os
 
30
sys.path.append(os.path.join('subversion', 'bindings', 'swig',
 
31
                             'python', 'tests'))
 
32
 
 
33
 
 
34
import setup_path
 
35
 
 
36
header = '''#!/usr/bin/env python
 
37
### This file automatically generated by tools/dev/gen-py-error.py,
 
38
### which see for more information
 
39
###
 
40
### It is versioned for convenience.
 
41
 
 
42
'''
 
43
 
 
44
 
 
45
def write_output(errs, filename):
 
46
  out = open(filename, 'w')
 
47
  out.write(header)
 
48
 
 
49
  for name, val in errs:
 
50
    out.write('%s = %d\n' % (name, val))
 
51
 
 
52
  out.close()
 
53
 
 
54
 
 
55
def main(output_filename):
 
56
  import core
 
57
 
 
58
  errs = [e for e in dir(core.svn.core) if e.startswith('SVN_ERR_')]
 
59
  codes = []
 
60
  for e in errs:
 
61
    codes.append((e[8:], getattr(core.svn.core, e)))
 
62
  write_output(codes, output_filename)
 
63
 
 
64
 
 
65
if __name__ == '__main__':
 
66
  main(os.path.join('subversion', 'tests', 'cmdline', 'svntest', 'err.py'))