From d88289ff3f8aec6c22e9091796f668ea3144d4cb Mon Sep 17 00:00:00 2001 From: Valentin Berlier Date: Tue, 10 Oct 2023 01:46:50 +0200 Subject: [PATCH] fix: handle missing directive --- lectern/contrib/relative_location.py | 2 +- lectern/contrib/yaml_to_json.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lectern/contrib/relative_location.py b/lectern/contrib/relative_location.py index f606b94..28f6bc5 100644 --- a/lectern/contrib/relative_location.py +++ b/lectern/contrib/relative_location.py @@ -30,7 +30,7 @@ def __call__( fragment: Fragment, directives: Mapping[str, Directive], ) -> Fragment: - if isinstance(directives[fragment.directive], NamespacedResourceDirective): + if isinstance(directives.get(fragment.directive), NamespacedResourceDirective): name = fragment.expect("name") if ":" not in name: fragment = replace(fragment, arguments=[self.ctx.generate.path(name)]) diff --git a/lectern/contrib/yaml_to_json.py b/lectern/contrib/yaml_to_json.py index 5a82ccb..ad4573b 100644 --- a/lectern/contrib/yaml_to_json.py +++ b/lectern/contrib/yaml_to_json.py @@ -29,7 +29,7 @@ def beet_default(ctx: Context): def handle_yaml(fragment: Fragment, directives: Mapping[str, Directive]) -> Fragment: """Loader that converts yaml to json.""" - directive = directives[fragment.directive] + directive = directives.get(fragment.directive) is_yaml = False if isinstance(directive, NamespacedResourceDirective):