23
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,
26
# Locates svn_error_codes.h based on its relative location to this script.
28
# Generates to STDOUT. Typically, redirect this into svntest/err.py
35
HEADER = '''#!/usr/bin/env python
36
### This file automatically generated by tools/dev/gen-py-errors.py,
38
37
### which see for more information
40
39
### 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)
42
# Established by svn 1.0. May as well hard-code these.
43
APR_OS_START_ERROR = 20000
44
APR_OS_START_USERERR = APR_OS_START_ERROR + 50000 * 2
45
SVN_ERR_CATEGORY_SIZE = 5000
47
RE_CAT_NAME = re.compile(r'SVN_ERR_([A-Z_]+)_CATEG')
48
RE_CAT_VALUE = re.compile(r'\d+')
50
RE_DEF_NAME = re.compile(r'SVN_ERRDEF\(([A-Z0-9_]+)')
51
RE_DEF_VALUE = re.compile(r'SVN_ERR_([A-Z_]+)_CATEG[^0-9]*([0-9]+)')
54
def write_output(codes):
57
for name, value in codes:
58
# skip SVN_ERR_ on the name
59
print '%s = %d' % (name[8:], value)
62
def main(codes_fname):
68
# Parse all the category start values
71
m = RE_CAT_NAME.search(line)
74
m = RE_CAT_VALUE.search(f.next())
76
value = int(m.group(0))
77
categ[name] = APR_OS_START_USERERR + value * SVN_ERR_CATEGORY_SIZE
79
elif line.strip() == 'SVN_ERROR_START':
82
# Parse each of the error values
85
m = RE_DEF_NAME.search(line)
89
m = RE_DEF_VALUE.search(line)
91
# SVN_ERR_WC_NOT_DIRECTORY is defined as equal to NOT_WORKING_COPY
92
# rather than relative to SVN_ERR_WC_CATEGORY_START
96
value = int(m.group(2))
97
codes.append((name, categ[cat] + value))
99
elif line.strip() == 'SVN_ERROR_END':
102
write_output(sorted(codes))
65
105
if __name__ == '__main__':
66
main(os.path.join('subversion', 'tests', 'cmdline', 'svntest', 'err.py'))
106
this_dir = os.path.dirname(os.path.abspath(__file__))
107
codes_fname = os.path.join(this_dir, os.path.pardir, os.path.pardir,
108
'subversion', 'include', 'svn_error_codes.h')