dbdicom 0.3.10__py3-none-any.whl → 0.3.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dbdicom might be problematic. Click here for more details.

dbdicom/api.py CHANGED
@@ -181,14 +181,16 @@ def copy(from_entity:list, to_entity=None):
181
181
  return from_entity_copy
182
182
 
183
183
 
184
- def delete(entity:list):
184
+ def delete(entity:list, not_exists_ok=False):
185
185
  """Delete a DICOM entity
186
186
 
187
187
  Args:
188
188
  entity (list): entity to delete
189
+ not_exists_ok (bool): By default, an exception is raised when attempting
190
+ to delete an entity that does not exist. Set this to True to pass over this silently.
189
191
  """
190
192
  dbd = open(entity[0])
191
- dbd.delete(entity)
193
+ dbd.delete(entity, not_exists_ok)
192
194
  dbd.close()
193
195
 
194
196
 
dbdicom/dbd.py CHANGED
@@ -72,14 +72,25 @@ class DataBaseDicom():
72
72
 
73
73
 
74
74
 
75
- def delete(self, entity):
75
+ def delete(self, entity, not_exists_ok=False):
76
76
  """Delete a DICOM entity from the database
77
77
 
78
78
  Args:
79
79
  entity (list): entity to delete
80
+ not_exists_ok (bool): By default, an exception is raised when attempting
81
+ to delete an entity that does not exist. Set this to True to pass over this silently.
80
82
  """
81
83
  # delete datasets on disk
82
- removed = register.index(self.register, entity)
84
+ try:
85
+ removed = register.index(self.register, entity)
86
+ except ValueError:
87
+ if not_exists_ok:
88
+ return self
89
+ else:
90
+ raise ValueError(
91
+ f"The entity you are trying to delete does not exist. \n"
92
+ f"You can set not_exists_ok=True in dbdicom.delete() to avoid this error."
93
+ )
83
94
  for index in removed:
84
95
  file = os.path.join(self.path, index)
85
96
  if os.path.exists(file):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbdicom
3
- Version: 0.3.10
3
+ Version: 0.3.11
4
4
  Summary: A pythonic interface for reading and writing DICOM databases
5
5
  Author-email: Steven Sourbron <s.sourbron@sheffield.ac.uk>, Ebony Gunwhy <e.gunwhy@sheffield.ac.uk>
6
6
  Project-URL: Homepage, https://openmiblab.github.io/dbdicom/
@@ -1,9 +1,9 @@
1
1
  dbdicom/__init__.py,sha256=dW5aezonmMc_41Dp1PuYmXQlr307RkyJxsJuetkpWso,87
2
- dbdicom/api.py,sha256=5jOJjwOahDrj97Hu0XEJbryvhihpv4iuPSXdX8INpsE,14731
2
+ dbdicom/api.py,sha256=lXF74j1PvQ00WdRu_CJvvtKNoBVGcwUH7YohM_m9Dk4,14949
3
3
  dbdicom/const.py,sha256=BqBiRRjeiSqDr1W6YvaayD8WKCjG4Cny2NT0GeLM6bI,4269
4
4
  dbdicom/database.py,sha256=mkYQAAf9fETzUhSQflQFp7RQUBdPlSlDty9nn6KY1jQ,4771
5
5
  dbdicom/dataset.py,sha256=pokXlcXLM33OdqMKGfVcWHlVE9ez4iBfpoefVWw1ob8,14421
6
- dbdicom/dbd.py,sha256=isqBzCE5bxfixZTH5ShNmJ123vCAhueGxV7pCTrqBF8,44035
6
+ dbdicom/dbd.py,sha256=vitqM706NObGnd29vBpizO24OPOaAdAJ7ODYwXE4Mp8,44600
7
7
  dbdicom/register.py,sha256=5yXnTbRUu8rYJqeIbSv5SiRf2E4BZ0JZyvKm_xvaXZQ,14944
8
8
  dbdicom/external/__init__.py,sha256=XNQqfspyf6vFGedXlRKZsUB8k8E-0W19Uamwn8Aioxo,316
9
9
  dbdicom/external/__pycache__/__init__.cpython-311.pyc,sha256=pXAQ35ixd92fm6YcuHgzR1t6RcASQ-cHhU1wOA5b8sw,542
@@ -47,8 +47,8 @@ dbdicom/utils/dcm4che.py,sha256=Vxq8NYWWK3BuqJkzhBQ89oMqzJlnxqTxgsgTo_Frznc,2317
47
47
  dbdicom/utils/files.py,sha256=qhWNJqeWnRjDNbERpC6Mz962_TW9mFdvd2lnBbK3xt4,2259
48
48
  dbdicom/utils/image.py,sha256=zRM1O0bxPp-qpf3Iv_GRS1omKaMN1SgSkAwufWLJ0Fk,3863
49
49
  dbdicom/utils/pydicom_dataset.py,sha256=XM3EERsCWPlEaUzVaFQSbPNiNbEGwxIbf-sUKKf_YxA,12755
50
- dbdicom-0.3.10.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
51
- dbdicom-0.3.10.dist-info/METADATA,sha256=0BoheAKLRKF5pClyGgZqc1Y07-AH3I7IbvB-Mh9tQQA,1031
52
- dbdicom-0.3.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- dbdicom-0.3.10.dist-info/top_level.txt,sha256=nJWxXg4YjD6QblfmhrzTMXcr8FSKNc0Yk-CAIDUsYkQ,8
54
- dbdicom-0.3.10.dist-info/RECORD,,
50
+ dbdicom-0.3.11.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
51
+ dbdicom-0.3.11.dist-info/METADATA,sha256=vsikqOJDm30MtPF3YpAalFQ4v6poQ_g5-C_aXkCgGrg,1031
52
+ dbdicom-0.3.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
+ dbdicom-0.3.11.dist-info/top_level.txt,sha256=nJWxXg4YjD6QblfmhrzTMXcr8FSKNc0Yk-CAIDUsYkQ,8
54
+ dbdicom-0.3.11.dist-info/RECORD,,