semantics#

exception grave_settings.semantics.SymantecNotSupportedError[source]#

Bases: Exception

exception grave_settings.semantics.SymantecConfigurationInvalid[source]#

Bases: Exception

exception grave_settings.semantics.SecurityException[source]#

Bases: Exception

exception grave_settings.semantics.OmitMeError[source]#

Bases: Exception

raise this to retroactively refuse to be serialized as an attribute or dictionary key

class grave_settings.semantics.Negate(semantic)[source]#

Bases: object

semantic#
class grave_settings.semantics.Semantic(value)[source]#

Bases: Generic[T]

Semantics are meant to be “frozen” in that they do not change state after they have been initialized. They may be passed from context to context without respect for consistency or state and are expected to always have the same meaning no matter where and “when” they are.

Parameters:

value (T) –

COLLECTION: Type[set] | None = None#
C_T = ~C_T#
val#
collection_add(collection)[source]#
collection_remove(collection)[source]#
static collection_copy(collection)[source]#
Return type:

C_T

static collection_concatenate(first, second)[source]#
Parameters:
  • first (C_T) –

  • second (C_T) –

class grave_settings.semantics.Semantics(semantics=None)[source]#

Bases: object

Parameters:

semantics (dict[Type[~T_S], Union[~T_S, set[~T_S]]]) –

update(semantics)[source]#
Parameters:

semantics (Iterable[T_S_E]) –

add_semantics(*semantics)[source]#
Parameters:

semantics (T_S_E) –

get_semantic(semantic_class)[source]#
Parameters:

semantic_class (Type[T_S]) –

Return type:

T_S | list[~T_S] | None

pop(key)[source]#
Parameters:

key (Type[T_S]) –

remove_semantic(semantic)[source]#
Parameters:

semantic (Semantic) –

copy()[source]#
Return type:

Self

class grave_settings.semantics.SemanticContext(semantics)[source]#

Bases: Semantics

Parameters:

semantics (Semantics) –

add_frame_semantics(*semantic)[source]#
Parameters:

semantic (T_S_E) –

remove_frame_semantic(semantic)[source]#
Parameters:

semantic (Type[Semantic] | Semantic) –

add_semantics(*semantics)[source]#
Parameters:

semantics (T_S_E) –

get_semantic(semantic_class)[source]#
Parameters:

semantic_class (Type[T_S]) –

Return type:

T_S | list[~T_S] | None

remove_semantic(semantic)[source]#
Parameters:

semantic (Type[Semantic] | Semantic) –

copy_semantics()[source]#
context_push()[source]#
context_pop()[source]#
class grave_settings.semantics.IgnoreDuckTypingForType(value)[source]#

Bases: Semantic[Type]

Disables duck typing in the formatter for a specific class. This is to take care of naming clashes with types that happen to share the same name as the built-in methods

Parameters:

value (T) –

val#
class grave_settings.semantics.IgnoreDuckTypingForSubclasses(value)[source]#

Bases: Semantic[Type]

Disables duck typing in the formatter for a specific class. This is to take care of naming clashes with types that happen to share the same name as the built-in methods

Parameters:

value (T) –

val#
class grave_settings.semantics.OmitMe[source]#

Bases: Semantic

Used to inform that an object’s parent should not include this object as a member. It’s probably a bad idea to overuse this, but it is meant for flagging objects that should never be serialized or represented in an objects state

val#
class grave_settings.semantics.PreserveDictionaryOrdering(value)[source]#

Bases: Semantic[bool]

Keep the ordering of dictionary objects consistent between the format and the python object hierarchy

Parameters:

value (T) –

val#
class grave_settings.semantics.PreserveSerializableKeyOrdering(value)[source]#

Bases: Semantic[bool]

Similar to PreserveDictionaryOrdering but for serializable objects. This includes auto-serialized objects.

Parameters:

value (T) –

val#
class grave_settings.semantics.OverrideClassString(value)[source]#

Bases: Semantic[str]

The default class string is overriden by a custom value when serializing

Parameters:

value (T) –

val#
class grave_settings.semantics.SerializeNoneVersionInfo(value)[source]#

Bases: Semantic[bool]

If this is False then versioned objects that have null version information will not serialize their version information. The result is a cleaner file, but it is not always the case that null version information is the same as being unversioned

Parameters:

value (T) –

val#
class grave_settings.semantics.AutoKeySerializableDictType(value)[source]#

Bases: Semantic[Type]

Automatically scan dictionary objects to ensure their keys are serializable as native format keys. If not they are replaced by a wrapper type whose factory is supplied to this semantic’s constructor

Parameters:

value (T) –

val#
class grave_settings.semantics.Indentation(value)[source]#

Bases: Semantic[int]

Specified indentation formatting if applicable

Parameters:

value (T) –

val#
class grave_settings.semantics.AutoPreserveReferences(value)[source]#

Bases: Semantic[bool]

The formatter will keep track of objects that are referenced more than once in the object hierarchy and automatically convert subsequent instanced of the same object to a PreservedReference

Parameters:

value (T) –

val#
class grave_settings.semantics.EnforceReferenceLifecycle(value)[source]#

Bases: Semantic[bool]

Ensures that an object id that is used to cache an object for PreservedReferences is not re-used by the interpreter by maintaining a reference to all objects cached for the duration of the operation.

Parameters:

value (T) –

val#
class grave_settings.semantics.DetonateDanglingPreservedReferences(value)[source]#

Bases: Semantic[bool]

This will call a method that raises an exception if any tracked PreservedReference has not been flagged for garbage collection at the end of the deserialization process. It can be used to test if all the PreservedReference objects have been replaced by their correct reference since they should all be de-referenced by the end of the process.

Parameters:

value (T) –

val#
class grave_settings.semantics.ResolvePreservedReferences(value)[source]#

Bases: Semantic[bool]

Preserved References are resolved by the formatter and never given to the object. This may be slower. but it ensures that the object will never have a property set that is of type PreservedReference. When this is not present the formatter should not resolve the preserved references. Objects can resolve them by subscribing to the context objects

Parameters:

value (T) –

val#
class grave_settings.semantics.NotifyFinalizedMethodName(value)[source]#

Bases: Semantic[str]

This can be used as a frame semantic while de-serializing to get a callback on a method designated by the argument. The argument should be the method name as it is a member of the current object. The signature or the callback should match the signature of Serializable’s finalize method. currently: (self, id_map: dict) -> None:

The id_map will be a dictionary of reference ids to de-serialized objects. The references ids should be consistent with PreservedReference’s “ref” member variable.

Parameters:

value (T) –

val#
class grave_settings.semantics.DoNotAllowImportingModules(value)[source]#

Bases: Semantic[bool]

When de-serializing, do not import modules that are not currently loaded in the system path. This will disallow the loading of arbitrary python modules if they are not already loaded.

Parameters:

value (T) –

val#
class grave_settings.semantics.ClassStringPassFunction(value)[source]#

Bases: Semantic[Callable[[str], bool]]

Define a function that will return a boolean specifying the acceptability of a class path string. If the function returns false the class/module will not be imported, executed or instantiated and instead a SecurityException will be raised.

Parameters:

value (T) –

COLLECTION#

alias of set

val#
class grave_settings.semantics.KeySemanticsTemplate(value)[source]#

Bases: Semantic[dict[Any, Iterable[Semantic]]]

Parameters:

value (T) –

val#