<s> """<STR_LIT>""" <EOL> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> import os <EOL> import base64 <EOL> from lino_xl . lib . beid import Plugin as BeIdPlugin <EOL> class Plugin ( BeIdPlugin ) : <EOL> site_js_snippets = [ '<STR_LIT>' ] <EOL> media_name = '<STR_LIT>' <EOL> media_base_url = "<STR_LIT:?>" <EOL> media_root = None <EOL> """<STR_LIT>""" <EOL> def get_js_includes ( self , settings , language ) : <EOL> yield self . build_media_url ( '<STR_LIT>' ) <EOL> yield self . build_media_url ( '<STR_LIT>' ) <EOL> def get_body_lines ( self , site , request ) : <EOL> p = self . build_media_url ( ) <EOL> p = request . build_absolute_uri ( p ) <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' % p <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' + p + '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> yield '<STR_LIT>' <EOL> def card2client ( cls , data ) : <EOL> "<STR_LIT>" <EOL> self = cls <EOL> from lino . utils import ssin <EOL> from lino . api import dd , rt <EOL> from lino . mixins . beid import BeIdCardTypes <EOL> from lino . utils import join_words <EOL> from lino . utils import IncompleteDate <EOL> from lino . modlib . contacts . utils import street2kw <EOL> countries = dd . resolve_app ( '<STR_LIT>' , strict = True ) <EOL> kw = dict ( ) <EOL> kw . update ( national_id = ssin . format_ssin ( data [ '<STR_LIT>' ] ) ) <EOL> kw . update ( first_name = join_words ( <EOL> data [ '<STR_LIT>' ] , <EOL> data [ '<STR_LIT>' ] , <EOL> data [ '<STR_LIT>' ] ) ) <EOL> kw . update ( last_name = data [ '<STR_LIT>' ] ) <EOL> card_number = data [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in data : <EOL> fn = self . card_number_to_picture_file ( card_number ) <EOL> if os . path . exists ( fn ) : <EOL> logger . warning ( "<STR_LIT>" , fn ) <EOL> fp = file ( fn , '<STR_LIT:wb>' ) <EOL> fp . write ( base64 . b64decode ( data [ '<STR_LIT>' ] ) ) <EOL> fp . close ( ) <EOL> kw . update ( birth_date = IncompleteDate ( <EOL> * settings . SITE . parse_date ( data [ '<STR_LIT>' ] ) ) ) <EOL> kw . update ( card_valid_from = datetime . date ( <EOL> * settings . SITE . parse_date ( data [ '<STR_LIT>' ] ) ) ) <EOL> kw . update ( card_valid_until = datetime . date ( <EOL> * settings . SITE . parse_date ( data [ '<STR_LIT>' ] ) ) ) <EOL> kw . update ( card_number = card_number ) <EOL> kw . update ( card_issuer = data [ '<STR_LIT>' ] ) <EOL> kw . update ( noble_condition = data [ '<STR_LIT>' ] ) <EOL> kw . update ( street = data [ '<STR_LIT>' ] ) <EOL> kw . update ( street_no = data [ '<STR_LIT>' ] ) <EOL> kw . update ( street_box = data [ '<STR_LIT>' ] ) <EOL> if kw [ '<STR_LIT>' ] and not ( kw [ '<STR_LIT>' ] or kw [ '<STR_LIT>' ] ) : <EOL> kw = street2kw ( kw [ '<STR_LIT>' ] , ** kw ) <EOL> kw . update ( zip_code = data [ '<STR_LIT>' ] ) <EOL> kw . update ( birth_place = data [ '<STR_LIT>' ] ) <EOL> pk = data [ '<STR_LIT>' ] . upper ( ) <EOL> msg1 = "<STR_LIT>" % kw . get ( '<STR_LIT>' ) <EOL> country = countries . Country . objects . get ( isocode = pk ) <EOL> kw . update ( country = country ) <EOL> kw . update ( city = countries . Place . lookup_or_create ( <EOL> '<STR_LIT:name>' , data [ '<STR_LIT>' ] , country = country ) ) <EOL> def sex2gender ( sex ) : <EOL> if sex == '<STR_LIT:M>' : <EOL> return dd . Genders . male <EOL> if sex in '<STR_LIT>' : <EOL> return dd . Genders . female <EOL> logger . warning ( "<STR_LIT>" , msg1 , sex ) <EOL> kw . update ( gender = sex2gender ( data [ '<STR_LIT>' ] ) ) <EOL> if False : <EOL> def nationality2country ( nationality ) : <EOL> try : <EOL> return countries . Country . objects . get ( <EOL> nationalities__icontains = nationality ) <EOL> except countries . Country . DoesNotExist , e : <EOL> logger . warning ( "<STR_LIT>" , <EOL> msg1 , nationality ) <EOL> except MultipleObjectsReturned , e : <EOL> logger . warning ( <EOL> "<STR_LIT>" , <EOL> msg1 , nationality ) <EOL> kw . update ( nationality = nationality2country ( data [ '<STR_LIT>' ] ) ) <EOL> def doctype2cardtype ( dt ) : <EOL> return BeIdCardTypes . get_by_value ( str ( dt ) ) <EOL> kw . update ( card_type = doctype2cardtype ( data [ '<STR_LIT>' ] ) ) <EOL> return kw </s>
