Skip to content

Commit 57740c0

Browse files
author
hackermd
committed
Rename QIDO-RS methods
All ``search_*`` methods were renamed to ``search_for*`` to match the names of the corresponding QIDO-RS resources.
1 parent 95fe9ca commit 57740c0

File tree

8 files changed

+45
-44
lines changed

8 files changed

+45
-44
lines changed

src/dicomweb_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.1.2'
1+
__version__ = '0.2.0'
22

33
from dicomweb_client.api import DICOMWebClient

src/dicomweb_client/api.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ def _http_post_multipart_application_dicom(self, url, datasets):
564564
data = self._encode_multipart_message(encoded_datasets, content_type)
565565
self._http_post(url, data, headers={'Content-Type': content_type})
566566

567-
def search_studies(self, fuzzymatching=None, limit=None, offset=None,
568-
fields=None, search_filters={}):
569-
'''Searches DICOM studies.
567+
def search_for_studies(self, fuzzymatching=None, limit=None, offset=None,
568+
fields=None, search_filters={}):
569+
'''Searches for DICOM studies.
570570
571571
Parameters
572572
----------
@@ -641,9 +641,10 @@ def retrieve_study_metadata(self, study_instance_uid):
641641
url += '/metadata'
642642
return self._http_get_application_json(url)
643643

644-
def search_series(self, study_instance_uid=None, fuzzymatching=None,
645-
limit=None, offset=None, fields=None, search_filters={}):
646-
'''Searches DICOM series.
644+
def search_for_series(self, study_instance_uid=None, fuzzymatching=None,
645+
limit=None, offset=None, fields=None,
646+
search_filters={}):
647+
'''Searches for DICOM series.
647648
648649
Parameters
649650
----------
@@ -730,11 +731,11 @@ def retrieve_series_metadata(self, study_instance_uid, series_instance_uid):
730731
url += '/metadata'
731732
return self._http_get_application_json(url)
732733

733-
def search_instances(self, study_instance_uid=None,
734-
series_instance_uid=None, fuzzymatching=None,
735-
limit=None, offset=None, fields=None,
736-
search_filters={}):
737-
'''Searches DICOM instances.
734+
def search_for_instances(self, study_instance_uid=None,
735+
series_instance_uid=None, fuzzymatching=None,
736+
limit=None, offset=None, fields=None,
737+
search_filters={}):
738+
'''Searches for DICOM instances.
738739
739740
Parameters
740741
----------

src/dicomweb_client/cli.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,33 +155,33 @@ def _get_parser():
155155
search_subparsers.required = True
156156

