comparison OrthancFramework/Resources/CodeGeneration/GenerateErrorCodes.py @ 5384:31bfa492311e

GenerateErrorCodes.py now works with python3
author Alain Mazy <am@osimis.io>
date Wed, 06 Sep 2023 16:09:16 +0200
parents 0ea402b4d901
children 48b8dae6dc77
comparison
equal deleted inserted replaced
5383:33410f14033b 5384:31bfa492311e
120 120
121 path = os.path.join(BASE, 'OrthancFramework', 'Sources', 'SQLite', 'OrthancSQLiteException.h') 121 path = os.path.join(BASE, 'OrthancFramework', 'Sources', 'SQLite', 'OrthancSQLiteException.h')
122 with open(path, 'r') as f: 122 with open(path, 'r') as f:
123 a = f.read() 123 a = f.read()
124 124
125 e = filter(lambda x: 'SQLite' in x and x['SQLite'], ERRORS) 125 e = list(filter(lambda x: 'SQLite' in x and x['SQLite'], ERRORS))
126 s = ',\n'.join(map(lambda x: ' ErrorCode_%s' % x['Name'], e)) 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) 127 a = re.sub('(enum ErrorCode\s*{)[^}]*?(\s*};)', r'\1\n%s\2' % s, a, re.DOTALL)
128 128
129 s = '\n\n'.join(map(lambda x: ' case ErrorCode_%s:\n return "%s";' % (x['Name'], x['Description']), e)) 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:)', 130 a = re.sub('(EnumerationToString\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)',