def _make_contact_or_wifi_qr_code(contact_or_wifi, expected_cls, embedded: bool, qr_code_args: dict) -> str: if not isinstance(contact_or_wifi, expected_cls): # For compatibility with existing views and templates, try to build from dict. contact_or_wifi = expected_cls(**contact_or_wifi) if embedded: return make_qr_code_with_args(contact_or_wifi.make_qr_code_text(), qr_code_args=qr_code_args) else: return make_qr_code_url_with_args(contact_or_wifi.make_qr_code_text(), qr_code_args=qr_code_args)
def _make_geolocation_qr_code(embedded: bool, **kwargs) -> str: if 'coordinates' in kwargs: coordinates = kwargs.pop('coordinates') else: coordinates = Coordinates(kwargs.pop('latitude'), kwargs.pop('longitude'), kwargs.pop('altitude')) if embedded: return make_qr_code_with_args(coordinates.make_geolocation_text(), qr_code_args=kwargs) else: return make_qr_code_url_with_args(coordinates.make_geolocation_text(), qr_code_args=kwargs)
def _make_google_maps_qr_code(embedded, **kwargs): if 'coordinates' in kwargs: coordinates = kwargs.pop('coordinates') else: coordinates = Coordinates(kwargs.pop('latitude'), kwargs.pop('longitude')) if embedded: return make_qr_code_with_args(coordinates.make_google_maps_text(), qr_code_args=kwargs) else: return make_qr_code_url_with_args(coordinates.make_google_maps_text(), qr_code_args=kwargs)
def qr_for_google_play(package_id, **kwargs): return make_qr_code_with_args(make_google_play_text(package_id), qr_code_args=kwargs)
def qr_for_youtube(video_id, **kwargs): return make_qr_code_with_args(make_youtube_text(video_id), qr_code_args=kwargs)
def qr_for_sms(phone_number, **kwargs): return make_qr_code_with_args(make_sms_text(phone_number), qr_code_args=kwargs)
def qr_for_email(email, **kwargs): return make_qr_code_with_args(make_email_text(email), qr_code_args=kwargs)
def qr_from_text(text, **kwargs): return make_qr_code_with_args(text, qr_code_args=kwargs)
def qr_for_tel(phone_number: Any, **kwargs) -> str: return make_qr_code_with_args(make_tel_text(phone_number), qr_code_args=kwargs)
def qr_for_email(email: Any, **kwargs) -> str: return make_qr_code_with_args(make_email_text(email), qr_code_args=kwargs)
def qr_from_text(text: Any, **kwargs) -> str: return make_qr_code_with_args(text, qr_code_args=kwargs)
def qr_from_text(text: Any, **kwargs) -> str: if "dark_color" in kwargs: del kwargs["dark_color"] return mark_safe( make_qr_code_with_args(text, qr_code_args=kwargs).replace( ' stroke="#000"', ""))