comparison OrthancFramework/Resources/CodeGeneration/GenerateTransferSyntaxes.py @ 4468:9c070a34de18

IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 25 Jan 2021 15:18:34 +0100
parents d9473bd5ed43
children 7053502fbf97
comparison
equal deleted inserted replaced
4467:c92ec129698a 4468:9c070a34de18
24 import os 24 import os
25 import re 25 import re
26 import sys 26 import sys
27 import pystache 27 import pystache
28 28
29 BASE = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 29 BASE = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
30 30
31 31
32 32
33 ## https://www.dicomlibrary.com/dicom/transfer-syntax/ 33 ## https://www.dicomlibrary.com/dicom/transfer-syntax/
34 ## https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EDICOM_transfer_syntax 34 ## https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EDICOM_transfer_syntax
35 35
36 36
37 with open(os.path.join(BASE, 'Resources', 'DicomTransferSyntaxes.json'), 'r') as f: 37 with open(os.path.join(BASE, 'Resources', 'CodeGeneration', 'DicomTransferSyntaxes.json'), 'r') as f:
38 SYNTAXES = json.loads(f.read()) 38 SYNTAXES = json.loads(f.read())
39 39
40 40
41 41
42 ## 42 ##
43 ## Generate the "DicomTransferSyntax" enumeration in "Enumerations.h" 43 ## Generate the "DicomTransferSyntax" enumeration in "Enumerations.h"
44 ## 44 ##
45 45
46 path = os.path.join(BASE, 'Core', 'Enumerations.h') 46 path = os.path.join(BASE, 'Sources', 'Enumerations.h')
47 with open(path, 'r') as f: 47 with open(path, 'r') as f:
48 a = f.read() 48 a = f.read()
49 49
50 s = ',\n'.join(map(lambda x: ' DicomTransferSyntax_%s /*!< %s */' % (x['Value'], x['Name']), SYNTAXES)) 50 s = ',\n'.join(map(lambda x: ' DicomTransferSyntax_%s /*!< %s */' % (x['Value'], x['Name']), SYNTAXES))
51 51
58 58
59 ## 59 ##
60 ## Generate the implementations 60 ## Generate the implementations
61 ## 61 ##
62 62
63 with open(os.path.join(BASE, 'Core', 'Enumerations_TransferSyntaxes.impl.h'), 'w') as b: 63 with open(os.path.join(BASE, 'Sources', 'Enumerations_TransferSyntaxes.impl.h'), 'w') as b:
64 with open(os.path.join(BASE, 'Resources', 'GenerateTransferSyntaxesEnumerations.mustache'), 'r') as a: 64 with open(os.path.join(BASE, 'Resources', 'CodeGeneration', 'GenerateTransferSyntaxesEnumerations.mustache'), 'r') as a:
65 b.write(pystache.render(a.read(), { 65 b.write(pystache.render(a.read(), {
66 'Syntaxes' : SYNTAXES 66 'Syntaxes' : SYNTAXES
67 })) 67 }))
68 68
69 with open(os.path.join(BASE, 'Core', 'DicomParsing', 'FromDcmtkBridge_TransferSyntaxes.impl.h'), 'w') as b: 69 with open(os.path.join(BASE, 'Sources', 'DicomParsing', 'FromDcmtkBridge_TransferSyntaxes.impl.h'), 'w') as b:
70 with open(os.path.join(BASE, 'Resources', 'GenerateTransferSyntaxesDcmtk.mustache'), 'r') as a: 70 with open(os.path.join(BASE, 'Resources', 'CodeGeneration', 'GenerateTransferSyntaxesDcmtk.mustache'), 'r') as a:
71 b.write(pystache.render(a.read(), { 71 b.write(pystache.render(a.read(), {
72 'Syntaxes' : SYNTAXES 72 'Syntaxes' : SYNTAXES
73 })) 73 }))