<s> from pymaging import Image <EOL> from pymaging . colors import RGB <EOL> from pymaging . formats import registry <EOL> from pymaging . shapes import Line <EOL> from pymaging . webcolors import Black , White <EOL> from pymaging_png . png import PNG <EOL> import qrcode . image . base <EOL> class PymagingImage ( qrcode . image . base . BaseImage ) : <EOL> """<STR_LIT>""" <EOL> kind = "<STR_LIT>" <EOL> allowed_kinds = ( "<STR_LIT>" , ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> registry . formats = [ ] <EOL> registry . names = { } <EOL> registry . _populate ( ) <EOL> registry . register ( PNG ) <EOL> super ( PymagingImage , self ) . __init__ ( * args , ** kwargs ) <EOL> def new_image ( self , ** kwargs ) : <EOL> return Image . new ( RGB , self . pixel_size , self . pixel_size , White ) <EOL> def drawrect ( self , row , col ) : <EOL> ( x , y ) , ( x2 , y2 ) = self . pixel_box ( row , col ) <EOL> for r in range ( self . box_size ) : <EOL> line_y = y + r <EOL> line = Line ( x , line_y , x2 , line_y ) <EOL> self . _img . draw ( line , Black ) <EOL> def save ( self , stream , kind = None ) : <EOL> self . _img . save ( stream , self . check_kind ( kind ) ) <EOL> def check_kind ( self , kind , transform = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if transform is None : <EOL> transform = lambda x : x . lower ( ) <EOL> return super ( PymagingImage , self ) . check_kind ( <EOL> kind , transform = transform , ** kwargs ) </s>
