Mercurial > hg > orthanc
annotate OrthancFramework/Resources/CodeGeneration/CheckDcmtkTransferSyntaxes.py @ 5640:f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:19:57 +0200 |
parents | 48b8dae6dc77 |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
7 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
8 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4468
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # This program is free software: you can redistribute it and/or |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public License |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # as published by the Free Software Foundation, either version 3 of |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # the License, or (at your option) any later version. |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # 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
|
16 # WITHOUT ANY WARRANTY; without even the implied warranty of |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # License along with this program. If not, see |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 # <http://www.gnu.org/licenses/>. |
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 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import json |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import os |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import re |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 import sys |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 if len(sys.argv) != 2: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 print('Usage: %s [Path to DCMTK source code]' % sys.argv[0]) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 exit(-1) |
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 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 orthancSyntaxes = [] |
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 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 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
|
39 for syntax in json.loads(f.read()): |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 orthancSyntaxes.append(syntax['UID']) |
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 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 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
|
44 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
|
45 |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 for line in f.readlines(): |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 m = r.match(line) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 if m != None: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 syntax = m.group(2) |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 if not syntax in orthancSyntaxes: |
9c070a34de18
IApplicationEntityFilter::GetAcceptedTransferSyntaxes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 print('Missing syntax: %s => %s' % (syntax, m.group(1))) |