annotate Resources/GenerateTransferSyntaxes.py @ 3951:5fe8c6d3212e transcoding

removed useless information "hasSopInstanceUidChanged"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 21:06:53 +0200
parents ae31ba2b09a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # Copyright (C) 2017-2020 Osimis S.A., Belgium
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 #
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # modify it under the terms of the GNU General Public License as
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # published by the Free Software Foundation, either version 3 of the
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # License, or (at your option) any later version.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 #
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # In addition, as a special exception, the copyright holders of this
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # program give permission to link the code of its release with the
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # OpenSSL project's "OpenSSL" library (or with modified versions of it
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # that use the same license as the "OpenSSL" library), and distribute
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # the linked executables. You must obey the GNU General Public License
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # in all respects for all of the code used other than "OpenSSL". If you
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # modify file(s) with this exception, you may extend this exception to
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # your version of the file(s), but you are not obligated to do so. If
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 # you do not wish to do so, delete this exception statement from your
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 # version. If you delete this exception statement from all source files
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 # in the program, then also delete it here.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 # This program is distributed in the hope that it will be useful, but
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 # WITHOUT ANY WARRANTY; without even the implied warranty of
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # General Public License for more details.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 # You should have received a copy of the GNU General Public License
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 # along with this program. If not, see <http://www.gnu.org/licenses/>.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 import json
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 import os
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 import re
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 import sys
3730
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
38 import pystache
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 BASE = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 ## https://www.dicomlibrary.com/dicom/transfer-syntax/
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 ## https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EDICOM_transfer_syntax
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 with open(os.path.join(BASE, 'Resources', 'DicomTransferSyntaxes.json'), 'r') as f:
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 SYNTAXES = json.loads(f.read())
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ##
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ## Generate the "DicomTransferSyntax" enumeration in "Enumerations.h"
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ##
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 path = os.path.join(BASE, 'Core', 'Enumerations.h')
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 with open(path, 'r') as f:
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 a = f.read()
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 s = ',\n'.join(map(lambda x: ' DicomTransferSyntax_%s /*!< %s */' % (x['Value'], x['Name']), SYNTAXES))
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 a = re.sub('(enum DicomTransferSyntax\s*{)[^}]*?(\s*};)', r'\1\n%s\2' % s, a, re.DOTALL)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 with open(path, 'w') as f:
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 f.write(a)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
3730
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
69
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 ##
3730
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
71 ## Generate the implementations
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ##
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
3730
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
74 with open(os.path.join(BASE, 'Core', 'Enumerations_TransferSyntaxes.impl.h'), 'w') as b:
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
75 with open(os.path.join(BASE, 'Resources', 'GenerateTransferSyntaxesEnumerations.mustache'), 'r') as a:
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
76 b.write(pystache.render(a.read(), {
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
77 'Syntaxes' : SYNTAXES
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
78 }))
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
3730
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
80 with open(os.path.join(BASE, 'Core', 'DicomParsing', 'FromDcmtkBridge_TransferSyntaxes.impl.h'), 'w') as b:
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
81 with open(os.path.join(BASE, 'Resources', 'GenerateTransferSyntaxesDcmtk.mustache'), 'r') as a:
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
82 b.write(pystache.render(a.read(), {
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
83 'Syntaxes' : SYNTAXES
ae31ba2b09a6 toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
84 }))