from barcode import generate


class BankBarcode(object):

    def _check_length(self, name, value, expected_length, description):
        length = len(value)
        if length < expected_length:
            raise ValueError('{} is too short, {}'.format(name, description))
        elif length > expected_length:
            raise ValueError('{} is too long, {}'.format(name, description))
        elif length == expected_length:
            return True

    def code(self):
        raise NotImplementedError('This method is not implemented!')

    def save(self, path):
        writer_options = {'font_size': 6}
        generate(
            'code128',
            self.code(),
            output=path,
            writer_options=writer_options
        )

@@ -50,16 +50,60 @@
 object):
+%0A    %22%22%22%0A    Base class for barcodes%0A    %22%22%22
 %0A%0A    de
@@ -168,16 +168,351 @@
 ption):%0A
+        %22%22%22%0A        Check length of a value.%0A%0A        :param name: name of the value%0A        :param value: the value itself%0A        :param expected_length: the expected lenght of the value%0A        :param description: definition of the expected value%0A        :return: True if value have the expected lenght, otherwise False%0A        %22%22%22%0A
         
@@ -847,16 +847,95 @@
 (self):%0A
+        %22%22%22%0A        Code generation. To implement in child classes%0A        %22%22%22%0A
         
@@ -1022,16 +1022,140 @@
  path):%0A
+        %22%22%22%0A        Save barcode in SVG format.%0A%0A        :param path: path to SVG file without %22.svg%22 extension%0A        %22%22%22%0A
         

document BankBarcode