comparison Resources/GenerateErrorCodes.py @ 1626:8dc468f44661

mapping of error codes from plugins to Orthanc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 18 Sep 2015 14:28:47 +0200
parents 9a3e03d6a4d5
children 939b921b2c81
comparison
equal deleted inserted replaced
1625:c17b1142caab 1626:8dc468f44661
130 a = re.sub('(EnumerationToString\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', 130 a = re.sub('(EnumerationToString\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)',
131 r'\1\n%s\2' % s, a, re.DOTALL) 131 r'\1\n%s\2' % s, a, re.DOTALL)
132 132
133 with open(path, 'w') as f: 133 with open(path, 'w') as f:
134 f.write(a) 134 f.write(a)
135
136
137
138 ##
139 ## Generate the "Plugins::Convert(OrthancPluginErrorCode)" in
140 ## "PluginsEnumerations.cpp"
141 ##
142
143 path = os.path.join(BASE, 'Plugins', 'Engine', 'PluginsEnumerations.cpp')
144 with open(path, 'r') as f:
145 a = f.read()
146
147 s = '\n\n'.join(map(lambda x: ' case OrthancPluginErrorCode_%s:\n return ErrorCode_%s;' % (x['Name'], x['Name']), ERRORS))
148 a = re.sub('(Convert\(OrthancPluginErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)',
149 r'\1\n%s\2' % s, a, re.DOTALL)
150
151 with open(path, 'w') as f:
152 f.write(a)