/usr/share/pyshared/qrcode/image/pure.py is in python-qrcode 4.0.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from pymaging import Image
from pymaging.colors import RGB
from pymaging.formats import registry
from pymaging.shapes import Line
from pymaging.webcolors import Black, White
from pymaging_png.png import PNG
import qrcode.image.base
class PymagingImage(qrcode.image.base.BaseImage):
"""
pymaging image builder, default format is PNG.
"""
kind = "PNG"
allowed_kinds = ("PNG",)
def __init__(self, *args, **kwargs):
"""
Register PNG with pymaging.
"""
registry.formats = []
registry.names = {}
registry._populate()
registry.register(PNG)
super(PymagingImage, self).__init__(*args, **kwargs)
def new_image(self, **kwargs):
return Image.new(RGB, self.pixel_size, self.pixel_size, White)
def drawrect(self, row, col):
(x, y), (x2, y2) = self.pixel_box(row, col)
for r in range(self.box_size):
line_y = y + r
line = Line(x, line_y, x2, line_y)
self._img.draw(line, Black)
def save(self, stream, kind=None):
self._img.save(stream, self.check_kind(kind))
def check_kind(self, kind, transform=None, **kwargs):
"""
pymaging (pymaging_png at least) uses lower case for the type.
"""
if transform is None:
transform = lambda x: x.lower()
return super(PymagingImage, self).check_kind(
kind, transform=transform, **kwargs)
|