Funcs
ph_from_json
ph_from_json(data)
Decode a JSON string or a Python dict using the Haystack JSON encoding defined
here to a PhKind (phable's
Python representation of a Project Haystack kind).
Example:
from phable import ph_from_json
data = {"equip": {"_kind": "marker"}}
ph_from_json(data)
# {"equip": Marker()}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | dict[str, typing.Any]
|
A JSON string or a Python dict using the Haystack JSON encoding. |
required |
Returns:
| Type | Description |
|---|---|
phable.kinds.PhKind
|
A |
Source code in src/phable/io/ph_json.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
ph_to_json_str
ph_to_json_str(data)
Encode a PhKind (phable's Python representation of a Project Haystack kind)
to a JSON string using the Haystack JSON encoding defined
here.
Example:
from phable import Marker, ph_to_json_str
data = {"equip": Marker()}
ph_to_json_str(data)
# '{"equip": {"_kind": "marker"}}'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
phable.kinds.PhKind
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the Haystack JSON encoding. |
Source code in src/phable/io/ph_json.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
ph_from_zinc
ph_from_zinc(data)
Decode a Zinc string using the Haystack Zinc encoding defined
here to a PhKind (phable's
Python representation of a Project Haystack kind).
Example:
from phable import ph_from_zinc
ph_from_zinc('{equip}')
# {"equip": Marker()}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
A Zinc string to decode. |
required |
Returns:
| Type | Description |
|---|---|
phable.kinds.PhKind
|
A |
Source code in src/phable/io/ph_zinc.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
ph_to_zinc
ph_to_zinc(data)
Encode a PhKind (phable's Python representation of a Project Haystack kind)
to a Zinc string using the Haystack Zinc encoding defined
here.
Example:
from phable import Marker, ph_to_zinc
data = {"equip": Marker()}
ph_to_zinc(data)
# '{equip}'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
phable.kinds.PhKind
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Zinc string representation of the Haystack Zinc encoding. |
Source code in src/phable/io/ph_zinc.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |