qrcode module¶
Adds qrcode rendering
-
class
qrcode.QrColumn(*, only: Union[Sequence[str], Set[str]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: 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: str = None)[source]¶ Bases:
marshmallow.schema.Schema-
opts= <marshmallow.schema.SchemaOpts object>¶
-
-
class
qrcode.QrSchema(*, only: Union[Sequence[str], Set[str]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: 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: str = None)[source]¶ Bases:
marshmallow.schema.Schema-
class
Meta[source]¶ Bases:
object-
render_module¶ alias of
YamlRender
-
-
opts= <marshmallow.schema.SchemaOpts object>¶
-
class
-
qrcode.add_padding(code: List[List[int]], width: int = 4) → List[List[int]][source]¶ Add
widthnumber 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_codefunctionlookatme.render.markdown_blockThis extension ignores all code blocks except ones with the language
qrcodeorqrcode-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
autocaptionis True andcaptionis None, the caption will be set to the data that is QR encoded.