lookatme.contrib.file_loader module

This module defines a built-in contrib module that enables external files to be included within the slide. This is extremely useful when having source code displayed in a code block, and then running/doing something with the source data in a terminal on the same slide.

class lookatme.contrib.file_loader.FileSchema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]

Bases: marshmallow.schema.Schema

class Meta[source]

Bases: object

render_module

alias of YamlRender

load(*args, **kwargs) → Dict[KT, VT][source]

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data – The data to deserialize.
  • many – Whether to deserialize data as a collection. If None, the value for self.many is used.
  • partial – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
  • unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
Returns:

Deserialized data

New in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(*args, **kwargs) → Dict[KT, VT][source]

Same as load(), except it takes a JSON string as input.

Parameters:
  • json_data – A JSON string of the data to deserialize.
  • many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
  • partial – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
  • unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
Returns:

Deserialized data

New in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

opts = <marshmallow.schema.SchemaOpts object>
class lookatme.contrib.file_loader.LineRange(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]

Bases: marshmallow.schema.Schema

opts = <marshmallow.schema.SchemaOpts object>
class lookatme.contrib.file_loader.YamlRender[source]

Bases: object

static dumps(data)[source]
static loads(data)[source]
lookatme.contrib.file_loader.render_code(token, body, stack, loop)[source]

Render the code, ignoring all code blocks except ones with the language set to file.

lookatme.contrib.file_loader.transform_data(transform_shell_cmd, input_data)[source]

Transform the input_data using the transform_shell_cmd shell command.

lookatme.contrib.file_loader.user_warnings()[source]

Provide warnings to the user that loading this extension may cause shell commands specified in the markdown to be run.