SnippetSet

class SnippetSet(snippets=<factory>)

Bases: Iterator[Snippet]

Mutable iterator and collection of snippets.

Attributes

snippets

Methods

to_dict()

Convert snippets to a hash-keyed dictionary.

write_json()

Convert the collection to JSON.

from_dict(data)

Create a snippet set from a hash-keyed dictionary.

Parameters:

snippets (List[Snippet])

index: int = 0
write_json()

Convert the collection to JSON.

Returns:

JSON representation of the snippets.

Parameters:

self (SnippetSet)

Return type:

str

to_dict()

Convert snippets to a hash-keyed dictionary.

Returns:

Dictionary of snippet payloads.

Parameters:

self (SnippetSet)

Return type:

Dict[str, Dict[str, Any]]

classmethod from_dict(data)

Create a snippet set from a hash-keyed dictionary.

Parameters:

data (Dict[str, Dict[str, Any]]) – Snippet payloads keyed by snippet hash.

Returns:

Parsed snippet set.

Return type:

SnippetSet