本文整理汇总了Python中werkzeug.useragents.UserAgent方法的典型用法代码示例。如果您正苦于以下问题:Python useragents.UserAgent方法的具体用法?Python useragents.UserAgent怎么用?Python useragents.UserAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.useragents
的用法示例。
在下文中一共展示了useragents.UserAgent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_email_view
# 需要导入模块: from werkzeug import useragents [as 别名]
# 或者: from werkzeug.useragents import UserAgent [as 别名]
def get_email_view(self):
@self.jinja2_view('email_error.html')
def error_email(params):
ua = UserAgent(params.get('ua'))
if ua.browser:
browser = '{0} {1} {2} {3}'
lang = ua.language or ''
browser = browser.format(ua.platform, ua.browser,
ua.version, lang)
params['browser'] = browser
else:
params['browser'] = ua.string
params['time'] = params['time'][:19]
return params
return error_email
# ============================================================================
示例2: user_agent
# 需要导入模块: from werkzeug import useragents [as 别名]
# 或者: from werkzeug.useragents import UserAgent [as 别名]
def user_agent(self):
"""The current user agent."""
from werkzeug.useragents import UserAgent
return UserAgent(self.environ)
示例3: __call__
# 需要导入模块: from werkzeug import useragents [as 别名]
# 或者: from werkzeug.useragents import UserAgent [as 别名]
def __call__(self, environ, start_response):
ua = UserAgent(environ)
if ua.browser != 'msie':
return self.app(environ, start_response)
return self.run_fixed(environ, start_response)
示例4: parse_browser
# 需要导入模块: from werkzeug import useragents [as 别名]
# 或者: from werkzeug.useragents import UserAgent [as 别名]
def parse_browser(self, params):
ua = UserAgent(params.get('ua'))
if ua.browser:
params['ua_platform'] = ua.platform
params['ua_browser'] = ua.browser
params['ua_version'] = ua.version
else:
params['ua_platform'] = '-'
params['ua_browser'] = params.get('ua', '-')
params['ua_version'] = '-'