157157
# QIDO - Studies
158-
search_studies_parser = search_subparsers.add_parser(
158+
search_for_studies_parser = search_subparsers.add_parser(
159159
'studies',
160160
description='Search for DICOM studies.',
161161
parents=[abstract_search_parser, abstract_fmt_parser]
162162
)
163-
search_studies_parser.set_defaults(func=_search_studies)
163+
search_for_studies_parser.set_defaults(func=_search_for_studies)
164164

165165
# QUIDO - Series
166-
search_series_parser = search_subparsers.add_parser(
166+
search_for_series_parser = search_subparsers.add_parser(
167167
'series',
168168
description='Search for DICOM series.',
169169
parents=[
170170
abstract_search_parser, abstract_fmt_parser,
171171
abstract_optional_study_parser
172172
]
173173
)
174-
search_series_parser.set_defaults(func=_search_series)
174+
search_for_series_parser.set_defaults(func=_search_for_series)
175175

176176
# QIDO - Instances
177-
search_instances_parser = search_subparsers.add_parser(
177+
search_for_instances_parser = search_subparsers.add_parser(
178178
'instances', description='Search for DICOM instances.',
179179
parents=[
180180
abstract_fmt_parser, abstract_search_parser,
181181
abstract_optional_study_parser, abstract_optional_series_parser
182182
]
183183
)
184-
search_instances_parser.set_defaults(func=_search_instances)
184+
search_for_instances_parser.set_defaults(func=_search_for_instances)
185185

186186
# WADO
187187
retrieve_parser = subparsers.add_parser(
@@ -429,27 +429,27 @@ def _print_pixeldata(image):
429429
print('\n')
430430

431431

432-
def _search_studies(args):
432+
def _search_for_studies(args):
433433
'''Searches for *Studies* and writes metadata to standard output.'''
434434
params = _parse_search_parameters(args)
435435
client = DICOMWebClient(args.url, args.username, args.password)
436-
studies = client.search_studies(**params)
436+
studies = client.search_for_studies(**params)
437437
_print_metadata(studies, args.prettify, args.dicomize)
438438

439439

440-
def _search_series(args):
440+
def _search_for_series(args):
441441
'''Searches for Series and writes metadata to standard output.'''
442442
params = _parse_search_parameters(args)
443443
client = DICOMWebClient(args.url, args.username, args.password)
444-
series = client.search_series(args.study_instance_uid, **params)
444+
series = client.search_for_series(args.study_instance_uid, **params)
445445
_print_metadata(series, args.prettify, args.dicomize)
446446

447447

448-
def _search_instances(args):
448+
def _search_for_instances(args):
449449
'''Searches for Instances and writes metadata to standard output.'''
450450
params = _parse_search_parameters(args)
451451
client = DICOMWebClient(args.url, args.username, args.password)
452-
instances = client.search_instances(
452+
instances = client.search_for_instances(
453453
args.study_instance_uid, args.series_instance_uid, **params
454454
)
455455
_print_metadata(instances, args.prettify, args.dicomize)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/dicomweb_client/tests/test_api.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@
66
from PIL import Image
77

88

9-
def test_search_studies(httpserver, client, cache_dir):
10-
cache_filename = os.path.join(cache_dir, 'search_studies.json')
9+
def test_search_for_studies(httpserver, client, cache_dir):
10+
cache_filename = os.path.join(cache_dir, 'search_for_studies.json')
1111
with open(cache_filename, 'r') as f:
1212
content = f.read()
1313
parsed_content = json.loads(content)
1414
headers = {'content-type': 'application/dicom+json'}
1515
httpserver.serve_content(content=content, code=200, headers=headers)
16-
assert client.search_studies() == parsed_content
16+
assert client.search_for_studies() == parsed_content
1717
request = httpserver.requests[0]
1818
assert request.path == '/studies'
1919
assert request.accept_mimetypes == [('application/dicom+json', 1)]
2020

2121

22-
def test_search_studies_limit_offset(httpserver, client, cache_dir):
23-
cache_filename = os.path.join(cache_dir, 'search_studies.json')
22+
def test_search_for_studies_limit_offset(httpserver, client, cache_dir):
23+
cache_filename = os.path.join(cache_dir, 'search_for_studies.json')
2424
with open(cache_filename, 'r') as f:
2525
data = json.loads(f.read())
2626
# We will limit the search to 2 studies starting with the 2nd.
2727
content = json.dumps(data[1:3])
2828
parsed_content = json.loads(content)
2929
headers = {'content-type': 'application/dicom+json'}
3030
httpserver.serve_content(content=content, code=200, headers=headers)
31-
assert client.search_studies(limit=2, offset=1) == parsed_content
31+
assert client.search_for_studies(limit=2, offset=1) == parsed_content
3232
request = httpserver.requests[0]
3333
assert (
3434
request.query_string.decode() == 'limit=2&offset=1' or
@@ -38,28 +38,28 @@ def test_search_studies_limit_offset(httpserver, client, cache_dir):
3838
assert request.accept_mimetypes == [('application/dicom+json', 1)]
3939

4040

41-
def test_search_series(httpserver, client, cache_dir):
42-
cache_filename = os.path.join(cache_dir, 'search_series.json')
41+
def test_search_for_series(httpserver, client, cache_dir):
42+
cache_filename = os.path.join(cache_dir, 'search_for_series.json')
4343
with open(cache_filename, 'r') as f:
4444
content = f.read()
4545
parsed_content = json.loads(content)
4646
headers = {'content-type': 'application/dicom+json'}
4747
httpserver.serve_content(content=content, code=200, headers=headers)
48-
assert client.search_series() == parsed_content
48+
assert client.search_for_series() == parsed_content
4949
request = httpserver.requests[0]
5050
assert request.path == '/series'
5151
assert request.accept_mimetypes == [('application/dicom+json', 1)]
5252

5353

54-
def test_search_series_limit_offset(httpserver, client, cache_dir):
55-
cache_filename = os.path.join(cache_dir, 'search_series.json')
54+
def test_search_for_series_limit_offset(httpserver, client, cache_dir):
55+
cache_filename = os.path.join(cache_dir, 'search_for_series.json')
5656
with open(cache_filename, 'r') as f:
5757
data = json.loads(f.read())
5858
content = json.dumps(data[1:3])
5959
parsed_content = json.loads(content)
6060
headers = {'content-type': 'application/dicom+json'}
6161
httpserver.serve_content(content=content, code=200, headers=headers)
62-
assert client.search_studies(limit=2, offset=1) == parsed_content
62+
assert client.search_for_studies(limit=2, offset=1) == parsed_content
6363
request = httpserver.requests[0]
6464
assert (
6565
request.query_string.decode() == 'limit=2&offset=1' or
@@ -69,27 +69,27 @@ def test_search_series_limit_offset(httpserver, client, cache_dir):
6969
assert request.accept_mimetypes == [('application/dicom+json', 1)]
7070

7171

72-
def test_search_instances(httpserver, client, cache_dir):
73-
cache_filename = os.path.join(cache_dir, 'search_instances.json')
72+
def test_search_for_instances(httpserver, client, cache_dir):
73+
cache_filename = os.path.join(cache_dir, 'search_for_instances.json')
7474
with open(cache_filename, 'r') as f:
7575
content = f.read()
7676
parsed_content = json.loads(content)
7777
headers = {'content-type': 'application/dicom+json'}
7878
httpserver.serve_content(content=content, code=200, headers=headers)
79-
assert client.search_instances() == parsed_content
79+
assert client.search_for_instances() == parsed_content
8080
request = httpserver.requests[0]
8181
assert request.path == '/instances'
8282
assert request.accept_mimetypes == [('application/dicom+json', 1)]
8383

8484

85-
def test_search_instances_limit_offset(httpserver, client, cache_dir):
86-
cache_filename = os.path.join(cache_dir, 'search_instances.json')
85+
def test_search_for_instances_limit_offset(httpserver, client, cache_dir):
86+
cache_filename = os.path.join(cache_dir, 'search_for_instances.json')
8787
with open(cache_filename, 'r') as f:
8888
content = f.read()
8989
parsed_content = json.loads(content)
9090
headers = {'content-type': 'application/dicom+json'}
9191
httpserver.serve_content(content=content, code=200, headers=headers)
92-
assert client.search_instances(limit=2, offset=1) == parsed_content
92+
assert client.search_for_instances(limit=2, offset=1) == parsed_content
9393
request = httpserver.requests[0]
9494
assert (
9595
request.query_string.decode() == 'limit=2&offset=1' or
@@ -99,12 +99,12 @@ def test_search_instances_limit_offset(httpserver, client, cache_dir):
9999
assert request.accept_mimetypes == [('application/dicom+json', 1)]
100100

101101

102-
def test_search_instances_includefields(httpserver, client, cache_dir):
102+
def test_search_for_instances_includefields(httpserver, client, cache_dir):
103103
headers = {'content-type': 'application/dicom+json'}
104104
httpserver.serve_content(content='', code=200, headers=headers)
105105
f1 = 'StudyInstanceUID'
106106
f2 = 'SeriesInstanceUID'
107-
client.search_instances(fields={f1, f2})
107+
client.search_for_instances(fields={f1, f2})
108108
request = httpserver.requests[0]
109109
query_string_opt_1 = 'includefield={}&includefield={}'.format(f1, f2)
110110
query_string_opt_2 = 'includefield={}&includefield={}'.format(f2, f1)

0 commit comments

Comments
 (0)