template_versioning
trestle.core.commands.author.versioning.template_versioning
¤
A Template Versioning.
Attributes¤
logger = logging.getLogger(__name__)
module-attribute
¤
Classes¤
TemplateVersioning
¤
Template versioning solution.
- Load template with a specified version.
- Template version can be specified via -tv flag
- If no version specified the latest version will be used by default.
- Otherwise use the templates from the specified version.
- Backward compatibility.
- Version 0.0.1 will be reserved for the template versions prior to this change.
- If the old template path is detected (i.e. without the template version). then the filesystem will be updated to the new path with the version.
- Upon first run, old template versions prior to this change will be placed to the folder 0.0.1.
- If templates have no headers then 0.0.1 version will be used.
- Versioning organization.
- Template and instance version is added both: in the file system (via path) and in the headers or metadata.
- Instance version validation.
- Markdown:
- When validating the instance the header will be used to validate the version.
- Drawio:
- When validating the instance the metadata will be used to validate the version.
- Markdown:
Source code in trestle/core/commands/author/versioning/template_versioning.py
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 |
|
Functions¤
get_all_versions_for_task(task_path)
staticmethod
¤
Get all versions for the task.
Source code in trestle/core/commands/author/versioning/template_versioning.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
get_latest_version_for_task(task_path)
staticmethod
¤
Get latest version of the template for the given task.
Source code in trestle/core/commands/author/versioning/template_versioning.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
get_versioned_template_dir(task_path, version=None)
staticmethod
¤
Get a template folder of the specified version.
If no version is given, the latest version of template will be returned
Source code in trestle/core/commands/author/versioning/template_versioning.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
is_valid_version(template_version)
staticmethod
¤
Check if the version format is correct.
Source code in trestle/core/commands/author/versioning/template_versioning.py
208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
update_template_folder_structure(task_path)
staticmethod
¤
Automatically detect whether the path is an old style and update it.
An old-style path is a path of the form
root_folder/.trestle/author/{template_name}/{template_objects}
The new version path is a path of the form: root_folder/.trestle/author/{template_name}/{version}/{template_objects} By default all old-style templates will be updated to version 0.0.1
Source code in trestle/core/commands/author/versioning/template_versioning.py
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 |
|
write_versioned_template(resource_name, task_path, target_file, version=None)
staticmethod
¤
Write a template with the header or metadata of a specified version.
If no version was given the latest version for the task will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_name
|
str
|
Template resource name |
required |
task_path
|
Path
|
Task path |
required |
target_file
|
Path
|
File path where template will be written |
required |
version
|
Optional[str]
|
return a resource of a specific version |
None
|
Returns:
Type | Description |
---|---|
None
|
A dotted path of a versioned template, list of all available versions |
Source code in trestle/core/commands/author/versioning/template_versioning.py
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 |
|
handler: python