Пример #1
0
 def make_image(self, image_factory=None, **kw):
     check_valid_scale(self.box_size)
     check_valid_border(self.border)
     if self.data_cache is None:
         self.make()
     image_factory = image_factory or self.image_factory
     _check_valid_factory(image_factory)
     if image_factory is None or image_factory.kind in ('PNG', 'EPS', 'PDF',
                                                        'SVG'):
         config = dict(scale=self.box_size, border=self.border)
         kind = None
         if image_factory is not None:
             kind = image_factory.kind
             try:
                 config.update(image_factory.config)
             except AttributeError:
                 pass
             try:
                 config['background'] = image_factory.background
             except AttributeError:
                 pass
         return _Image(self.segno_qrcode, config, kind)
     im = image_factory(self.border, self.modules_count, self.box_size,
                        **kw)
     for r in range(self.modules_count):
         for c in range(self.modules_count):
             if self.modules[r][c]:
                 im.drawrect(r, c)
     return im
Пример #2
0
 def make_image(self, image_factory=None, **kw):
     check_valid_scale(self.box_size)
     check_valid_border(self.border)
     if self.data_cache is None:
         self.make()
     image_factory = image_factory or self.image_factory
     _check_valid_factory(image_factory)
     if image_factory is None or image_factory.kind in ('PNG', 'EPS', 'PDF', 'SVG'):
         config = dict(scale=self.box_size, border=self.border)
         kind = None
         if image_factory is not None:
             kind = image_factory.kind
             try:
                 config.update(image_factory.config)
             except AttributeError:
                 pass
             try:
                 config['background'] = image_factory.background
             except AttributeError:
                 pass
         return _Image(self.segno_qrcode, config, kind)
     im = image_factory(self.border, self.modules_count, self.box_size, **kw)
     for r in range(self.modules_count):
         for c in range(self.modules_count):
             if self.modules[r][c]:
                 im.drawrect(r, c)
     return im
Пример #3
0
 def __init__(self, version=None, error_correction=constants.ERROR_CORRECT_M,
              box_size=10, border=4, image_factory=None):
     check_valid_scale(box_size)
     self.version = version and int(version)
     self.error_correction = int(error_correction)
     self.box_size = int(box_size)
     self.border = int(border)
     self.image_factory = image_factory
     _check_valid_factory(image_factory)
     self.clear()
Пример #4
0
 def __init__(self,
              version=None,
              error_correction=constants.ERROR_CORRECT_M,
              box_size=10,
              border=4,
              image_factory=None):
     check_valid_scale(box_size)
     self.version = version and int(version)
     self.error_correction = int(error_correction)
     self.box_size = int(box_size)
     self.border = int(border)
     self.image_factory = image_factory
     _check_valid_factory(image_factory)
     self.clear()
Пример #5
0
def test_invalid_scale(scale):
    with pytest.raises(ValueError):
        utils.check_valid_scale(scale)
Пример #6
0
def test_valid_scale(scale):
    assert utils.check_valid_scale(scale) is None