ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaConfiguration
python
iconfTool
utils
serialization.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2
import
logging
3
import
pickle
4
from
typing
import
Any, Set
5
6
logger = logging.getLogger(__name__)
7
8
9
def
save_object
(file_path: str, obj: Any) ->
None
:
10
logger.info(f
"Saving object of type {type(obj)} to {file_path}"
)
11
with
open(file_path,
"wb"
)
as
f:
12
pickle.dump(obj, f)
13
14
15
def
load_strings_set
(file_path: str) -> Set[str]:
16
logger.info(f
"Loading {file_path}"
)
17
with
open(file_path,
"rb"
)
as
f:
18
s: Set[str] = pickle.load(f)
19
if
not
isinstance(s, set):
20
msg = f
"Saved object is not a set. Type: {type(s)}"
21
logger.error(msg)
22
raise
TypeError(msg)
23
for
element
in
s:
24
if
not
isinstance(element, str):
25
msg = f
"Set element is not a string. Type: {type(element)}"
26
logger.error(msg)
27
raise
TypeError(msg)
28
return
s
python.iconfTool.utils.serialization.load_strings_set
Set[str] load_strings_set(str file_path)
Definition
serialization.py:15
python.iconfTool.utils.serialization.save_object
None save_object(str file_path, Any obj)
Definition
serialization.py:9
Generated on
for ATLAS Offline Software by
1.17.0