# HG changeset patch # User Sebastien Jodogne # Date 1622742071 -7200 # Node ID 7e4d1f2b3a8f56a8de16a4c187b6689c5b23f442 # Parent cdab941fe17d87fe14bed7a3c9f8055f3a67945c GenerateAnonymizationProfile.py can read from URL diff -r cdab941fe17d -r 7e4d1f2b3a8f OrthancFramework/Sources/DicomParsing/DicomModification.cpp --- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Thu Jun 03 17:40:15 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Thu Jun 03 19:41:11 2021 +0200 @@ -579,9 +579,9 @@ /** * This is Table E.1-1 from PS 3.15-2017c (DICOM Part 15: Security * and System Management Profiles), "basic profile" column. It was - * generated automatically with the - * "../Resources/GenerateAnonymizationProfile.py" script. - * https://raw.githubusercontent.com/jodogne/dicom-specification/master/2017c/part15.pdf + * generated automatically by calling: + * "../../../OrthancServer/Resources/GenerateAnonymizationProfile.py + * https://raw.githubusercontent.com/jodogne/dicom-specification/master/2017c/part15.xml" **/ // TODO: (50xx,xxxx) with rule X // Curve Data diff -r cdab941fe17d -r 7e4d1f2b3a8f OrthancServer/Resources/GenerateAnonymizationProfile.py --- a/OrthancServer/Resources/GenerateAnonymizationProfile.py Thu Jun 03 17:40:15 2021 +0200 +++ b/OrthancServer/Resources/GenerateAnonymizationProfile.py Thu Jun 03 19:41:11 2021 +0200 @@ -32,17 +32,26 @@ import re +import requests import sys import xml.etree.ElementTree as ET # Usage: -# ./GenerateAnonymizationProfile.py ~/Subversion/dicom-specification/2017c/part15.xml +# ./GenerateAnonymizationProfile.py https://raw.githubusercontent.com/jodogne/dicom-specification/master/2021b/part15.xml if len(sys.argv) != 2: - raise Exception('Please provide the path to the part15.xml file from the DICOM standard') + raise Exception('Please provide the path or the URL to the part15.xml file from the DICOM standard') + +source = sys.argv[1] -with open(sys.argv[1], 'r') as f: - root = ET.fromstring(f.read()) +if (source.startswith('http://') or + source.startswith('https://')): + part15 = requests.get(source).content +else: + with open(source, 'r') as f: + part15 = f.read() + +root = ET.fromstring(part15) br = '{http://docbook.org/ns/docbook}' # Shorthand variable @@ -115,7 +124,7 @@ FormatUnknown(rawTag, name, profile) for line in sorted(LINES): - print line + print(line.encode('ascii', 'ignore').decode('ascii')) # D - replace with a non-zero length value that may be a dummy value and consistent with the VR