steenzout.barcode.base module

Base bar code module.

class Barcode(code, writer=None)[source]

Bases: steenzout.object.Object

Base bar code class.

__repr__()[source]

Returns the canonical string representation of the object.

Returns:the canonical string representation of the object.
Return type:(str)
build()[source]
Returns:
Return type:(str)
classmethod calculate_checksum(code)[source]

Calculates a bar code checksum.

Parameters:code (str) – the code.
Returns:the checksum.
Return type:(integer)
checksum

(int): bar code checksum.

code

(str): bar code.

digits = 0
get_fullcode()[source]

Returns the full code, encoded in the barcode.

Returns:Full human readable code.
Return type:(str)
name = ''
raw = None
render(writer_options=None)[source]

Renders the barcode using self.writer.

Parameters:writer_options (dict) – options for self.writer, see writer docs for details.
Returns:output of the writer’s render method.
save(filename, options=None)[source]

Renders the barcode and saves it in filename.

Parameters:
  • filename (str) – filename to save the barcode in (without filename extension).
  • options (dict) – the same as in :py:func:`self.render.
Returns:

Filename with extension.

Return type:

(str)

to_ascii()[source]

Returns ASCII representation of the bar code.

Returns:ASCII representation of the bar code.
Return type:(str)
classmethod validate(code)[source]

Validates the given bar code.

write(fp, options=None)[source]

Renders the barcode and writes it to the file like object fp.

Parameters:
  • fp – File like object object to write the raw data in.
  • options (dict) – the same as in :py:func:`self.render.
writer

(steenzout.barcode.writer.Interface): writer instance.