qrcode module¶
Adds qrcode rendering
-
class
qrcode.
QrColumn
(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Bases:
marshmallow.schema.Schema
-
data
= <fields.String(default=<marshmallow.missing>, attribute=None, validate=None, required=False, load_only=False, dump_only=False, missing=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.', 'invalid': 'Not a valid string.', 'invalid_utf8': 'Not a valid utf-8 string.'})>¶
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
qrcode.
QrSchema
(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Bases:
marshmallow.schema.Schema
-
class
Meta
[source]¶ Bases:
object
-
render_module
¶ alias of
YamlRender
-
-
columns
= <fields.List(default=<marshmallow.missing>, attribute=None, validate=None, required=False, load_only=False, dump_only=False, missing=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.', 'invalid': 'Not a valid list.'})>¶
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
class
-
qrcode.
add_padding
(code: List[List[int]], width: int = 4) → List[List[int]][source]¶ Add
width
number of blocks of padding to the codeParameters: - code – The qrcode on/off image
- width – The amount of padding to add
-
qrcode.
blocks_to_squares
(blocks: List[List[int]]) → List[List[List[int]]][source]¶ Returns a list of list of blocks of four squares at a time. E.g.
blocks = [ [A, B, 1, 1], [C, D, 0, 1], ] # would return the list below containing a list of rows, with each # row being a list of squares [ [ [A, B, C, D], [1, 1, 0, 1] ] ]
In the returned squares, the square coords go:
- top-left
- top-right
- bottom-left
- bottom-right
Parameters: blocks – List of blocks to transform into squares
-
qrcode.
qrcode_ex
(data: dict) → urwid.container.Columns[source]¶ Handle the structured QR data (parsed from the YAML) to render QR codes for each defined column.
-
qrcode.
qrcode_raw_render
(data: str) → urwid.widget.Text[source]¶ Render the qrcode into an urwid.Text
Parameters: data – The data to encode in a qrcode and render
-
qrcode.
qrcode_render
(data: str, autocaption: bool = True, caption: str = None) → urwid.widget.Widget[source]¶ Render a qrcode.
Parameters: - data – The data to render as a qrcode
- autocaption – If caption should be added automatically
-
qrcode.
render_code
(token: Dict[KT, VT], body: urwid.widget.Widget, stack: List[urwid.widget.Widget], loop: urwid.main_loop.MainLoop)[source]¶ Main extension function that has first-chance at handling the
render_code
functionlookatme.render.markdown_block
This extension ignores all code blocks except ones with the language
qrcode
orqrcode-ex
.qrcode-ex
- Expects the contents of the code block to be yaml of the form:
columns: - data: "Data to be qr encoded" autocaption: true/false # optional caption: "Manual markdown caption" # optional
One or more columns may defined to render QR codes side-by-side
If
autocaption
is True andcaption
is None, the caption will be set to the data that is QR encoded.