diff --git a/applications/echo.py b/applications/echo.py index 7f9a9274..0ed6190a 100644 --- a/applications/echo.py +++ b/applications/echo.py @@ -1,6 +1,6 @@ import logging -import _odil +import odil def add_subparser(subparsers): parser = subparsers.add_parser( @@ -15,22 +15,22 @@ def add_subparser(subparsers): return parser def echo(host, port, calling_ae_title, called_ae_title): - association = _odil.Association() + association = odil.Association() association.set_peer_host(host) association.set_peer_port(port) association.update_parameters()\ .set_calling_ae_title(calling_ae_title)\ .set_called_ae_title(called_ae_title) \ .set_presentation_contexts([ - _odil.AssociationParameters.PresentationContext( - 3, _odil.registry.VerificationSOPClass, - [ _odil.registry.ImplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 3, odil.registry.VerificationSOPClass, + [ odil.registry.ImplicitVRLittleEndian ], True, False ) ]) association.associate() logging.info("Association established") - echo = _odil.EchoSCU(association) + echo = odil.EchoSCU(association) echo.echo() logging.info("C-ECHO successful") diff --git a/applications/find.py b/applications/find.py index 614b287e..48710f52 100644 --- a/applications/find.py +++ b/applications/find.py @@ -1,6 +1,6 @@ import logging -import _odil +import odil from print_ import find_max_name_length, print_data_set @@ -23,7 +23,7 @@ def add_subparser(subparsers): return parser def find(host, port, calling_ae_title, called_ae_title, level, keys, decode_uids): - query = _odil.DataSet() + query = odil.DataSet() for key in keys: if "=" in key: key, value = key.split("=", 1) @@ -31,34 +31,34 @@ def find(host, port, calling_ae_title, called_ae_title, level, keys, decode_uids else: value = None - tag = getattr(_odil.registry, key) + tag = getattr(odil.registry, key) if value is not None: - vr = _odil.registry.public_dictionary[tag].vr + vr = odil.registry.public_dictionary[tag].vr if vr in ["DS", "FL", "FD"]: - value = _odil.Value.Reals([float(x) for x in value]) + value = odil.Value.Reals([float(x) for x in value]) elif vr in ["IS", "SL", "SS", "UL", "US"]: - value = _odil.Value.Integers([int(x) for x in value]) + value = odil.Value.Integers([int(x) for x in value]) else: - value = _odil.Value.Strings(value) + value = odil.Value.Strings(value) query.add(tag, value) else: query.add(tag) sop_class = getattr( - _odil.registry, + odil.registry, "{}RootQueryRetrieveInformationModelFIND".format(level.capitalize())) - find_pc = _odil.AssociationParameters.PresentationContext( + find_pc = odil.AssociationParameters.PresentationContext( 1, sop_class, [ - _odil.registry.ImplicitVRLittleEndian, - _odil.registry.ExplicitVRLittleEndian + odil.registry.ImplicitVRLittleEndian, + odil.registry.ExplicitVRLittleEndian ], True, False ) - association = _odil.Association() + association = odil.Association() association.set_peer_host(host) association.set_peer_port(port) association.update_parameters()\ @@ -68,7 +68,7 @@ def find(host, port, calling_ae_title, called_ae_title, level, keys, decode_uids association.associate() logging.info("Association established") - find = _odil.FindSCU(association) + find = odil.FindSCU(association) find.set_affected_sop_class(sop_class) data_sets = find.find(query) print "{} answer{}".format(len(data_sets), "s" if len(data_sets)>1 else "") diff --git a/applications/print_.py b/applications/print_.py index 63640d83..d612cbc0 100644 --- a/applications/print_.py +++ b/applications/print_.py @@ -1,6 +1,6 @@ import logging -import _odil +import odil def add_subparser(subparsers): parser = subparsers.add_parser( @@ -18,7 +18,7 @@ def add_subparser(subparsers): def print_(inputs, print_header, decode_uids): for input in inputs: logging.info("Printing {}".format(input)) - header, data_set = _odil.read(input) + header, data_set = odil.read(input) max_length = find_max_name_length(data_set) if print_header: @@ -32,8 +32,8 @@ def print_(inputs, print_header, decode_uids): def print_data_set(data_set, decode_uids, padding, max_length): for tag, element in data_set.items(): name = "{:04x},{:04x}".format(tag.group, tag.element) - if tag in _odil.registry.public_dictionary: - entry = _odil.registry.public_dictionary[tag] + if tag in odil.registry.public_dictionary: + entry = odil.registry.public_dictionary[tag] name = entry.name if element.is_data_set(): @@ -54,10 +54,10 @@ def print_data_set(data_set, decode_uids, padding, max_length): getter = element.as_string value = [x for x in getter()] - if decode_uids and element.vr == _odil.VR.UI: + if decode_uids and element.vr == odil.VR.UI: value = [ - _odil.registry.uids_dictionary[uid].name - if uid in _odil.registry.uids_dictionary else uid + odil.registry.uids_dictionary[uid].name + if uid in odil.registry.uids_dictionary else uid for uid in value ] @@ -77,8 +77,8 @@ def print_data_set(data_set, decode_uids, padding, max_length): def find_max_name_length(data_set, max_length=0, padding_length=0): for tag, element in data_set.items(): - if tag in _odil.registry.public_dictionary: - entry = _odil.registry.public_dictionary[tag] + if tag in odil.registry.public_dictionary: + entry = odil.registry.public_dictionary[tag] length = len(entry.name) else: length = 9 # xxxx,yyyy diff --git a/applications/transcode.py b/applications/transcode.py index b5135a66..572459ea 100644 --- a/applications/transcode.py +++ b/applications/transcode.py @@ -1,6 +1,6 @@ import logging -import _odil +import odil def add_subparser(subparsers): parser = subparsers.add_parser( @@ -27,8 +27,8 @@ def transcode(input, output, format, transfer_syntax, pretty_print): if format == "binary": if transfer_syntax: - transfer_syntax = getattr(_odil.registry, transfer_syntax) - ts_info = _odil.registry.uids_dictionary[transfer_syntax] + transfer_syntax = getattr(odil.registry, transfer_syntax) + ts_info = odil.registry.uids_dictionary[transfer_syntax] if ts_info.type != "Transfer Syntax": raise Exception( "{} is not a transfer syntax".format(ts_info.name)) @@ -43,17 +43,17 @@ def transcode(input, output, format, transfer_syntax, pretty_print): globals()["as_{}".format(format)](input, output, **kwargs) def as_binary(input, output, transfer_syntax): - _, data_set = _odil.read(input) - _odil.write(data_set, output, transfer_syntax=transfer_syntax) + _, data_set = odil.read(input) + odil.write(data_set, output, transfer_syntax=transfer_syntax) def as_json(input, output, pretty_print): - _, data_set = _odil.read(input) + _, data_set = odil.read(input) with open(output, "w") as fd: - json = _odil.as_json(data_set, pretty_print) + json = odil.as_json(data_set, pretty_print) fd.write(json) def as_xml(input, output, pretty_print): - _, data_set = _odil.read(input) + _, data_set = odil.read(input) with open(output, "w") as fd: - xml = _odil.as_xml(data_set, pretty_print) + xml = odil.as_xml(data_set, pretty_print) fd.write(xml) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index be5f613b..91d181ad 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,7 +17,7 @@ file(GLOB_RECURSE examples *.cpp) foreach(example_file ${examples}) get_filename_component(example ${example_file} NAME_WE) add_executable(${example} ${example_file}) - target_link_libraries(${example} odil) + target_link_libraries(${example} libodil) endforeach() file(GLOB_RECURSE python_examples *.py) diff --git a/examples/convert.py b/examples/convert.py index ff1c8868..e392f75c 100644 --- a/examples/convert.py +++ b/examples/convert.py @@ -1,7 +1,7 @@ import argparse import sys -import _odil +import odil def main(): parser = argparse.ArgumentParser(description="Convert a DICOM file") @@ -16,22 +16,22 @@ def main(): help="Include group length tags") arguments = parser.parse_args() - if arguments.transfer_syntax not in dir(_odil.registry): + if arguments.transfer_syntax not in dir(odil.registry): parser.error("Unknown transfer syntax") - uid = getattr(_odil.registry, arguments.transfer_syntax) - if uid not in _odil.registry.uids_dictionary: + uid = getattr(odil.registry, arguments.transfer_syntax) + if uid not in odil.registry.uids_dictionary: parser.error("Unknown transfer syntax") - if _odil.registry.uids_dictionary[uid].type != "Transfer Syntax": + if odil.registry.uids_dictionary[uid].type != "Transfer Syntax": parser.error("Not a transfer syntax") arguments.transfer_syntax = uid arguments.item_length = getattr( - _odil.Writer.ItemEncoding, "{}Length".format(arguments.item_length)) + odil.Writer.ItemEncoding, "{}Length".format(arguments.item_length)) convert(**arguments.__dict__) def convert(input, output, transfer_syntax, item_length, use_group_length): - header, data_set = _odil.read(input) + header, data_set = odil.read(input) to_remove = [ "FileMetaInformationVersion", @@ -40,9 +40,9 @@ def convert(input, output, transfer_syntax, item_length, use_group_length): "ImplementationClassUID", "ImplementationVersionName" ] for name in to_remove: - header.remove(getattr(_odil.registry, name)) + header.remove(getattr(odil.registry, name)) - _odil.write(data_set, output, header, transfer_syntax, item_length, use_group_length) + odil.write(data_set, output, header, transfer_syntax, item_length, use_group_length) if __name__ == "__main__": sys.exit(main()) diff --git a/examples/dump.py b/examples/dump.py index 7bdcf4e5..211e656d 100644 --- a/examples/dump.py +++ b/examples/dump.py @@ -1,7 +1,7 @@ import argparse import sys -import _odil +import odil def main(): parser = argparse.ArgumentParser(description="Print content of DICOM file") @@ -12,7 +12,7 @@ def main(): "--decode-uids", "-D", action="store_true", help="Display UID names") arguments = parser.parse_args() - header, data_set = _odil.read(arguments.file) + header, data_set = odil.read(arguments.file) if arguments.header: print_data_set(header, arguments.decode_uids) print @@ -21,14 +21,14 @@ def main(): def print_data_set(data_set, decode_uids=False, padding=""): max_length = 0 for tag in data_set.keys(): - if tag in _odil.registry.public_dictionary: - entry = _odil.registry.public_dictionary[tag] + if tag in odil.registry.public_dictionary: + entry = odil.registry.public_dictionary[tag] max_length = max(max_length, len(entry.name)) for tag, element in data_set.items(): name = "{:04x},{:04x}".format(tag.group, tag.element) - if tag in _odil.registry.public_dictionary: - entry = _odil.registry.public_dictionary[tag] + if tag in odil.registry.public_dictionary: + entry = odil.registry.public_dictionary[tag] name = entry.name if element.is_data_set(): @@ -46,10 +46,10 @@ def print_data_set(data_set, decode_uids=False, padding=""): getter = element.as_string value = [x for x in getter()] - if decode_uids and element.vr == _odil.VR.UI: + if decode_uids and element.vr == odil.VR.UI: value = [ - _odil.registry.uids_dictionary[uid].name - if uid in _odil.registry.uids_dictionary else uid + odil.registry.uids_dictionary[uid].name + if uid in odil.registry.uids_dictionary else uid for uid in value ] diff --git a/examples/find.py b/examples/find.py index 23c8832f..56e3023e 100644 --- a/examples/find.py +++ b/examples/find.py @@ -1,17 +1,17 @@ -import _odil +import odil -association = _odil.Association() +association = odil.Association() association.set_peer_host("184.73.255.26") association.set_peer_port(11112) presentation_contexts = [ - _odil.AssociationParameters.PresentationContext( - 1, _odil.registry.StudyRootQueryRetrieveInformationModelFIND, - [ _odil.registry.ExplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 1, odil.registry.StudyRootQueryRetrieveInformationModelFIND, + [ odil.registry.ExplicitVRLittleEndian ], True, False ), - _odil.AssociationParameters.PresentationContext( - 3, _odil.registry.VerificationSOPClass, - [ _odil.registry.ExplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 3, odil.registry.VerificationSOPClass, + [ odil.registry.ExplicitVRLittleEndian ], True, False ) ] @@ -21,20 +21,20 @@ .set_presentation_contexts(presentation_contexts) association.associate() -query = _odil.DataSet() -query.add(_odil.registry.PatientName, _odil.Value.Strings(["*"])) -query.add(_odil.registry.QueryRetrieveLevel, _odil.Value.Strings(["STUDY"])) -query.add(_odil.registry.StudyDescription) -query.add(_odil.registry.StudyDate) +query = odil.DataSet() +query.add(odil.registry.PatientName, odil.Value.Strings(["*"])) +query.add(odil.registry.QueryRetrieveLevel, odil.Value.Strings(["STUDY"])) +query.add(odil.registry.StudyDescription) +query.add(odil.registry.StudyDate) -find = _odil.FindSCU(association) -find.set_affected_sop_class(_odil.registry.StudyRootQueryRetrieveInformationModelFIND) +find = odil.FindSCU(association) +find.set_affected_sop_class(odil.registry.StudyRootQueryRetrieveInformationModelFIND) def callback(data_set): - print data_set.as_string(_odil.registry.PatientName)[0] + print data_set.as_string(odil.registry.PatientName)[0] find.find(query, callback) data_sets = find.find(query) print len(data_sets), "found" for data_set in data_sets: - print data_set.as_string(_odil.registry.PatientName)[0] + print data_set.as_string(odil.registry.PatientName)[0] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d582eb1..5218b46f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,11 +17,12 @@ add_definitions( ) link_directories(${Boost_LIBRARY_DIRS} ${DCMTK_LIBRARY_DIRS}) -add_library(odil SHARED ${files} ${headers} ${templates}) +add_library(libodil SHARED ${files} ${headers} ${templates}) +set_target_properties(libodil PROPERTIES OUTPUT_NAME odil) -target_link_libraries(odil +target_link_libraries(libodil ${Boost_LIBRARIES} ${DCMTK_LIBRARIES} ${ICU_LIBRARIES} ${JsonCpp_LIBRARIES}) -set_target_properties(odil PROPERTIES +set_target_properties(libodil PROPERTIES VERSION ${odil_VERSION} SOVERSION ${odil_MAJOR_VERSION}) @@ -29,7 +30,7 @@ install( DIRECTORY odil/ DESTINATION include/odil FILES_MATCHING PATTERN "*.h" PATTERN "*.txx") install( - TARGETS odil + TARGETS libodil ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 437e4783..2541e6e4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,7 +23,7 @@ foreach(test_file ${tests}) get_filename_component(test ${test_file} NAME_WE) add_executable(test_${test} ${test_file} ${headers}) - target_link_libraries(test_${test} odil ${Boost_LIBRARIES}) + target_link_libraries(test_${test} libodil ${Boost_LIBRARIES}) set_target_properties(test_${test} PROPERTIES OUTPUT_NAME ${test}) file(READ ${test_file} content) diff --git a/tests/peer_fixture_base.py b/tests/peer_fixture_base.py index 21289b53..03a16901 100644 --- a/tests/peer_fixture_base.py +++ b/tests/peer_fixture_base.py @@ -1,11 +1,11 @@ import os import unittest -import _odil +import odil class PeerFixtureBase(unittest.TestCase): def setUp(self, contexts): - self.association = _odil.Association() + self.association = odil.Association() self.association.set_peer_host(os.environ["ODIL_PEER_HOST_NAME"]) self.association.set_peer_port(int(os.environ["ODIL_PEER_PORT"])) self.association.update_parameters()\ diff --git a/tests/wrappers/test_association.py b/tests/wrappers/test_association.py index ec5c631a..036ea9e9 100644 --- a/tests/wrappers/test_association.py +++ b/tests/wrappers/test_association.py @@ -1,44 +1,44 @@ import unittest -import _odil +import odil class TestAssociation(unittest.TestCase): def test_default_constructor(self): - association = _odil.Association() + association = odil.Association() self.assertFalse(association.is_associated()) def test_peer_host(self): - association = _odil.Association() + association = odil.Association() association.set_peer_host("pacs.example.com") self.assertEqual(association.get_peer_host(), "pacs.example.com") def test_peer_port(self): - association = _odil.Association() + association = odil.Association() association.set_peer_port(1234) self.assertEqual(association.get_peer_port(), 1234) def test_peer_port(self): - association = _odil.Association() + association = odil.Association() association.set_peer_port(1234) self.assertEqual(association.get_peer_port(), 1234) def test_parameters(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_called_ae_title("foo") - association = _odil.Association() + association = odil.Association() association.set_parameters(parameters) self.assertEqual( association.get_parameters().get_called_ae_title(), "foo") def test_update_parameters(self): - association = _odil.Association() + association = odil.Association() association.update_parameters().set_called_ae_title("foo") self.assertEqual( association.get_parameters().get_called_ae_title(), "foo") def test_next_message_id(self): - association = _odil.Association() + association = odil.Association() id1 = association.next_message_id() id2 = association.next_message_id() self.assertNotEqual(id1, id2) diff --git a/tests/wrappers/test_association_parameters.py b/tests/wrappers/test_association_parameters.py index e97d96b9..fb4b8d0f 100644 --- a/tests/wrappers/test_association_parameters.py +++ b/tests/wrappers/test_association_parameters.py @@ -1,10 +1,10 @@ import unittest -import _odil +import odil class TestAssociationParameters(unittest.TestCase): def test_default_constructor(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() self.assertEqual(parameters.get_called_ae_title(), "") self.assertEqual(parameters.get_calling_ae_title(), "") self.assertEqual(len(parameters.get_presentation_contexts()), 0) @@ -12,27 +12,27 @@ def test_default_constructor(self): user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.None) + odil.AssociationParameters.UserIdentity.Type.None) self.assertEqual(parameters.get_maximum_length(), 16384) def test_called_ae_title(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_called_ae_title("foo") self.assertEqual(parameters.get_called_ae_title(), "foo") def test_calling_ae_title(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_calling_ae_title("foo") self.assertEqual(parameters.get_calling_ae_title(), "foo") def test_presentation_contexts(self): - presentation_context = _odil.AssociationParameters.PresentationContext() + presentation_context = odil.AssociationParameters.PresentationContext() presentation_context.id = 1 presentation_context.abstract_syntax = "foo" presentation_context.transfer_syntaxes.append("bar") - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_presentation_contexts([presentation_context]) self.assertEqual(len(parameters.get_presentation_contexts()), 1) @@ -40,70 +40,70 @@ def test_presentation_contexts(self): parameters.get_presentation_contexts()[0], presentation_context) def test_user_identity_username(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_user_identity_to_username("foo") user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.Username) + odil.AssociationParameters.UserIdentity.Type.Username) self.assertEqual(user_identity.primary_field, "foo") def test_user_identity_username_and_password(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_user_identity_to_username_and_password("foo", "bar") user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.UsernameAndPassword) + odil.AssociationParameters.UserIdentity.Type.UsernameAndPassword) self.assertEqual(user_identity.primary_field, "foo") self.assertEqual(user_identity.secondary_field, "bar") def test_user_identity_kerberos(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_user_identity_to_kerberos("foo") user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.Kerberos) + odil.AssociationParameters.UserIdentity.Type.Kerberos) self.assertEqual(user_identity.primary_field, "foo") def test_user_identity_saml(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_user_identity_to_saml("foo") user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.SAML) + odil.AssociationParameters.UserIdentity.Type.SAML) self.assertEqual(user_identity.primary_field, "foo") def test_user_identity_none(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_user_identity_to_saml("foo") parameters.set_user_identity_to_none() user_identity = parameters.get_user_identity() self.assertEqual( user_identity.type, - _odil.AssociationParameters.UserIdentity.Type.None) + odil.AssociationParameters.UserIdentity.Type.None) def test_maximum_length(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_maximum_length(12345) self.assertEqual(parameters.get_maximum_length(), 12345) def test_chaining(self): - parameters = _odil.AssociationParameters() + parameters = odil.AssociationParameters() parameters.set_called_ae_title("foo").set_calling_ae_title("bar") self.assertEqual(parameters.get_called_ae_title(), "foo") self.assertEqual(parameters.get_calling_ae_title(), "bar") class TestPresentationContext(unittest.TestCase): def test_constructor(self): - presentation_context = _odil.AssociationParameters.PresentationContext( + presentation_context = odil.AssociationParameters.PresentationContext( 1, "foo", ["bar", "baz"], False, True) self.assertEqual(presentation_context.id, 1) self.assertEqual(presentation_context.abstract_syntax, "foo") diff --git a/tests/wrappers/test_data_set.py b/tests/wrappers/test_data_set.py index 1142cf4f..c43e533a 100644 --- a/tests/wrappers/test_data_set.py +++ b/tests/wrappers/test_data_set.py @@ -1,116 +1,116 @@ import unittest -import _odil +import odil class TestDataSet(unittest.TestCase): def test_empty_constructor(self): - data_set = _odil.DataSet() + data_set = odil.DataSet() self.assertTrue(data_set.empty()) self.assertEqual(data_set.size(), 0) self.assertEqual(len(data_set), 0) def test_empty_element(self): - tag = _odil.registry.PatientName - data_set = _odil.DataSet() - data_set.add(tag, _odil.Element()) + tag = odil.registry.PatientName + data_set = odil.DataSet() + data_set.add(tag, odil.Element()) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.INVALID) + self.assertEqual(data_set.get_vr(tag), odil.VR.INVALID) self.assertTrue(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 0) def test_empty_element_tag(self): - tag = _odil.registry.PatientName - data_set = _odil.DataSet() + tag = odil.registry.PatientName + data_set = odil.DataSet() data_set.add(tag) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.PN) + self.assertEqual(data_set.get_vr(tag), odil.VR.PN) self.assertTrue(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 0) def test_int_element(self): - tag = _odil.registry.SelectorUSValue + tag = odil.registry.SelectorUSValue value = [1, 2, 3] - data_set = _odil.DataSet() - data_set.add(tag, _odil.Value.Integers(value)) + data_set = odil.DataSet() + data_set.add(tag, odil.Value.Integers(value)) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.US) + self.assertEqual(data_set.get_vr(tag), odil.VR.US) self.assertFalse(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 3) self.assertTrue(data_set.is_int(tag)) self.assertEqual([x for x in data_set.as_int(tag)], value) def test_real_element(self): - tag = _odil.registry.SelectorFLValue + tag = odil.registry.SelectorFLValue value = [1.1, 2, 3.3] - data_set = _odil.DataSet() - data_set.add(tag, _odil.Value.Reals(value)) + data_set = odil.DataSet() + data_set.add(tag, odil.Value.Reals(value)) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.FL) + self.assertEqual(data_set.get_vr(tag), odil.VR.FL) self.assertFalse(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 3) self.assertTrue(data_set.is_real(tag)) self.assertEqual([x for x in data_set.as_real(tag)], value) def test_string_element(self): - tag = _odil.registry.SelectorCSValue + tag = odil.registry.SelectorCSValue value = ["foo", "bar"] - data_set = _odil.DataSet() - data_set.add(tag, _odil.Value.Strings(value)) + data_set = odil.DataSet() + data_set.add(tag, odil.Value.Strings(value)) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.CS) + self.assertEqual(data_set.get_vr(tag), odil.VR.CS) self.assertFalse(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 2) self.assertTrue(data_set.is_string(tag)) self.assertEqual([x for x in data_set.as_string(tag)], value) def test_data_set_element(self): - tag = _odil.registry.SelectorCodeSequenceValue - value = [_odil.DataSet(), _odil.DataSet()] - data_set = _odil.DataSet() + tag = odil.registry.SelectorCodeSequenceValue + value = [odil.DataSet(), odil.DataSet()] + data_set = odil.DataSet() data_set.add( - tag, _odil.Value.DataSets(value)) + tag, odil.Value.DataSets(value)) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.SQ) + self.assertEqual(data_set.get_vr(tag), odil.VR.SQ) self.assertFalse(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 2) self.assertTrue(data_set.is_data_set(tag)) self.assertEqual([x for x in data_set.as_data_set(tag)], value) def test_string_binary(self): - tag = _odil.registry.RedPaletteColorLookupTableData - value = [_odil.Value.BinaryItem("\x01\x02")] - data_set = _odil.DataSet() - data_set.add(tag, _odil.Value.Binary(value)) + tag = odil.registry.RedPaletteColorLookupTableData + value = [odil.Value.BinaryItem("\x01\x02")] + data_set = odil.DataSet() + data_set.add(tag, odil.Value.Binary(value)) self.assertFalse(data_set.empty()) self.assertEqual(data_set.size(), 1) self.assertEqual(len(data_set), 1) - self.assertEqual(data_set.get_vr(tag), _odil.VR.OW) + self.assertEqual(data_set.get_vr(tag), odil.VR.OW) self.assertFalse(data_set.empty(tag)) self.assertEqual(data_set.size(tag), 1) self.assertTrue(data_set.is_binary(tag)) @@ -118,33 +118,33 @@ def test_string_binary(self): [x for x in data_set.as_binary(tag)[0]], [x for x in value[0]]) def test_getitem(self): - data_set = _odil.DataSet() - data_set.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) + data_set = odil.DataSet() + data_set.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) self.assertEqual( - [x for x in data_set[_odil.registry.PatientName].as_string()], + [x for x in data_set[odil.registry.PatientName].as_string()], ["Doe^John"]) - self.assertRaises(Exception, lambda x: data_set[_odil.registry.PatientID]) + self.assertRaises(Exception, lambda x: data_set[odil.registry.PatientID]) def test_iter(self): - data_set = _odil.DataSet() - data_set.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - data_set.add(_odil.registry.PatientID, _odil.Value.Strings(["DJ123"])) + data_set = odil.DataSet() + data_set.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + data_set.add(odil.registry.PatientID, odil.Value.Strings(["DJ123"])) self.assertEqual( [x.get_name() for x in data_set], ["PatientName", "PatientID"]) def test_keys(self): - data_set = _odil.DataSet() - data_set.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - data_set.add(_odil.registry.PatientID, _odil.Value.Strings(["DJ123"])) + data_set = odil.DataSet() + data_set.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + data_set.add(odil.registry.PatientID, odil.Value.Strings(["DJ123"])) self.assertEqual( [x.get_name() for x in data_set.keys()], ["PatientName", "PatientID"]) def test_values(self): - data_set = _odil.DataSet() - data_set.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - data_set.add(_odil.registry.PatientID, _odil.Value.Strings(["DJ123"])) + data_set = odil.DataSet() + data_set.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + data_set.add(odil.registry.PatientID, odil.Value.Strings(["DJ123"])) self.assertEqual( [ [item for item in element.as_string()] @@ -152,9 +152,9 @@ def test_values(self): [["Doe^John"], ["DJ123"]]) def test_items(self): - data_set = _odil.DataSet() - data_set.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - data_set.add(_odil.registry.PatientID, _odil.Value.Strings(["DJ123"])) + data_set = odil.DataSet() + data_set.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + data_set.add(odil.registry.PatientID, odil.Value.Strings(["DJ123"])) self.assertEqual( [ [tag.get_name(), [item for item in element.as_string()]] diff --git a/tests/wrappers/test_echo_scu.py b/tests/wrappers/test_echo_scu.py index ab7c49b3..43575b92 100644 --- a/tests/wrappers/test_echo_scu.py +++ b/tests/wrappers/test_echo_scu.py @@ -2,7 +2,7 @@ import sys import unittest -import _odil +import odil sys.path.append(os.path.dirname(os.path.dirname(__file__))) from peer_fixture_base import PeerFixtureBase @@ -12,14 +12,14 @@ def setUp(self): PeerFixtureBase.setUp( self, [ - _odil.AssociationParameters.PresentationContext( - 3, _odil.registry.VerificationSOPClass, - [ _odil.registry.ImplicitVRLittleEndian ], True, False) + odil.AssociationParameters.PresentationContext( + 3, odil.registry.VerificationSOPClass, + [ odil.registry.ImplicitVRLittleEndian ], True, False) ] ) def test_echo(self): - echo = _odil.EchoSCU(self.association) + echo = odil.EchoSCU(self.association) echo.echo() if __name__ == "__main__": diff --git a/tests/wrappers/test_element.py b/tests/wrappers/test_element.py index fbcd2320..1fcbe744 100644 --- a/tests/wrappers/test_element.py +++ b/tests/wrappers/test_element.py @@ -1,53 +1,53 @@ import unittest -import _odil +import odil class TestElement(unittest.TestCase): def test_empty_constructor(self): - element = _odil.Element() + element = odil.Element() self.assertTrue(element.empty()) self.assertEqual(element.size(), 0) self.assertEqual(len(element), 0) - self.assertEqual(element.vr, _odil.VR.INVALID) + self.assertEqual(element.vr, odil.VR.INVALID) def test_integers_constructor(self): items = [1, 2, 3] - element = _odil.Element(_odil.Value.Integers(items), _odil.VR.US) + element = odil.Element(odil.Value.Integers(items), odil.VR.US) self.assertEqual([x for x in element.as_int()], items) - self.assertEqual(element.vr, _odil.VR.US) + self.assertEqual(element.vr, odil.VR.US) self.assertEqual(element.size(), 3) self.assertEqual(len(element), 3) def test_reals_constructor(self): items = [1.1, 2, 3.3] - element = _odil.Element(_odil.Value.Reals(items), _odil.VR.FL) + element = odil.Element(odil.Value.Reals(items), odil.VR.FL) self.assertEqual([x for x in element.as_real()], items) - self.assertEqual(element.vr, _odil.VR.FL) + self.assertEqual(element.vr, odil.VR.FL) self.assertEqual(element.size(), 3) self.assertEqual(len(element), 3) def test_strings_constructor(self): items = ["foo", "bar"] - element = _odil.Element(_odil.Value.Strings(items), _odil.VR.CS) + element = odil.Element(odil.Value.Strings(items), odil.VR.CS) self.assertEqual([x for x in element.as_string()], items) - self.assertEqual(element.vr, _odil.VR.CS) + self.assertEqual(element.vr, odil.VR.CS) self.assertEqual(element.size(), 2) self.assertEqual(len(element), 2) def test_data_sets_constructor(self): - items = [_odil.DataSet(), _odil.DataSet()] - element = _odil.Element(_odil.Value.DataSets(items), _odil.VR.SQ) + items = [odil.DataSet(), odil.DataSet()] + element = odil.Element(odil.Value.DataSets(items), odil.VR.SQ) self.assertEqual([x for x in element.as_data_set()], items) - self.assertEqual(element.vr, _odil.VR.SQ) + self.assertEqual(element.vr, odil.VR.SQ) self.assertEqual(element.size(), 2) self.assertEqual(len(element), 2) def test_binary_constructor(self): - items = [_odil.Value.BinaryItem("\x01\x02\x03")] - element = _odil.Element(_odil.Value.Binary(items), _odil.VR.OB) + items = [odil.Value.BinaryItem("\x01\x02\x03")] + element = odil.Element(odil.Value.Binary(items), odil.VR.OB) self.assertEqual( [x for x in element.as_binary()[0]], [x for x in items[0]]) - self.assertEqual(element.vr, _odil.VR.OB) + self.assertEqual(element.vr, odil.VR.OB) self.assertEqual(element.size(), 1) self.assertEqual(len(element), 1) diff --git a/tests/wrappers/test_elements_dictionary.py b/tests/wrappers/test_elements_dictionary.py index 39f5912c..1afee09d 100644 --- a/tests/wrappers/test_elements_dictionary.py +++ b/tests/wrappers/test_elements_dictionary.py @@ -1,20 +1,20 @@ import unittest -import _odil +import odil class TestElementsDictionaryKey(unittest.TestCase): def test_empty_constructor(self): - key = _odil.ElementsDictionaryKey() + key = odil.ElementsDictionaryKey() def test_tag_constructor(self): - key = _odil.ElementsDictionaryKey(_odil.registry.PatientName) + key = odil.ElementsDictionaryKey(odil.registry.PatientName) def test_string_constructor(self): - key = _odil.ElementsDictionaryKey("60xx0010") + key = odil.ElementsDictionaryKey("60xx0010") class TestElementsDictionaryEntry(unittest.TestCase): def test_constructor(self): - entry = _odil.ElementsDictionaryEntry( + entry = odil.ElementsDictionaryEntry( "Patient's Name", "PatientName", "PN", "1") self.assertEqual(entry.name, "Patient's Name") self.assertEqual(entry.keyword, "PatientName") @@ -24,21 +24,21 @@ def test_constructor(self): class TestElementsDictionary(unittest.TestCase): def test_contains(self): self.assertTrue( - _odil.registry.PatientName in _odil.registry.public_dictionary) + odil.registry.PatientName in odil.registry.public_dictionary) self.assertFalse( - _odil.Tag(0x0001, 0x0001) in _odil.registry.public_dictionary) - self.assertTrue("60xx0010" in _odil.registry.public_dictionary) - self.assertFalse("foo" in _odil.registry.public_dictionary) + odil.Tag(0x0001, 0x0001) in odil.registry.public_dictionary) + self.assertTrue("60xx0010" in odil.registry.public_dictionary) + self.assertFalse("foo" in odil.registry.public_dictionary) def test_get_item_tag(self): - entry = _odil.registry.public_dictionary[_odil.registry.PatientName] + entry = odil.registry.public_dictionary[odil.registry.PatientName] self.assertEqual(entry.name, "Patient's Name") self.assertEqual(entry.keyword, "PatientName") self.assertEqual(entry.vr, "PN") self.assertEqual(entry.vm, "1") def test_get_item_string(self): - entry = _odil.registry.public_dictionary["60xx0010"] + entry = odil.registry.public_dictionary["60xx0010"] self.assertEqual(entry.name, "Overlay Rows") self.assertEqual(entry.keyword, "OverlayRows") self.assertEqual(entry.vr, "US") diff --git a/tests/wrappers/test_find_scu.py b/tests/wrappers/test_find_scu.py index dd13dfd4..40eb1776 100644 --- a/tests/wrappers/test_find_scu.py +++ b/tests/wrappers/test_find_scu.py @@ -2,7 +2,7 @@ import sys import unittest -import _odil +import odil sys.path.append(os.path.dirname(os.path.dirname(__file__))) from peer_fixture_base import PeerFixtureBase @@ -12,25 +12,25 @@ def setUp(self): PeerFixtureBase.setUp( self, [ - _odil.AssociationParameters.PresentationContext( - 1, _odil.registry.PatientRootQueryRetrieveInformationModelFIND, - [ _odil.registry.ImplicitVRLittleEndian ], True, False) + odil.AssociationParameters.PresentationContext( + 1, odil.registry.PatientRootQueryRetrieveInformationModelFIND, + [ odil.registry.ImplicitVRLittleEndian ], True, False) ] ) - self.query = _odil.DataSet() - self.query.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - self.query.add(_odil.registry.QueryRetrieveLevel, _odil.Value.Strings(["PATIENT"])) - self.query.add(_odil.registry.PatientID) + self.query = odil.DataSet() + self.query.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + self.query.add(odil.registry.QueryRetrieveLevel, odil.Value.Strings(["PATIENT"])) + self.query.add(odil.registry.PatientID) def test_without_callback(self): - find = _odil.FindSCU(self.association) - find.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelFIND) + find = odil.FindSCU(self.association) + find.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelFIND) data_sets = find.find(self.query) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.PatientID)], + [x for x in data_sets[0].as_string(odil.registry.PatientID)], ["DJ001"]) def test_with_callback(self): @@ -38,13 +38,13 @@ def test_with_callback(self): def callback(data_set): data_sets.append(data_set) - find = _odil.FindSCU(self.association) - find.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelFIND) + find = odil.FindSCU(self.association) + find.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelFIND) find.find(self.query, callback) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.PatientID)], + [x for x in data_sets[0].as_string(odil.registry.PatientID)], ["DJ001"]) if __name__ == "__main__": diff --git a/tests/wrappers/test_get_scu.py b/tests/wrappers/test_get_scu.py index 08f01b25..7d2dd35d 100644 --- a/tests/wrappers/test_get_scu.py +++ b/tests/wrappers/test_get_scu.py @@ -2,7 +2,7 @@ import sys import unittest -import _odil +import odil sys.path.append(os.path.dirname(os.path.dirname(__file__))) from peer_fixture_base import PeerFixtureBase @@ -12,28 +12,28 @@ def setUp(self): PeerFixtureBase.setUp( self, [ - _odil.AssociationParameters.PresentationContext( - 1, _odil.registry.PatientRootQueryRetrieveInformationModelGET, - [ _odil.registry.ImplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 1, odil.registry.PatientRootQueryRetrieveInformationModelGET, + [ odil.registry.ImplicitVRLittleEndian ], True, False ), - _odil.AssociationParameters.PresentationContext( - 3, _odil.registry.RawDataStorage, - [ _odil.registry.ImplicitVRLittleEndian ], False, True + odil.AssociationParameters.PresentationContext( + 3, odil.registry.RawDataStorage, + [ odil.registry.ImplicitVRLittleEndian ], False, True ) ]) - self.query = _odil.DataSet() - self.query.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - self.query.add(_odil.registry.QueryRetrieveLevel, _odil.Value.Strings(["PATIENT"])) + self.query = odil.DataSet() + self.query.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + self.query.add(odil.registry.QueryRetrieveLevel, odil.Value.Strings(["PATIENT"])) def test_without_callback(self): - get = _odil.GetSCU(self.association) - get.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelGET) + get = odil.GetSCU(self.association) + get.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelGET) data_sets = get.get(self.query) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.SOPInstanceUID)], + [x for x in data_sets[0].as_string(odil.registry.SOPInstanceUID)], ["2.25.95090344942250266709587559073467305647"]) def test_with_callback(self): @@ -41,13 +41,13 @@ def test_with_callback(self): def callback(data_set): data_sets.append(data_set) - get = _odil.GetSCU(self.association) - get.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelGET) + get = odil.GetSCU(self.association) + get.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelGET) get.get(self.query, callback) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.SOPInstanceUID)], + [x for x in data_sets[0].as_string(odil.registry.SOPInstanceUID)], ["2.25.95090344942250266709587559073467305647"]) if __name__ == "__main__": diff --git a/tests/wrappers/test_move_scu.py b/tests/wrappers/test_move_scu.py index a26a2626..0092a57b 100644 --- a/tests/wrappers/test_move_scu.py +++ b/tests/wrappers/test_move_scu.py @@ -2,7 +2,7 @@ import sys import unittest -import _odil +import odil sys.path.append(os.path.dirname(os.path.dirname(__file__))) from peer_fixture_base import PeerFixtureBase @@ -12,38 +12,38 @@ def setUp(self): PeerFixtureBase.setUp( self, [ - _odil.AssociationParameters.PresentationContext( - 1, _odil.registry.PatientRootQueryRetrieveInformationModelMOVE, - [ _odil.registry.ImplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 1, odil.registry.PatientRootQueryRetrieveInformationModelMOVE, + [ odil.registry.ImplicitVRLittleEndian ], True, False ), - _odil.AssociationParameters.PresentationContext( - 3, _odil.registry.RawDataStorage, - [ _odil.registry.ImplicitVRLittleEndian ], False, True + odil.AssociationParameters.PresentationContext( + 3, odil.registry.RawDataStorage, + [ odil.registry.ImplicitVRLittleEndian ], False, True ) ]) - self.query = _odil.DataSet() - self.query.add(_odil.registry.PatientName, _odil.Value.Strings(["Doe^John"])) - self.query.add(_odil.registry.QueryRetrieveLevel, _odil.Value.Strings(["PATIENT"])) + self.query = odil.DataSet() + self.query.add(odil.registry.PatientName, odil.Value.Strings(["Doe^John"])) + self.query.add(odil.registry.QueryRetrieveLevel, odil.Value.Strings(["PATIENT"])) def test_default_constructor(self): - move = _odil.MoveSCU(self.association) + move = odil.MoveSCU(self.association) self.assertEqual(move.get_move_destination(), "") def test_move_destination(self): - move = _odil.MoveSCU(self.association) + move = odil.MoveSCU(self.association) move.set_move_destination("remote") self.assertEqual(move.get_move_destination(), "remote") def test_without_callback(self): - move = _odil.MoveSCU(self.association) - move.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelMOVE) + move = odil.MoveSCU(self.association) + move.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelMOVE) move.set_move_destination("LOCAL") data_sets = move.move(self.query) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.SOPInstanceUID)], + [x for x in data_sets[0].as_string(odil.registry.SOPInstanceUID)], ["2.25.95090344942250266709587559073467305647"]) def test_with_callback(self): @@ -51,14 +51,14 @@ def test_with_callback(self): def callback(data_set): data_sets.append(data_set) - move = _odil.MoveSCU(self.association) - move.set_affected_sop_class(_odil.registry.PatientRootQueryRetrieveInformationModelMOVE) + move = odil.MoveSCU(self.association) + move.set_affected_sop_class(odil.registry.PatientRootQueryRetrieveInformationModelMOVE) move.set_move_destination("LOCAL") move.move(self.query, callback) self.assertEqual(len(data_sets), 1) self.assertEqual( - [x for x in data_sets[0].as_string(_odil.registry.SOPInstanceUID)], + [x for x in data_sets[0].as_string(odil.registry.SOPInstanceUID)], ["2.25.95090344942250266709587559073467305647"]) if __name__ == "__main__": diff --git a/tests/wrappers/test_registry.py b/tests/wrappers/test_registry.py index df8c9eb4..71d0adb5 100644 --- a/tests/wrappers/test_registry.py +++ b/tests/wrappers/test_registry.py @@ -1,17 +1,17 @@ import unittest -import _odil +import odil class TestRegistry(unittest.TestCase): def test_attribute(self): - tag = _odil.registry.PatientID + tag = odil.registry.PatientID self.assertEqual(tag.group, 0x0010) self.assertEqual(tag.element, 0x0020) def test_public_dictionary(self): - tag = _odil.registry.PatientID - self.assertTrue(tag in _odil.registry.public_dictionary) - entry = _odil.registry.public_dictionary[tag] + tag = odil.registry.PatientID + self.assertTrue(tag in odil.registry.public_dictionary) + entry = odil.registry.public_dictionary[tag] self.assertEqual(entry.name, "Patient ID") self.assertEqual(entry.keyword, "PatientID") self.assertEqual(entry.vr, "LO") @@ -19,8 +19,8 @@ def test_public_dictionary(self): def test_uids_dictionary(self): uid = "1.2.840.10008.1.2.1" - self.assertTrue(uid in _odil.registry.uids_dictionary) - entry = _odil.registry.uids_dictionary[uid] + self.assertTrue(uid in odil.registry.uids_dictionary) + entry = odil.registry.uids_dictionary[uid] self.assertEqual(entry.name, "Explicit VR Little Endian") self.assertEqual(entry.keyword, "ExplicitVRLittleEndian") self.assertEqual(entry.type, "Transfer Syntax") diff --git a/tests/wrappers/test_store_scu.py b/tests/wrappers/test_store_scu.py index dc0ccd43..20bb4fbb 100644 --- a/tests/wrappers/test_store_scu.py +++ b/tests/wrappers/test_store_scu.py @@ -2,7 +2,7 @@ import sys import unittest -import _odil +import odil sys.path.append(os.path.dirname(os.path.dirname(__file__))) from peer_fixture_base import PeerFixtureBase @@ -12,38 +12,38 @@ def setUp(self): PeerFixtureBase.setUp( self, [ - _odil.AssociationParameters.PresentationContext( - 1, _odil.registry.RawDataStorage, - [ _odil.registry.ImplicitVRLittleEndian ], True, False + odil.AssociationParameters.PresentationContext( + 1, odil.registry.RawDataStorage, + [ odil.registry.ImplicitVRLittleEndian ], True, False ) ]) - self.data_set = _odil.DataSet() + self.data_set = odil.DataSet() self.data_set.add( - _odil.registry.ImageType, - _odil.Value.Strings(["ORIGINAL", "PRIMARY", "OTHER"])) + odil.registry.ImageType, + odil.Value.Strings(["ORIGINAL", "PRIMARY", "OTHER"])) self.data_set.add( - _odil.registry.PatientID, _odil.Value.Strings(["1234"])) + odil.registry.PatientID, odil.Value.Strings(["1234"])) self.data_set.add( - _odil.registry.StudyInstanceUID, - _odil.Value.Strings(["2.25.386726390606491051215227596277040710"])) + odil.registry.StudyInstanceUID, + odil.Value.Strings(["2.25.386726390606491051215227596277040710"])) self.data_set.add( - _odil.registry.SeriesInstanceUID, - _odil.Value.Strings(["2.25.235367796740370588607388995952651763168"])) + odil.registry.SeriesInstanceUID, + odil.Value.Strings(["2.25.235367796740370588607388995952651763168"])) self.data_set.add( - _odil.registry.SOPClassUID, - _odil.Value.Strings([_odil.registry.RawDataStorage])) + odil.registry.SOPClassUID, + odil.Value.Strings([odil.registry.RawDataStorage])) self.data_set.add( - _odil.registry.SOPInstanceUID, - _odil.Value.Strings(["2.25.294312554735929033890522327215919068328"])) + odil.registry.SOPInstanceUID, + odil.Value.Strings(["2.25.294312554735929033890522327215919068328"])) def test_affected_sop_class_uid(self): - store = _odil.StoreSCU(self.association) + store = odil.StoreSCU(self.association) store.set_affected_sop_class(self.data_set) - self.assertEqual(store.get_affected_sop_class(), _odil.registry.RawDataStorage) + self.assertEqual(store.get_affected_sop_class(), odil.registry.RawDataStorage) def test_store(self): - store = _odil.StoreSCU(self.association) + store = odil.StoreSCU(self.association) store.set_affected_sop_class(self.data_set) store.store(self.data_set) diff --git a/tests/wrappers/test_tag.py b/tests/wrappers/test_tag.py index f0ed3ead..cf21990c 100644 --- a/tests/wrappers/test_tag.py +++ b/tests/wrappers/test_tag.py @@ -1,86 +1,86 @@ import unittest -import _odil +import odil class TestTag(unittest.TestCase): def test_two_ints_constructor(self): - tag = _odil.Tag(0x1234, 0x5678) + tag = odil.Tag(0x1234, 0x5678) self.assertEqual(tag.group, 0x1234) self.assertEqual(tag.element, 0x5678) def test_one_int_constructor(self): - tag = _odil.Tag(0x12345678) + tag = odil.Tag(0x12345678) self.assertEqual(tag.group, 0x1234) self.assertEqual(tag.element, 0x5678) def test_string_constructor(self): - tag = _odil.Tag("PatientID") + tag = odil.Tag("PatientID") self.assertEqual(tag.group, 0x0010) self.assertEqual(tag.element, 0x0020) def test_group(self): - tag = _odil.Tag(0x1234, 0x5678) + tag = odil.Tag(0x1234, 0x5678) tag.group = 0x4321 self.assertEqual(tag.group, 0x4321) self.assertEqual(tag.element, 0x5678) def test_element(self): - tag = _odil.Tag(0x1234, 0x5678) + tag = odil.Tag(0x1234, 0x5678) tag.element = 0x8765 self.assertEqual(tag.group, 0x1234) self.assertEqual(tag.element, 0x8765) def test_is_private(self): - public = _odil.Tag(0x1234, 0x5678) + public = odil.Tag(0x1234, 0x5678) self.assertTrue(not public.is_private()) - private = _odil.Tag(0x1235, 0x5678) + private = odil.Tag(0x1235, 0x5678) self.assertTrue(private.is_private()) def test_get_name(self): - tag = _odil.Tag(0x0010, 0x0020) + tag = odil.Tag(0x0010, 0x0020) self.assertEqual(tag.get_name(), "PatientID") def test_equality(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertTrue(tag1 == tag1) self.assertFalse(tag1 == tag2) def test_inequality(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertFalse(tag1 != tag1) self.assertTrue(tag1 != tag2) def test_less(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertTrue(tag1 < tag2) self.assertFalse(tag2 < tag1) def test_greater(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertFalse(tag1 > tag2) self.assertTrue(tag2 > tag1) def test_less_or_equal(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertTrue(tag1 <= tag2) self.assertTrue(tag1 <= tag1) self.assertFalse(tag2 <= tag1) def test_greater_or_equal(self): - tag1 = _odil.Tag(0x1234, 0x5678) - tag2 = _odil.Tag(0x4321, 0x8765) + tag1 = odil.Tag(0x1234, 0x5678) + tag2 = odil.Tag(0x4321, 0x8765) self.assertFalse(tag1 >= tag2) self.assertTrue(tag1 >= tag1) self.assertTrue(tag2 >= tag1) def test_str(self): - tag = _odil.Tag(0x1234, 0x5678) + tag = odil.Tag(0x1234, 0x5678) self.assertEqual(str(tag), "12345678") if __name__ == "__main__": diff --git a/tests/wrappers/test_uid.py b/tests/wrappers/test_uid.py index fc00c6d0..a80ec893 100644 --- a/tests/wrappers/test_uid.py +++ b/tests/wrappers/test_uid.py @@ -1,14 +1,14 @@ import unittest -import _odil +import odil class TestUID(unittest.TestCase): def test_uid_prefix(self): - self.assertEqual(_odil.uid_prefix, "1.2.826.0.1.3680043.9.5560") + self.assertEqual(odil.uid_prefix, "1.2.826.0.1.3680043.9.5560") def test_uid_prefix(self): - uid = _odil.generate_uid() - self.assertEqual(uid[:len(_odil.uid_prefix)], _odil.uid_prefix) + uid = odil.generate_uid() + self.assertEqual(uid[:len(odil.uid_prefix)], odil.uid_prefix) if __name__ == "__main__": unittest.main() diff --git a/tests/wrappers/test_uids_dictionary.py b/tests/wrappers/test_uids_dictionary.py index f67d5d4f..8088e6ab 100644 --- a/tests/wrappers/test_uids_dictionary.py +++ b/tests/wrappers/test_uids_dictionary.py @@ -1,10 +1,10 @@ import unittest -import _odil +import odil class TestUIDsDictionaryEntry(unittest.TestCase): def test_constructor(self): - entry = _odil.UIDsDictionaryEntry( + entry = odil.UIDsDictionaryEntry( "MR Image Storage", "MRImageStorage", "SOP Class") self.assertEqual(entry.name, "MR Image Storage") self.assertEqual(entry.keyword, "MRImageStorage") @@ -12,7 +12,7 @@ def test_constructor(self): class TestUIDsDictionary(unittest.TestCase): def test_get_item(self): - entry = _odil.registry.uids_dictionary["1.2.840.10008.5.1.4.1.1.4"] + entry = odil.registry.uids_dictionary["1.2.840.10008.5.1.4.1.1.4"] self.assertEqual(entry.name, "MR Image Storage") self.assertEqual(entry.keyword, "MRImageStorage") self.assertEqual(entry.type, "SOP Class") diff --git a/tests/wrappers/test_value.py b/tests/wrappers/test_value.py index 15566e46..035b972f 100644 --- a/tests/wrappers/test_value.py +++ b/tests/wrappers/test_value.py @@ -1,86 +1,86 @@ import unittest -import _odil +import odil class TestValue(unittest.TestCase): def test_empty_constructor(self): - value = _odil.Value() + value = odil.Value() self.assertTrue(value.empty()) def test_integers_constructor(self): items = [1, 2, 3] - value = _odil.Value(_odil.Value.Integers(items)) + value = odil.Value(odil.Value.Integers(items)) self.assertEqual([x for x in value.as_integers()], items) def test_reals_constructor(self): items = [1.1, 2, 3.3] - value = _odil.Value(_odil.Value.Reals(items)) + value = odil.Value(odil.Value.Reals(items)) self.assertEqual([x for x in value.as_reals()], items) def test_strings_constructor(self): items = ["foo", "bar"] - value = _odil.Value(_odil.Value.Strings(items)) + value = odil.Value(odil.Value.Strings(items)) self.assertEqual([x for x in value.as_strings()], items) def test_data_sets_constructor(self): - items = [_odil.DataSet(), _odil.DataSet()] - value = _odil.Value(_odil.Value.DataSets(items)) + items = [odil.DataSet(), odil.DataSet()] + value = odil.Value(odil.Value.DataSets(items)) self.assertEqual([x for x in value.as_data_sets()], items) def test_binary_constructor(self): - items = [_odil.Value.BinaryItem("\x01\x02\x03")] - value = _odil.Value(_odil.Value.Binary(items)) + items = [odil.Value.BinaryItem("\x01\x02\x03")] + value = odil.Value(odil.Value.Binary(items)) self.assertEqual( [x for x in value.as_binary()[0]], [x for x in items[0]]) class TestValueIntegers(unittest.TestCase): def test_empty_constructor(self): - data = _odil.Value.Integers() + data = odil.Value.Integers() self.assertEqual([x for x in data], []) def test_sequence_constructor(self): items = [1, 2, 3] - data = _odil.Value.Integers(items) + data = odil.Value.Integers(items) self.assertEqual([x for x in data], items) class TestValueReals(unittest.TestCase): def test_empty_constructor(self): - data = _odil.Value.Reals() + data = odil.Value.Reals() self.assertEqual([x for x in data], []) def test_sequence_constructor(self): items = [1.1, 2, 3.3] - data = _odil.Value.Reals(items) + data = odil.Value.Reals(items) self.assertEqual([x for x in data], items) class TestValueStrings(unittest.TestCase): def test_empty_constructor(self): - data = _odil.Value.Strings() + data = odil.Value.Strings() self.assertEqual([x for x in data], []) def test_sequence_constructor(self): items = ["foo", "bar"] - data = _odil.Value.Strings(items) + data = odil.Value.Strings(items) self.assertEqual([x for x in data], items) class TestValueDataSets(unittest.TestCase): def test_empty_constructor(self): - data = _odil.Value.DataSets() + data = odil.Value.DataSets() self.assertEqual([x for x in data], []) def test_sequence_constructor(self): - items = [_odil.DataSet(), _odil.DataSet()] - data = _odil.Value.DataSets(items) + items = [odil.DataSet(), odil.DataSet()] + data = odil.Value.DataSets(items) self.assertEqual([x for x in data], items) class TestValueBinary(unittest.TestCase): def test_empty_constructor(self): - data = _odil.Value.Binary() + data = odil.Value.Binary() self.assertEqual([x for x in data], []) def test_sequence_constructor(self): - items = [_odil.Value.BinaryItem("\x01\x02\x03")] - data = _odil.Value.Binary(items) + items = [odil.Value.BinaryItem("\x01\x02\x03")] + data = odil.Value.Binary(items) self.assertEqual([x for x in data[0]], [x for x in items[0]]) if __name__ == "__main__": diff --git a/tests/wrappers/test_vr.py b/tests/wrappers/test_vr.py index 48eb6449..ef1660fc 100644 --- a/tests/wrappers/test_vr.py +++ b/tests/wrappers/test_vr.py @@ -1,10 +1,10 @@ import unittest -import _odil +import odil class TestVR(unittest.TestCase): def test_string(self): - vr = _odil.VR.AE + vr = odil.VR.AE self.assertEqual(str(vr), "AE") if __name__ == "__main__": diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index f6b28495..a5a0de3b 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -8,10 +8,12 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) file(GLOB_RECURSE files "*.cpp") -python_add_module(_odil SHARED ${files}) +python_add_module(pyodil SHARED ${files}) +set_target_properties( + pyodil PROPERTIES OUTPUT_NAME odil) if(APPLE) - set_target_properties(_odil PROPERTIES SUFFIX ".so") + set_target_properties(pyodil PROPERTIES SUFFIX ".so") endif() target_link_libraries( - _odil ${Boost_LIBRARIES} ${JsonCpp_LIBRARIES} odil ${PYTHON_LIBRARIES}) + pyodil ${Boost_LIBRARIES} ${JsonCpp_LIBRARIES} libodil ${PYTHON_LIBRARIES}) diff --git a/wrappers/odil.cpp b/wrappers/odil.cpp index 2c4f9e69..1fea1e83 100644 --- a/wrappers/odil.cpp +++ b/wrappers/odil.cpp @@ -31,7 +31,7 @@ void wrap_xml_converter(); void wrap_registry(); -BOOST_PYTHON_MODULE(_odil) +BOOST_PYTHON_MODULE(odil) { wrap_Association(); wrap_AssociationParameters();