Behemoth v0.2.5
Changes:
- Atomisation of Build Parts
The build parts have been split up to be as atomic as possible. This will give users more control over which data they wish to use, and generally make the system more configurable and maintainable.
Old
- build_deck_parts:
- from_crowd_anki:
folder: brain_brew_build/Ultimate Geography/
notes:
part_id: standard notes
sort_order: [Country]
save_to_file: src/deck_parts/notes/english.yaml
note_models:
- part_id: Ultimate Geography
save_to_file: src/deck_parts/note_models/Ultimate Geography.yaml
headers:
part_id: default
save_to_file: src/deck_parts/headers/default.yaml
media:
from_notes: true
from_note_models: true
New
- build_parts:
- notes_from_crowd_anki:
source: brain_brew_build/Ultimate Geography/
part_id: standard notes
sort_order: [Country]
save_to_file: src/deck_parts/notes/english.yaml
- note_models_from_crowd_anki:
source: brain_brew_build/Ultimate Geography/
part_id: Ultimate Geography
save_to_file: src/deck_parts/note_models/Ultimate Geography.yaml
- headers_from_crowd_anki:
source: brain_brew_build/Ultimate Geography/
part_id: default
save_to_file: src/deck_parts/headers/default.yaml
- media_group_from_crowd_anki:
source: brain_brew_build/Ultimate Geography/
part_id: all_anki_media
- save_media_group_to_folder:
parts: [all_anki_media]
folder: src/deck_parts/media
clear_folder: false
Each build task is also override-able with a list of itself, to be concise and keep readability. As in the following example:
- note_model_templates_from_html:
part_id: Country - Capital
html_file: src/deck_parts/note_models/templates/Country - Capital.html
- note_model_templates_from_html:
part_id: Capital - Country
html_file: src/deck_parts/note_models/templates/Capital - Country.html
- note_model_templates_from_html:
part_id: Country - Flag
html_file: src/deck_parts/note_models/templates/Country - Flag.html
is equivalent to
- note_model_templates_from_html:
- part_id: Country - Capital
html_file: src/deck_parts/note_models/templates/Country - Capital.html
- part_id: Capital - Country
html_file: src/deck_parts/note_models/templates/Capital - Country.html
- part_id: Country - Flag
html_file: src/deck_parts/note_models/templates/Country - Flag.html
The more entries you have, the better it is to group them together as a list. Though it is entirely optional.
- Note Model can now be created from individual CSS and Html files using the new
note_model_from_html_parts
andnote_model_templates_from_html
part builders.
Note Templates are made up of a single Html, with a --
as a separator for the front and back template.
{{Front}}
--
{{Back}}
And that is read in like so:
- note_model_templates_from_html:
- part_id: Country - Capital
html_file: src/deck_parts/note_models/templates/Country - Capital.html
- part_id: Capital - Country
html_file: src/deck_parts/note_models/templates/Capital - Country.html
#browser_html_file: otherfile.html
#template_name: override_name_for_template_that_isnt_the_part_name
- note_model_from_html_parts:
part_id: Ultimate Geography
model_name: Ultimate Geography
model_id: 43e2586a-9a65-11e8-a777-a0481cc15658
css_file: src/deck_parts/note_models/style.css <------------ CSS File
fields:
- name: Country
font: Arial
- name: Country info
font: Arial
- name: Capital
font: Arial
- name: Capital info
font: Arial
- name: Capital hint
font: Arial
- name: Flag
font: Arial
- name: Flag similarity
font: Arial
- name: Map
font: Arial
templates: <-------------- List of templates created in previous step
- Country - Capital
- Capital - Country
- Country - Flag
- Country - Map
This allows for a lot of flexibility in with which templates or fields to use.
- Similar to above, Deck Description can now be taken from a HTML file
- headers_from_yaml_part:
- part_id: default header
file: src/deck_parts/headers/default.yaml
override:
deck_description_html_file: src/deck_parts/headers/desc.html <------ Html file
- Media Group is now a build part, which can read all the files from any arbitrary folder. It also supports recursion, to find files in any subfolders, as well as a whitelist / blacklist optional filter which takes any previously created Media Group
- media_group_from_folder:
- part_id: all_media
source: src/deck_parts/media
recursive: true
# filter_whitelist_from_parts: other_part_name
´crowdanki_generate` now takes a list of MediaGroups which are combined and added into the Crowd Anki Export.
- Yamale is now used for Yaml Validation for user written recipes. This will give users much better feedback if their Yaml is incorrect (not what Brain Brew was expecting). Validation is run before any recipe parts are executed, and can be done exclusively using the
-v
option, so no recipes should break mid-run.
What this means for contributors (Click!)
Contributors who wish to make their own deck parts and have them be recognised as build tasks can simply:
- Choose whether your task is a
TopLevelBuildTask
orBuildPartTask
- Create a new class which inherits that task type
- Add your new class to the
yamale_dependencies
of that Task type - Implement the below functions, which are required by the parent
task_regex
is optional, if one wishes to have multiple matches for your task name. The abovetask_name
will be used instead if it does not exist.yamale_dependencies
is also optional, but should be used if youryamale_schema
contains any other Yaml objects. Items here will be included automatically in any other task that uses your task.
- Run the
scripts/yamale_build.py
script. This will add your yamale schema (and all of it's dependencies) into theschemas/recipes.yaml
file, which contains the commands recognised by the Yamale validation.
E.g. class:
@dataclass
class NotesFromCsvs(SharedBaseCsvs, BuildPartTask):
@classmethod
def task_name(cls) -> str:
return r'notes_from_csvs'
@classmethod
def task_regex(cls) -> str:
return r'notes_from_csv[s]?'
@classmethod
def yamale_schema(cls) -> str:
return f'''\
part_id: str()
save_to_file: str(required=False)
note_model_mappings: list(include('{NoteModelMapping.task_name()}'))
file_mappings: list(include('{FileMapping.task_name()}'))
'''
@classmethod
def yamale_dependencies(cls) -> set:
return {NoteModelMapping, FileMapping}
Install with Pip from PyPi: https://pypi.org/project/Brain-Brew/0.2.4/
Created with the support of my lovely Patreons.