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.)
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
15
# http://www.apache.org/licenses/LICENSE-2.0
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
23
# ====================================================================
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.
30
sys.path.append(os.path.join('subversion', 'bindings', 'swig',
36
header = '''#!/usr/bin/env python
37
### This file automatically generated by tools/dev/gen-py-error.py,
38
### which see for more information
40
### It is versioned for convenience.
45
def write_output(errs, filename):
46
out = open(filename, 'w')
49
for name, val in errs:
50
out.write('%s = %d\n' % (name, val))
55
def main(output_filename):
58
errs = [e for e in dir(core.svn.core) if e.startswith('SVN_ERR_')]
61
codes.append((e[8:], getattr(core.svn.core, e)))
62
write_output(codes, output_filename)
65
if __name__ == '__main__':
66
main(os.path.join('subversion', 'tests', 'cmdline', 'svntest', 'err.py'))