Funcs
ph_from_json
ph_from_json(data)
Decode a Python dict using the Haystack JSON encoding defined here to 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
|
dict[str, typing.Any]
|
A Python dict using the Haystack JSON encoding. |
required |
Returns:
| Type | Description |
|---|---|
phable.kinds.PhKind
|
A Project Haystack kind. |
Source code in src/phable/utils.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
ph_to_json
ph_to_json(data)
Encode a Project Haystack kind to a Python dict using the Haystack JSON encoding defined here.
Example:
from phable import Marker, ph_to_json
data = {"equip": Marker()}
ph_to_json(data)
# {"equip": {"_kind": "marker"}}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
phable.kinds.PhKind
|
A Project Haystack kind to encode. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
A Python dict representation of the Haystack JSON encoding. |
Source code in src/phable/utils.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
ph_from_zinc
ph_from_zinc(data)
Decode a Zinc string using the Haystack Zinc encoding defined here to 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 Project Haystack kind. |
Source code in src/phable/utils.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
ph_to_zinc
ph_to_zinc(data)
Encode 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 Project Haystack kind to encode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Zinc string representation of the Project Haystack kind. |
Source code in src/phable/utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |