Mercurial > hg > orthanc
comparison Resources/GenerateErrorCodes.py @ 1585:9a3e03d6a4d5
fix sqlite standalone build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 19:33:18 +0200 |
parents | bd1889029cbb |
children | 8dc468f44661 |
comparison
equal
deleted
inserted
replaced
1584:39ecd34fb1c7 | 1585:9a3e03d6a4d5 |
---|---|
109 a = re.sub('(ConvertErrorCodeToHttpStatus\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', | 109 a = re.sub('(ConvertErrorCodeToHttpStatus\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', |
110 r'\1\n%s\2' % s, a, re.DOTALL) | 110 r'\1\n%s\2' % s, a, re.DOTALL) |
111 | 111 |
112 with open(path, 'w') as f: | 112 with open(path, 'w') as f: |
113 f.write(a) | 113 f.write(a) |
114 | |
115 | |
116 | |
117 ## | |
118 ## Generate the "ErrorCode" enumeration in "OrthancSQLiteException.h" | |
119 ## | |
120 | |
121 path = os.path.join(BASE, 'Core', 'SQLite', 'OrthancSQLiteException.h') | |
122 with open(path, 'r') as f: | |
123 a = f.read() | |
124 | |
125 e = filter(lambda x: 'SQLite' in x and x['SQLite'], ERRORS) | |
126 s = ',\n'.join(map(lambda x: ' ErrorCode_%s' % x['Name'], e)) | |
127 a = re.sub('(enum ErrorCode\s*{)[^}]*?(\s*};)', r'\1\n%s\2' % s, a, re.DOTALL) | |
128 | |
129 s = '\n\n'.join(map(lambda x: ' case ErrorCode_%s:\n return "%s";' % (x['Name'], x['Description']), e)) | |
130 a = re.sub('(EnumerationToString\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', | |
131 r'\1\n%s\2' % s, a, re.DOTALL) | |
132 | |
133 with open(path, 'w') as f: | |
134 f.write(a) |