Mercurial > hg > orthanc-python
annotate CodeAnalysis/GenerateOrthancSDK.py @ 215:b124c74e6968
simplification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 03 Jul 2024 15:33:21 +0200 |
parents | 4e6079e27965 |
children | 3678a028f1f6 |
rev | line source |
---|---|
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 ## Python plugin for Orthanc |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 ## Copyright (C) 2020-2023 Osimis S.A., Belgium |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 ## Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 ## Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 ## This program is free software: you can redistribute it and/or |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 ## modify it under the terms of the GNU Affero General Public License |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 ## as published by the Free Software Foundation, either version 3 of |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 ## the License, or (at your option) any later version. |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 ## This program is distributed in the hope that it will be useful, but |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 ## Affero General Public License for more details. |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 ## You should have received a copy of the GNU Affero General Public License |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 import argparse |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import json |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import os |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import sys |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 import pystache |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 ROOT = os.path.dirname(os.path.realpath(sys.argv[0])) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 ## Parse the command-line arguments |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 parser = argparse.ArgumentParser(description = 'Generate Python code to wrap the Orthanc SDK.') |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 parser.add_argument('--model', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 default = os.path.join(os.path.dirname(__file__), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 '../Resources/Orthanc/Sdk-1.10.0/CodeModel.json'), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 help = 'Input code model, as generated by the orthanc-java project') |
194
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
42 parser.add_argument('--classes', |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
43 default = os.path.join(os.path.dirname(__file__), |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
44 '../Resources/Orthanc/Sdk-1.10.0/ClassDocumentation.json'), |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
45 help = 'Input description of classes, as defined in the orthanc-java project') |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 parser.add_argument('--target', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 default = os.path.join(os.path.dirname(__file__), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 '../Sources/Autogenerated'), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 help = 'Target folder') |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 args = parser.parse_args() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 ## Configuration of the custom primitives that are manually |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 ## implemented (not autogenerated) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 ## |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
183
d31f216c9462
extracted custom functions/methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
182
diff
changeset
|
60 TARGET = os.path.realpath(args.target) |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
183
d31f216c9462
extracted custom functions/methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
182
diff
changeset
|
63 with open(os.path.join(ROOT, 'CustomMethods.json'), 'r') as f: |
d31f216c9462
extracted custom functions/methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
182
diff
changeset
|
64 CUSTOM_METHODS = json.loads(f.read()) |
182
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
65 |
183
d31f216c9462
extracted custom functions/methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
182
diff
changeset
|
66 with open(os.path.join(ROOT, 'CustomFunctions.json'), 'r') as f: |
d31f216c9462
extracted custom functions/methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
182
diff
changeset
|
67 CUSTOM_FUNCTIONS = json.loads(f.read()) |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 partials = {} |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 with open(os.path.join(ROOT, 'FunctionBody.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 partials['function_body'] = f.read() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
75 with open(os.path.join(ROOT, 'FunctionDocumentation.mustache'), 'r') as f: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
76 partials['function_documentation'] = f.read() |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
77 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 renderer = pystache.Renderer( |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 escape = lambda u: u, # No escaping |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 partials = partials, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 ) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 with open(args.model, 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 model = json.loads(f.read()) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
194
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
88 with open(args.classes, 'r') as f: |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
89 classes_description = json.loads(f.read()) |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
90 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 def ToUpperCase(name): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 s = '' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 for i in range(len(name)): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 if name[i].isupper(): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 if len(s) == 0: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 s += name[i] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 elif name[i - 1].islower(): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 s += '_' + name[i] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 elif (i + 1 < len(name) and |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 name[i - 1].islower() and |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 name[i + 1].isupper()): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 s += '_' + name[i] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 s += name[i] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 s += name[i].upper() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 return s |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
111 def ToLowerCase(name): |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
112 s = '' |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
113 for i in range(len(name)): |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
114 if (name[i].isupper() and |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
115 len(s) != 0): |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
116 s += '_' |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
117 s += name[i].lower() |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
118 return s |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
119 |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
120 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 def GetShortName(name): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 if not name.startswith('OrthancPlugin'): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 raise Exception() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 return name[len('OrthancPlugin'):] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 ORTHANC_TO_PYTHON_NUMERIC_TYPES = { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 # https://docs.python.org/3/c-api/arg.html#numbers |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 # https://en.wikipedia.org/wiki/C_data_types |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 'uint8_t' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 'type' : 'unsigned char', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 'format' : 'b', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 }, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 'int32_t' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 'type' : 'long int', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 'format' : 'l', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 }, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 'uint16_t' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 'type' : 'unsigned short', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 'format' : 'H', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 }, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 'uint32_t' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 'type' : 'unsigned long', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 'format' : 'k', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 }, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 'uint64_t' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 'type' : 'unsigned long long', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 'format' : 'K', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 }, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 'float' : { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 'type' : 'float', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 'format' : 'f', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 } |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
159 def DocumentFunction(f): |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
160 documentation = {} |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
161 description = f['documentation'].get('description', []) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
162 if len(description) > 0: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
163 documentation['short_description'] = description[0].split('.') [0] |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
164 documentation['description'] = map(lambda x: { 'text' : x }, description) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
165 |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
166 args_declaration = [] |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
167 args_documentation = [] |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
168 for a in f['args']: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
169 arg_name = ToLowerCase(a['sdk_name']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
170 if a['sdk_type'] == 'const char *': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
171 arg_type = 'str' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
172 elif a['sdk_type'] == 'float': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
173 arg_type = 'float' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
174 elif a['sdk_type'] in [ 'const_void_pointer_with_size', 'const void *' ]: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
175 arg_type = 'bytes' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
176 elif a['sdk_type'] == 'enumeration': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
177 arg_type = GetShortName(a['sdk_enumeration']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
178 elif a['sdk_type'] == 'const_object': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
179 arg_type = GetShortName(a['sdk_class']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
180 elif a['sdk_type'] in [ 'int32_t', 'uint32_t', 'uint8_t', 'uint16_t', 'uint64_t' ]: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
181 arg_type = 'int' |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
182 elif a['sdk_type'] == 'Callable': |
205
234681297600
documented orthanc.LookupDictionary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
183 # This is only used to generate the documentation file "orthanc.pyi" |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
184 arg_type = a['callable_type'] |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
185 else: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
186 raise Exception('Argument type not implemented: %s' % a['sdk_type']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
187 args_declaration.append('%s: %s' % (arg_name, arg_type)) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
188 args_documentation.append({ |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
189 'name' : arg_name, |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
190 'type' : arg_type, |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
191 'text' : f['documentation']['args'] [a['sdk_name']], |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
192 }) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
193 |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
194 documentation['args_declaration'] = ', '.join(args_declaration) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
195 documentation['args'] = args_documentation |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
196 documentation['has_args'] = len(args_documentation) > 0 |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
197 documentation['has_return'] = True |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
198 |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
199 if f['return_sdk_type'] == 'enumeration': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
200 if f['return_sdk_enumeration'] == 'OrthancPluginErrorCode': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
201 documentation['has_return'] = False |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
202 documentation['return_type'] = 'None' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
203 else: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
204 documentation['return_type'] = GetShortName(f['return_sdk_enumeration']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
205 elif f['return_sdk_type'] == 'object': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
206 documentation['return_type'] = GetShortName(f['return_sdk_class']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
207 elif f['return_sdk_type'] == 'void': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
208 documentation['has_return'] = False |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
209 documentation['return_type'] = 'None' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
210 elif f['return_sdk_type'] == 'OrthancPluginMemoryBuffer *': |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
211 documentation['return_type'] = 'bytes' |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
212 elif f['return_sdk_type'] in [ 'char *', 'const char *' ]: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
213 documentation['return_type'] = 'str' |
182
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
214 elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'uint16_t', 'int64_t' ]: |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
215 documentation['return_type'] = 'int' |
205
234681297600
documented orthanc.LookupDictionary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
216 elif f['return_sdk_type'] == 'Dictionary': |
234681297600
documented orthanc.LookupDictionary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
217 # This is only used to generate the documentation file "orthanc.pyi" |
234681297600
documented orthanc.LookupDictionary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
218 documentation['return_type'] = 'dict' |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
219 else: |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
220 raise Exception('Return type not implemented: %s' % f['return_sdk_type']) |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
221 |
182
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
222 if documentation['has_return']: |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
223 documentation['return_text'] = f['documentation']['return'] |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
224 |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
225 return documentation |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
226 |
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
227 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 def FormatFunction(f): |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 answer = { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 'c_function' : f['c_function'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 'short_name' : GetShortName(f['c_function']), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 'has_args' : len(f['args']) > 0, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 'count_args' : len(f['args']), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 tuple_format = '' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 tuple_target = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 call_args = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 args = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 for arg in f['args']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 # https://docs.python.org/3/c-api/arg.html |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 if arg['sdk_type'] in [ 'const void *', 'const_void_pointer_with_size' ]: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 args.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 'name' : arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 'python_type' : 'Py_buffer', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 'release' : 'PyBuffer_Release(&%s);' % arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 tuple_format += 's*' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 elif arg['sdk_type'] == 'const char *': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 args.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 'name' : arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 'python_type' : 'const char*', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 'initialization' : ' = NULL', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 tuple_format += 's' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 elif arg['sdk_type'] == 'enumeration': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 args.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 'name' : arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 'python_type' : 'long int', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 'initialization' : ' = 0', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 tuple_format += 'l' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 elif arg['sdk_type'] == 'const_object': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 args.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 'name' : arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 'python_type' : 'PyObject*', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 'initialization' : ' = NULL', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 'check_object_type' : arg['sdk_class'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 tuple_format += 'O' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 elif arg['sdk_type'] in ORTHANC_TO_PYTHON_NUMERIC_TYPES: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 t = ORTHANC_TO_PYTHON_NUMERIC_TYPES[arg['sdk_type']] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 args.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 'name' : arg['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 'python_type' : t['type'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 'initialization' : ' = 0', |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 tuple_format += t['format'] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 print('Ignoring function with unsupported argument type: %s(), type = %s' % (f['c_function'], arg['sdk_type'])) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 return None |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 tuple_target.append('&' + arg['name']) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 if arg['sdk_type'] == 'const void *': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 call_args.append(arg['name'] + '.buf') |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 elif arg['sdk_type'] == 'const_void_pointer_with_size': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 call_args.append(arg['name'] + '.buf') |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 call_args.append(arg['name'] + '.len') |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 elif arg['sdk_type'] == 'enumeration': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 call_args.append('static_cast<%s>(%s)' % (arg['sdk_enumeration'], arg['name'])) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 elif arg['sdk_type'] == 'const_object': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 call_args.append('%s == Py_None ? NULL : reinterpret_cast<sdk_%s_Object*>(%s)->object_' % ( |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 arg['name'], arg['sdk_class'], arg['name'])) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 call_args.append(arg['name']) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 answer['args'] = args |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 if f['return_sdk_type'] == 'void': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 answer['return_void'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'int64_t' ]: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 answer['return_long'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 elif f['return_sdk_type'] == 'OrthancPluginMemoryBuffer *': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 answer['return_bytes'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 elif f['return_sdk_type'] == 'enumeration': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 if f['return_sdk_enumeration'] == 'OrthancPluginErrorCode': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 answer['return_error'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 answer['return_enumeration'] = f['return_sdk_enumeration'] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 elif f['return_sdk_type'] == 'char *': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 answer['return_dynamic_string'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 elif f['return_sdk_type'] == 'const char *': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 answer['return_static_string'] = True |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 elif f['return_sdk_type'] == 'object': |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 answer['return_object'] = f['return_sdk_class'] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 else: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 print('Ignoring function with unsupported return type: %s(), type = %s' % (f['c_function'], f['return_sdk_type'])) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 return None |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 answer['tuple_format'] = ', '.join([ '"' + tuple_format + '"' ] + tuple_target) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
324 if 'documentation' in f: |
181
faaa3fec799a
refactoring using FunctionDocumentation.mustache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
325 answer['documentation'] = DocumentFunction(f) |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
326 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 if len(call_args) > 0: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 answer['call_args'] = ', ' + ', '.join(call_args) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 return answer |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 globalFunctions = [] |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
335 customFunctions = [] |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 for f in model['global_functions']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 g = FormatFunction(f) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 if g != None: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 globalFunctions.append(g) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 for f in CUSTOM_FUNCTIONS: |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
343 f['documentation'] = DocumentFunction(f) |
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
344 customFunctions.append(f) |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 enumerations = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 with open(os.path.join(ROOT, 'Enumeration.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 ENUMERATION_TEMPLATE = f.read() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 for e in model['enumerations']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 values = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 for value in e['values']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 values.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 'key' : ToUpperCase(value['key']), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 'value' : value['value'], |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
358 'documentation' : value['documentation'], |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 enumerations.append({ |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 'name' : e['name'], |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
363 'short_name' : GetShortName(e['name']), |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 'path' : 'sdk_%s.impl.h' % e['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 'values' : values, |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
366 'documentation' : e['documentation'], |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 path = 'sdk_%s.impl.h' % e['name'] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 with open(os.path.join(TARGET, path), 'w') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 f.write(pystache.render(ENUMERATION_TEMPLATE, { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 'name' : e['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 'short_name' : GetShortName(e['name']), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 'values' : values, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 })) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 classes = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
204
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
381 countDestructors = 0 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
382 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 for c in model['classes']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 methods = [] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 for m in c['methods']: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 g = FormatFunction(m) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 if g != None: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 g['self'] = ', self->object_' |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 methods.append(g) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 |
182
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
392 custom_methods = [] |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
393 |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
394 if c['name'] in CUSTOM_METHODS: |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
395 for custom_method in CUSTOM_METHODS[c['name']]: |
185 | 396 custom_method['self'] = True # Indicates that this is a method |
182
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
397 custom_method['documentation'] = DocumentFunction(custom_method) |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
398 custom_methods.append(custom_method) |
20b004998fc2
documentation of custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
399 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 classes.append({ |
194
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
401 'description' : classes_description[c['name']], |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 'class_name' : c['name'], |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 'short_name' : GetShortName(c['name']), |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 'methods' : methods, |
193
66cd20e970d8
simplification for custom methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
405 'custom_methods' : sorted(custom_methods, key = lambda x: x['short_name']), |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 }) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 if 'destructor' in c: |
204
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
409 countDestructors += 1 |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 classes[-1]['destructor'] = c['destructor'] |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 with open(os.path.join(ROOT, 'Class.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 with open(os.path.join(ROOT, 'ClassMethods.mustache'), 'r') as g: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 classDefinition = f.read() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 classMethods = g.read() |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 for c in classes: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 with open(os.path.join(TARGET, 'sdk_%s.impl.h' % c['class_name']), 'w') as h: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 h.write(renderer.render(classDefinition, c)) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 with open(os.path.join(TARGET, 'sdk_%s.methods.h' % c['class_name']), 'w') as h: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 h.write(renderer.render(classMethods, c)) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 sortedClasses = sorted(classes, key = lambda x: x['class_name']) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 sortedEnumerations = sorted(enumerations, key = lambda x: x['name']) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 sortedGlobalFunctions = sorted(globalFunctions, key = lambda x: x['c_function']) |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
430 sortedCustomFunctions = sorted(customFunctions, key = lambda x: x['short_name']) |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 with open(os.path.join(ROOT, 'GlobalFunctions.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 with open(os.path.join(TARGET, 'sdk_GlobalFunctions.impl.h'), 'w') as h: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 h.write(renderer.render(f.read(), { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 'global_functions' : sortedGlobalFunctions, |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
436 'custom_functions' : sortedCustomFunctions, |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 })) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 with open(os.path.join(ROOT, 'sdk.cpp.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 with open(os.path.join(TARGET, 'sdk.cpp'), 'w') as h: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 h.write(renderer.render(f.read(), { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 'classes' : sortedClasses, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 'enumerations' : sortedEnumerations, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 'global_functions' : sortedGlobalFunctions, |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
445 'custom_functions' : sortedCustomFunctions, |
172
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 })) |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 with open(os.path.join(ROOT, 'sdk.h.mustache'), 'r') as f: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 with open(os.path.join(TARGET, 'sdk.h'), 'w') as h: |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 h.write(renderer.render(f.read(), { |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 'classes' : sortedClasses, |
8382c7dea471
created CodeAnalysis/GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 })) |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
453 |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
454 with open(os.path.join(ROOT, 'PythonDocumentation.mustache'), 'r') as f: |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
455 with open(os.path.join(TARGET, 'orthanc.pyi'), 'w') as h: |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
456 h.write(renderer.render(f.read(), { |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
457 'classes' : sortedClasses, |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
458 'enumerations' : sortedEnumerations, |
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
459 'global_functions' : sortedGlobalFunctions, |
192
b0f096d2339e
documentation of orthanc.RegisterRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
190
diff
changeset
|
460 'custom_functions' : sortedCustomFunctions, |
180
ddf3e987827f
created Python documentation for the Orthanc interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
461 })) |
190 | 462 |
463 | |
204
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
464 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
465 ## |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
466 ## Print statistics |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
467 ## |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
468 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
469 countWrappedMethods = 0 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
470 countCustomMethods = 0 |
190 | 471 for c in sortedClasses: |
204
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
472 countWrappedMethods += len(c['methods']) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
473 countCustomMethods += len(c['custom_methods']) |
190 | 474 |
204
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
475 print('\nNumber of automatically wrapped global functions: %d' % len(sortedGlobalFunctions)) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
476 print('Number of automatically wrapped methods: %d' % countWrappedMethods) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
477 print('Number of automatically wrapped destructors: %d' % countDestructors) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
478 print('Number of manually implemented (custom) global functions: %d' % len(sortedCustomFunctions)) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
479 print('Number of manually implemented (custom) methods: %d' % countCustomMethods) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
480 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
481 totalWrapped = (len(sortedGlobalFunctions) + countWrappedMethods + countDestructors) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
482 print('\nTotal number of automatically wrapped functions (including destructors): %d' % totalWrapped) |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
483 print('NB: This number must correspond to "ParseOrthancSDK.py" in "orthanc-java"') |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
484 |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
485 total = totalWrapped + len(sortedCustomFunctions) + countCustomMethods |
65ad095c25d8
report statistics in GenerateOrthancSDK.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
194
diff
changeset
|
486 print('\n=> Total number of functions or methods in the Python SDK: %d\n' % total) |