Skip to content

Instantly share code, notes, and snippets.

Avatar

Shahriyar Rzayev ShahriyarR

View GitHub Profile
View enum_validation.sh
$ ./qr-code green-badge generate Shako Rzayev 1989-10-24 2021-01-01=pfizer 2021-06-01=asdasd
usage: qr-code green-badge generate [-h] [-v] first_name last_name birth_date [vaccinations <name>=<value> ...]
qr-code green-badge generate: error: argument vaccinations <name>=<value>: invalid choice: 'asdasd' (choose from 'pfizer', 'moderna', 'astrazeneca', 'janssen', 'sinovac')
View qr_code_generated.sh
$ ./qr-code green-badge generate Shako Rzayev 1989-10-24 2021-01-01=pfizer 2021-06-01=pfizer
QR code has been generated.
View qr_code_2.sh
$ ./qr-code green-badge generate -h
usage: qr-code green-badge generate [-h] [-v] first_name last_name birth_date [vaccinations <name>=<value> ...]
positional arguments:
first_name name of the vaccinated person
last_name surname of the vaccindate person
birth_date birthday of the vaccinated person in YYYY-MM-DD format
vaccinations <name>=<value>
vaccination information as date=manufacturer ['pfizer', 'moderna', 'astrazeneca', 'janssen', 'sinovac']
View generate_final.py
import shutil
import requests
from datetime import date, datetime
from typing import Literal, TypedDict
from enum import Enum
__version__ = "3.0"
View qr_code_1.sh
$ ./qr-code -h
usage: qr-code [-h] [-v] {green-badge} ...
Sample QR Generator
positional arguments:
{green-badge}
green-badge Generate Green Badge
View cli_entrypoint_2.py
#!/usr/bin/env python3
"""
Sample QR Generator
"""
import os
import sys
from dynacli import main
View cli_entrypoint_1.py
#!/usr/bin/env python3
"""
DynaCLI bootstrap script # Change me
"""
import os
import sys
from typing import Final
View generate.py
def generate(first_name: str, last_name: str, birth_date: str, **vaccinations: Manufacturer) -> None:
"""
Generate your vaccination QR code.
Args:
first_name (str): name of the vaccinated person
last_name (str): surname of the vaccindate person
birth_date (str): birthday of the vaccinated person in YYYY-MM-DD format
**vaccinations (Manufacturer): vaccination information as date=manufacturer
View show_typeddict.py
class Vaccination(TypedDict):
date: date
manufacturer: Manufacturer
class QRCode(TypedDict):
name: str
birth: str
vaccinations: list[Vaccination]
View show_enum.py
from enum import Enum
class Manufacturer(Enum):
pfizer = 1
moderna = 2
astrazeneca = 3
janssen = 4
sinovac = 5