cengal.web_tools.detect_browsers_host_device_type.by_http_user_agent.versions.v_1.by_http_user_agent
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18 19__all__ = ['is_mobile_browser', 'is_tablet_browser', 'is_mobile_or_tablet_browser'] 20 21 22""" 23Module Docstring 24Docstrings: http://www.python.org/dev/peps/pep-0257/ 25""" 26 27 28import re 29 30 31__author__ = "ButenkoMS <gtalk@butenkoms.space>" 32__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 33__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 34__license__ = "Apache License, Version 2.0" 35__version__ = "4.4.1" 36__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 37__email__ = "gtalk@butenkoms.space" 38# __status__ = "Prototype" 39__status__ = "Development" 40# __status__ = "Production" 41 42 43reg = re.compile(r'android|iphone|ipad|mobile|iemobile|windows phone', re.I) 44tablet_reg = re.compile(r'ipad|android(?!.*mobile)|touch|tablet pc', re.I) 45 46 47def is_mobile_browser(user_agent: str) -> bool: 48 return bool(reg.search(user_agent)) 49 50 51def is_tablet_browser(user_agent: str) -> bool: 52 return bool(tablet_reg.search(user_agent)) 53 54 55def is_mobile_or_tablet_browser(user_agent: str) -> bool: 56 mobile = False 57 tablet = is_tablet_browser(user_agent) 58 if not tablet: 59 mobile = is_mobile_browser(user_agent) 60 61 return mobile, tablet
def
is_mobile_browser(user_agent: str) -> bool:
def
is_tablet_browser(user_agent: str) -> bool:
def
is_mobile_or_tablet_browser(user_agent: str) -> bool: