Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
b4eb8959
Commit
b4eb8959
authored
Feb 27, 2020
by
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
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/edfscan.py
View file @
b4eb8959
...
@@ -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
...
...
tomoscan/esrf/hdf5scan.py
View file @
b4eb8959
...
@@ -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
...
...
tomoscan/scanbase.py
View file @
b4eb8959
...
@@ -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
):
...
...
tomoscan/scanfactory.py
View file @
b4eb8959
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment