Mercurial > hg > orthanc
annotate OrthancFramework/Resources/CodeGeneration/CheckDcmtkTransferSyntaxes.py @ 4962:501411a67f10 more-tags
merge
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 23 Mar 2022 12:23:11 +0100 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
4468
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 # Orthanc - A Lightweight, RESTful DICOM Store |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 # Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
7 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4468
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public License |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # as published by the Free Software Foundation, either version 3 of |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # the License, or (at your option) any later version. |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # This program is distributed in the hope that it will be useful, but |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # Lesser General Public License for more details. |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # License along with this program. If not, see |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # <http://www.gnu.org/licenses/>. |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 import json |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import os |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import re |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import sys |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 if len(sys.argv) != 2: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 print('Usage: %s [Path to DCMTK source code]' % sys.argv[0]) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 exit(-1) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 orthancSyntaxes = [] |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 with open(os.path.join(os.path.dirname(__file__), 'DicomTransferSyntaxes.json'), 'r') as f: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 for syntax in json.loads(f.read()): |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 orthancSyntaxes.append(syntax['UID']) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 with open(os.path.join(sys.argv[1], 'dcmdata/include/dcmtk/dcmdata/dcuid.h'), 'r') as f: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 r = re.compile(r'^#define UID_([A-Za-z0-9_]+)TransferSyntax\s+"([0-9.]+)"$') |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 for line in f.readlines(): |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 m = r.match(line) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 if m != None: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 syntax = m.group(2) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 if not syntax in orthancSyntaxes: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 print('Missing syntax: %s => %s' % (syntax, m.group(1))) |