Scheme Serialization (readwrite
)¶
Scheme save/load routines.
- orangecanvas.scheme.readwrite.dumps(obj, format='literal', prettyprint=False, pickle_fallback=False)[source]¶
Serialize obj using format (‘json’ or ‘literal’) and return its string representation and the used serialization format (‘literal’, ‘json’ or ‘pickle’).
If pickle_fallback is True and the serialization with format fails object’s pickle representation will be returned
- orangecanvas.scheme.readwrite.indent(element, level=0, indent='\t')[source]¶
Indent an instance of a
Element
. Based on (http://effbot.org/zone/element-lib.htm#prettyprint).
- orangecanvas.scheme.readwrite.literal_dumps(obj, indent=None, relaxed_types=True)[source]¶
Write obj into a string as a python literal.
Note
set
objects are not supported as the empty set is not representable as a literal.- Parameters
obj (Any) –
indent (Optional[int]) – If not None then it is the indent for the pretty printer.
relaxed_types (bool) –
Relaxed type checking. In addition to exact builtin numeric types, the numbers.Integer, numbers.Real are checked and allowed if their repr matches that of the builtin.
Warning
The exact type of the values will be lost.
- Returns
repr – String representation of obj
- Return type
See also
- Raises
TypeError – If obj contains non builtin types that cannot be represented as a literal value.
ValueError – If obj is a recursive structure.
- orangecanvas.scheme.readwrite.parse_ows_etree_v_2_0(tree)[source]¶
Parset an xml.etree.ElementTree struct into a intermediate workflow representation.
- orangecanvas.scheme.readwrite.scheme_to_etree(scheme, data_format='literal', pickle_fallback=False)[source]¶
Return an xml.etree.ElementTree representation of the scheme.
- orangecanvas.scheme.readwrite.scheme_to_ows_stream(scheme, stream, pretty=False, pickle_fallback=False)[source]¶
Write scheme to a a stream in Orange Scheme .ows (v 2.0) format.
- Parameters
stream (file-like object) – A file-like object opened for writing.
pretty (bool, optional) – If True the output xml will be pretty printed (indented).
pickle_fallback (bool, optional) – If True allow scheme node properties to be saves using pickle protocol if properties cannot be saved using the default notation.
- orangecanvas.scheme.readwrite.string_eval(source)[source]¶
Evaluate a python string literal source. Raise ValueError if source is not a string literal.
>>> string_eval("'a string'") a string