The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiConfig2.semantics.JSONSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.JSONSemantics:
Collaboration diagram for GaudiConfig2.semantics.JSONSemantics:

Public Member Functions

 default (self, value)
 load (self, value)
 store (self, value)
 is_set (self, value)
 opt_value (self, value)
Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
 __init__ (self, cpp_type)
 name (self)
 name (self, value)
 cpp_type (self)
 cpp_type (self, value)
 merge (self, a, b)

Static Protected Member Functions

 _normalize (value)

Static Private Attributes

tuple __handled_types__

Additional Inherited Members

Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type = cpp_type
Protected Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 _name = None
 _cpp_type = value

Detailed Description

Definition at line 149 of file semantics.py.

Member Function Documentation

◆ _normalize()

GaudiConfig2.semantics.JSONSemantics._normalize ( value)
staticprotected

Definition at line 156 of file semantics.py.

156 def _normalize(value):
157 return json.loads(json.dumps(value, allow_nan=False))
158

◆ default()

GaudiConfig2.semantics.JSONSemantics.default ( self,
value )

Definition at line 159 of file semantics.py.

159 def default(self, value):
160 data = json.loads(value) if isinstance(value, str) else self._normalize(value)
161 return _JSONValue(data, False)
162

◆ is_set()

GaudiConfig2.semantics.JSONSemantics.is_set ( self,
value )
Allow overriding the definition of "is set" if we need helper types.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 169 of file semantics.py.

169 def is_set(self, value):
170 return value.explicitly_set or value.data != value.default
171

◆ load()

GaudiConfig2.semantics.JSONSemantics.load ( self,
value )
Transformation for data when reading the property.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 163 of file semantics.py.

163 def load(self, value):
164 return value.data
165

◆ opt_value()

GaudiConfig2.semantics.JSONSemantics.opt_value ( self,
value )
Option string version of value.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 172 of file semantics.py.

172 def opt_value(self, value):
173 if not isinstance(value, _JSONValue):
174 value = self.default(value)
175 return _JSONOption(
176 json.dumps(
177 value.data, allow_nan=False, separators=(",", ":"), sort_keys=True
178 )
179 )
180
181

◆ store()

GaudiConfig2.semantics.JSONSemantics.store ( self,
value )
Validation/transformation of the data to be stored.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 166 of file semantics.py.

166 def store(self, value):
167 return _JSONValue(self._normalize(value), True)
168

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.JSONSemantics.__handled_types__
staticprivate
Initial value:
= (
"nlohmann::json",
re.compile(r"nlohmann::(?:json_abi[^:]*::)?basic_json<.*>$"),
)

Definition at line 150 of file semantics.py.


The documentation for this class was generated from the following file: