Yaml spec
YamlSpec
¶
Bases: ABC
Object for handling yaml spec files: Powers, Bestiary, etc
Source code in automation/templates/yaml_spec.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 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 138 139 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 |
|
__init__(input_files)
¶
Takes input files, loads raw data, gets stem and name for saving
If file not found at input_file relative path, adds ./automation/_input/
Source code in automation/templates/yaml_spec.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 54 55 56 57 58 59 |
|
categories()
abstractmethod
¶
{(hierarchy tuple): [List of names]} dict
Source code in automation/templates/yaml_spec.py
118 119 120 121 |
|
type_dict: dict
property
¶
Cache of items by type e.g. {Major: [a, b]}
category_hierarchy: list[tuple[str, int, tuple]]
property
¶
List of tuples containing (item, indentation, and set of (sub)-categories)
Returns:
Type | Description |
---|---|
list[tuple[str, int, tuple]]
|
list[tuple]: [(item, indent, (category, subcategory, sub-sub, etc.))] |
md_TOC: str
property
¶
Generate markdown Table of Contents with category_hierarchy
make_entries(category_set)
¶
All entries into bulleted lists with key prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
category_set |
set
|
unique set of categories (category, subcategory) |
required |
Source code in automation/templates/yaml_spec.py
166 167 168 169 170 171 172 173 174 |
|
write_md(output_fp=None, TOC=False)
¶
Write markdown
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_fp |
str
|
relative path for writing output file. Default None meaning save to ../docs/src/1_Mechanics/ path with same file name |
None
|
TOC |
bool
|
Write table of contents. Default False |
False
|
Source code in automation/templates/yaml_spec.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
csv_fields()
abstractmethod
¶
Column names for csv
Returns:
Name | Type | Description |
---|---|---|
fields |
list
|
list of column headers for CSV |
Source code in automation/templates/yaml_spec.py
201 202 203 204 205 206 207 |
|
write_csv(output_fp=None, delimiter='\t')
¶
Write CSV from YAML, default is tab-delimited
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_fp |
str
|
relative filepath. Default none, which means local _output subfolder |
None
|
delimiter |
str
|
column delimiter. |
'\t'
|
Source code in automation/templates/yaml_spec.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|