Commit b4eb8959 authored by payno's avatar payno
Browse files

move _DICT_TYPE_KEY and _DICT_PATH_KEY to public

parent caa2b8c4
Pipeline #22024 passed with stages
in 4 minutes and 43 seconds
...@@ -246,11 +246,11 @@ class EDFTomoScan(TomoScanBase): ...@@ -246,11 +246,11 @@ class EDFTomoScan(TomoScanBase):
data = json.load(desc) data = json.load(desc)
else: else:
data = desc data = desc
if not (self._DICT_TYPE_KEY in data and data[self._DICT_TYPE_KEY] == self._TYPE): if not (self.DICT_TYPE_KEY in data and data[self.DICT_TYPE_KEY] == self._TYPE):
raise ValueError('Description is not an EDFScan json description') raise ValueError('Description is not an EDFScan json description')
assert self._DICT_PATH_KEY in data assert self.DICT_PATH_KEY in data
self.path = data[self._DICT_PATH_KEY] self.path = data[self.DICT_PATH_KEY]
return self return self
@staticmethod @staticmethod
......
...@@ -277,13 +277,13 @@ class HDF5TomoScan(TomoScanBase): ...@@ -277,13 +277,13 @@ class HDF5TomoScan(TomoScanBase):
data = json.load(_dict) data = json.load(_dict)
else: else:
data = _dict data = _dict
if not (self._DICT_TYPE_KEY in data and data[self._DICT_TYPE_KEY] == self._TYPE): if not (self.DICT_TYPE_KEY in data and data[self.DICT_TYPE_KEY] == self._TYPE):
raise ValueError('Description is not an HDF5Scan json description') raise ValueError('Description is not an HDF5Scan json description')
if HDF5TomoScan._DICT_ENTRY_KEY not in data: if HDF5TomoScan._DICT_ENTRY_KEY not in data:
raise ValueError('No hdf5 entry specified') raise ValueError('No hdf5 entry specified')
assert self._DICT_PATH_KEY in data assert self.DICT_PATH_KEY in data
self.path = data[self._DICT_PATH_KEY] self.path = data[self.DICT_PATH_KEY]
self._entry = data[self._DICT_ENTRY_KEY] self._entry = data[self._DICT_ENTRY_KEY]
return self return self
......
...@@ -46,9 +46,9 @@ class TomoScanBase: ...@@ -46,9 +46,9 @@ class TomoScanBase:
:param scan: path to the root folder containing the scan. :param scan: path to the root folder containing the scan.
:type: Union[str,None] :type: Union[str,None]
""" """
_DICT_TYPE_KEY = 'type' DICT_TYPE_KEY = 'type'
_DICT_PATH_KEY = 'path' DICT_PATH_KEY = 'path'
_SCHEME = None _SCHEME = None
"""scheme to read data url for this type of acquisition""" """scheme to read data url for this type of acquisition"""
...@@ -212,8 +212,8 @@ class TomoScanBase: ...@@ -212,8 +212,8 @@ class TomoScanBase:
:rtype: dict :rtype: dict
""" """
res = dict() res = dict()
res[self._DICT_TYPE_KEY] = self.type res[self.DICT_TYPE_KEY] = self.type
res[self._DICT_PATH_KEY] = self.path res[self.DICT_PATH_KEY] = self.path
return res return res
def load_from_dict(self, _dict: dict): def load_from_dict(self, _dict: dict):
......
...@@ -90,13 +90,13 @@ class ScanFactory: ...@@ -90,13 +90,13 @@ class ScanFactory:
:return: instance of TomoScanBase :return: instance of TomoScanBase
:rtype: TomoScanBase :rtype: TomoScanBase
""" """
if TomoScanBase._DICT_TYPE_KEY not in _dict: if TomoScanBase.DICT_TYPE_KEY not in _dict:
raise ValueError('given dict is not recognized. Cannot find' raise ValueError('given dict is not recognized. Cannot find'
'', TomoScanBase._DICT_TYPE_KEY) '', TomoScanBase.DICT_TYPE_KEY)
elif _dict[TomoScanBase._DICT_TYPE_KEY] == EDFTomoScan._TYPE: elif _dict[TomoScanBase.DICT_TYPE_KEY] == EDFTomoScan._TYPE:
return EDFTomoScan(scan=None).load_from_dict(_dict) return EDFTomoScan(scan=None).load_from_dict(_dict)
else: else:
raise ValueError('Scan type', _dict[TomoScanBase._DICT_TYPE_KEY], raise ValueError('Scan type', _dict[TomoScanBase.DICT_TYPE_KEY],
'is not managed') 'is not managed')
@staticmethod @staticmethod
...@@ -117,9 +117,9 @@ class ScanFactory: ...@@ -117,9 +117,9 @@ class ScanFactory:
"""Create a ScanBase instance from a json description""" """Create a ScanBase instance from a json description"""
data = json.load(desc) data = json.load(desc)
if TomoScanBase._DICT_TYPE_KEY not in data: if TomoScanBase.DICT_TYPE_KEY not in data:
raise ValueError('json not recognize') raise ValueError('json not recognize')
elif data[TomoScanBase._DICT_TYPE_KEY] == EDFTomoScan._TYPE: elif data[TomoScanBase.DICT_TYPE_KEY] == EDFTomoScan._TYPE:
scan = EDFTomoScan(scan=None).load_from_dict(data) scan = EDFTomoScan(scan=None).load_from_dict(data)
return scan return scan
else: else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment