-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from eidreader.main import eid2dict | ||
import base64 | ||
|
||
|
||
def get_eid_data(): | ||
return eid2dict() | ||
|
||
|
||
def get_eid_image(eid_data): | ||
return eid_data['PHOTO_FILE'] | ||
|
||
|
||
def get_national_number(eid_data): | ||
return eid_data['national_number'] | ||
|
||
|
||
def eid_inserted(eid_data): | ||
if (eid_data['success']): | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def write_image(eid_image_decode, national_number): | ||
eid_image = open('{}.jpeg'.format(national_number), 'wb') | ||
eid_image.write(eid_image_decode) | ||
eid_image.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
eid_data = get_eid_data() | ||
if (eid_inserted(eid_data)): | ||
eid_image_decode_string = base64.b64decode(get_eid_image(eid_data)) | ||
national_number = get_national_number(eid_data) | ||
write_image(eid_image_decode_string, national_number) | ||
else: | ||
print('E-ID card not inserted, or could not be read') |