Renderer
Renderer
This module provides utilities for rendering data in various formats, specifically focusing on rendering Volatility framework data into JSON and pandas DataFrames.
Classes:
Name | Description |
---|---|
TreeGrid_to_json |
A class for rendering Volatility TreeGrid data into JSON format. |
Renderer |
A class for rendering data into human-readable formats such as lists, JSON strings, and pandas DataFrames. |
Renderer
Class for rendering data in various formats.
This class provides methods to render data into human-readable formats such as lists, JSON strings, and pandas DataFrames.
Attributes:
Name | Type | Description |
---|---|---|
data |
Any
|
The input data to be rendered. |
Source code in pydfirram/core/renderer.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
__init__(data)
Initialize the Renderer with the provided data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Any
|
The input data to be rendered. |
required |
Source code in pydfirram/core/renderer.py
151 152 153 154 155 156 157 158 |
|
file_render()
Convert the data to a list format.
This method attempts to render the input data using the TreeGrid_to_json class, and convert it to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
Dict |
None
|
The rendered data in list format. |
Raises:
Type | Description |
---|---|
Exception
|
If rendering the data fails. |
Source code in pydfirram/core/renderer.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
to_df(max_row=False)
Convert the data to a pandas DataFrame.
This method first converts the data to a list format, and then constructs a pandas DataFrame from it.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: The data as a pandas DataFrame. |
Raises:
Type | Description |
---|---|
Exception
|
If rendering the data as a DataFrame fails. |
Source code in pydfirram/core/renderer.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
to_json()
Convert the data to a JSON string.
This method first converts the data to a list format, and then serializes it to a JSON string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The data serialized as a JSON string. |
Raises:
Type | Description |
---|---|
Exception
|
If converting the data to JSON fails. |
Source code in pydfirram/core/renderer.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
to_list()
Convert the data to a list format.
This method attempts to render the input data using the TreeGrid_to_json class, and convert it to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
Dict |
The rendered data in list format. |
Raises:
Type | Description |
---|---|
Exception
|
If rendering the data fails. |
Source code in pydfirram/core/renderer.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
TreeGrid_to_json
Bases: CLIRenderer
simple TreeGrid to JSON
Source code in pydfirram/core/renderer.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
get_render_options()
Get render options.
Source code in pydfirram/core/renderer.py
68 69 70 71 72 |
|
render(grid)
Render the TreeGrid to JSON format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid |
TreeGrid
|
The TreeGrid to render. |
required |
Returns:
Name | Type | Description |
---|---|---|
Dict |
dict[str, Any]
|
The JSON representation of the TreeGrid. |
Source code in pydfirram/core/renderer.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|