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):
data = json.load(desc)
else:
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')
assert self._DICT_PATH_KEY in data
self.path = data[self._DICT_PATH_KEY]
assert self.DICT_PATH_KEY in data
self.path = data[self.DICT_PATH_KEY]
return self
@staticmethod
......
......@@ -277,13 +277,13 @@ class HDF5TomoScan(TomoScanBase):
data = json.load(_dict)
else:
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')
if HDF5TomoScan._DICT_ENTRY_KEY not in data:
raise ValueError('No hdf5 entry specified')
assert self._DICT_PATH_KEY in data
self.path = data[self._DICT_PATH_KEY]
assert self.DICT_PATH_KEY in data
self.path = data[self.DICT_PATH_KEY]
self._entry = data[self._DICT_ENTRY_KEY]
return self
......
......@@ -46,9 +46,9 @@ class TomoScanBase:
:param scan: path to the root folder containing the scan.
:type: Union[str,None]
"""
_DICT_TYPE_KEY = 'type'
DICT_TYPE_KEY = 'type'
_DICT_PATH_KEY = 'path'
DICT_PATH_KEY = 'path'
_SCHEME = None
"""scheme to read data url for this type of acquisition"""
......@@ -212,8 +212,8 @@ class TomoScanBase:
:rtype: dict
"""
res = dict()
res[self._DICT_TYPE_KEY] = self.type
res[self._DICT_PATH_KEY] = self.path
res[self.DICT_TYPE_KEY] = self.type
res[self.DICT_PATH_KEY] = self.path
return res
def load_from_dict(self, _dict: dict):
......
......@@ -90,13 +90,13 @@ class ScanFactory:
:return: instance of 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'
'', TomoScanBase._DICT_TYPE_KEY)
elif _dict[TomoScanBase._DICT_TYPE_KEY] == EDFTomoScan._TYPE:
'', TomoScanBase.DICT_TYPE_KEY)
elif _dict[TomoScanBase.DICT_TYPE_KEY] == EDFTomoScan._TYPE:
return EDFTomoScan(scan=None).load_from_dict(_dict)
else:
raise ValueError('Scan type', _dict[TomoScanBase._DICT_TYPE_KEY],
raise ValueError('Scan type', _dict[TomoScanBase.DICT_TYPE_KEY],
'is not managed')
@staticmethod
......@@ -117,9 +117,9 @@ class ScanFactory:
"""Create a ScanBase instance from a json description"""
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')
elif data[TomoScanBase._DICT_TYPE_KEY] == EDFTomoScan._TYPE:
elif data[TomoScanBase.DICT_TYPE_KEY] == EDFTomoScan._TYPE:
scan = EDFTomoScan(scan=None).load_from_dict(data)
return scan
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