python unescape函数_Python escape.url_unescape方法代碼示例
本文整理匯總了Python中tornado.escape.url_unescape方法的典型用法代碼示例。如果您正苦於以下問題:Python escape.url_unescape方法的具體用法?Python escape.url_unescape怎麽用?Python escape.url_unescape使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊tornado.escape的用法示例。
在下文中一共展示了escape.url_unescape方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: _unquote_or_none
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def _unquote_or_none(s):
"""None-safe wrapper around url_unescape to handle unamteched optional
groups correctly.
Note that args are passed as bytes so the handler can decide what
encoding to use.
"""
if s is None:
return s
return escape.url_unescape(s, encoding=None, plus=False)
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:12,
示例2: environ
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def environ(request):
"""Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.
"""
hostport = request.host.split(":")
if len(hostport) == 2:
host = hostport[0]
port = int(hostport[1])
else:
host = request.host
port = 443 if request.protocol == "https" else 80
environ = {
"REQUEST_METHOD": request.method,
"SCRIPT_NAME": "",
"PATH_INFO": to_wsgi_str(escape.url_unescape(
request.path, encoding=None, plus=False)),
"QUERY_STRING": request.query,
"REMOTE_ADDR": request.remote_ip,
"SERVER_NAME": host,
"SERVER_PORT": str(port),
"SERVER_PROTOCOL": request.version,
"wsgi.version": (1, 0),
"wsgi.url_scheme": request.protocol,
"wsgi.input": BytesIO(escape.utf8(request.body)),
"wsgi.errors": sys.stderr,
"wsgi.multithread": False,
"wsgi.multiprocess": True,
"wsgi.run_once": False,
}
if "Content-Type" in request.headers:
environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")
if "Content-Length" in request.headers:
environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")
for key, value in request.headers.items():
environ["HTTP_" + key.replace("-", "_").upper()] = value
return environ
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:37,
示例3: test_url_unescape_unicode
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def test_url_unescape_unicode(self):
tests = [
('%C3%A9', u('\u00e9'), 'utf8'),
('%C3%A9', u('\u00c3\u00a9'), 'latin1'),
('%C3%A9', utf8(u('\u00e9')), None),
]
for escaped, unescaped, encoding in tests:
# input strings to url_unescape should only contain ascii
# characters, but make sure the function accepts both byte
# and unicode strings.
self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped)
self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,
示例4: test_url_escape_quote_plus
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def test_url_escape_quote_plus(self):
unescaped = '+ #%'
plus_escaped = '%2B+%23%25'
escaped = '%2B%20%23%25'
self.assertEqual(url_escape(unescaped), plus_escaped)
self.assertEqual(url_escape(unescaped, plus=False), escaped)
self.assertEqual(url_unescape(plus_escaped), unescaped)
self.assertEqual(url_unescape(escaped, plus=False), unescaped)
self.assertEqual(url_unescape(plus_escaped, encoding=None),
utf8(unescaped))
self.assertEqual(url_unescape(escaped, encoding=None, plus=False),
utf8(unescaped))
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,
示例5: environ
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def environ(request: httputil.HTTPServerRequest) -> Dict[Text, Any]:
"""Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.
"""
hostport = request.host.split(":")
if len(hostport) == 2:
host = hostport[0]
port = int(hostport[1])
else:
host = request.host
port = 443 if request.protocol == "https" else 80
environ = {
"REQUEST_METHOD": request.method,
"SCRIPT_NAME": "",
"PATH_INFO": to_wsgi_str(
escape.url_unescape(request.path, encoding=None, plus=False)
),
"QUERY_STRING": request.query,
"REMOTE_ADDR": request.remote_ip,
"SERVER_NAME": host,
"SERVER_PORT": str(port),
"SERVER_PROTOCOL": request.version,
"wsgi.version": (1, 0),
"wsgi.url_scheme": request.protocol,
"wsgi.input": BytesIO(escape.utf8(request.body)),
"wsgi.errors": sys.stderr,
"wsgi.multithread": False,
"wsgi.multiprocess": True,
"wsgi.run_once": False,
}
if "Content-Type" in request.headers:
environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")
if "Content-Length" in request.headers:
environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")
for key, value in request.headers.items():
environ["HTTP_" + key.replace("-", "_").upper()] = value
return environ
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:38,
示例6: _unquote_or_none
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def _unquote_or_none(s: Optional[str]) -> Optional[bytes]: # noqa: F811
"""None-safe wrapper around url_unescape to handle unmatched optional
groups correctly.
Note that args are passed as bytes so the handler can decide what
encoding to use.
"""
if s is None:
return s
return url_unescape(s, encoding=None, plus=False)
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:12,
示例7: environ
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def environ(request):
"""Converts a `tornado.httpserver.HTTPRequest` to a WSGI environment.
"""
hostport = request.host.split(":")
if len(hostport) == 2:
host = hostport[0]
port = int(hostport[1])
else:
host = request.host
port = 443 if request.protocol == "https" else 80
environ = {
"REQUEST_METHOD": request.method,
"SCRIPT_NAME": "",
"PATH_INFO": to_wsgi_str(escape.url_unescape(
request.path, encoding=None, plus=False)),
"QUERY_STRING": request.query,
"REMOTE_ADDR": request.remote_ip,
"SERVER_NAME": host,
"SERVER_PORT": str(port),
"SERVER_PROTOCOL": request.version,
"wsgi.version": (1, 0),
"wsgi.url_scheme": request.protocol,
"wsgi.input": BytesIO(escape.utf8(request.body)),
"wsgi.errors": sys.stderr,
"wsgi.multithread": False,
"wsgi.multiprocess": True,
"wsgi.run_once": False,
}
if "Content-Type" in request.headers:
environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")
if "Content-Length" in request.headers:
environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")
for key, value in request.headers.items():
environ["HTTP_" + key.replace("-", "_").upper()] = value
return environ
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:37,
示例8: _unquote_or_none
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def _unquote_or_none(s):
"""None-safe wrapper around url_unescape to handle unmatched optional
groups correctly.
Note that args are passed as bytes so the handler can decide what
encoding to use.
"""
if s is None:
return s
return url_unescape(s, encoding=None, plus=False)
開發者ID:tp4a,項目名稱:teleport,代碼行數:12,
示例9: test_url_unescape
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def test_url_unescape(self):
tests = [
('%C3%A9', u'\u00e9', 'utf8'),
('%C3%A9', u'\u00c3\u00a9', 'latin1'),
('%C3%A9', utf8(u'\u00e9'), None),
]
for escaped, unescaped, encoding in tests:
# input strings to url_unescape should only contain ascii
# characters, but make sure the function accepts both byte
# and unicode strings.
self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped)
self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)
開發者ID:omererdem,項目名稱:honeything,代碼行數:14,
示例10: get
點讚 5
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def get(self, token, connection_file):
register_connection_file(token, url_unescape(connection_file))
開發者ID:funkey,項目名稱:nyroglancer,代碼行數:5,
示例11: __call__
點讚 4
# 需要導入模塊: from tornado import escape [as 別名]
# 或者: from tornado.escape import url_unescape [as 別名]
def __call__(self, request):
"""Called by HTTPServer to execute the request."""
transforms = [t(request) for t in self.transforms]
handler = None
args = []
kwargs = {}
handlers = self._get_host_handlers(request)
if not handlers:
handler = RedirectHandler(
self, request, url="http://" + self.default_host + "/")
else:
for spec in handlers:
match = spec.regex.match(request.path)
if match:
handler = spec.handler_class(self, request, **spec.kwargs)
if spec.regex.groups:
# None-safe wrapper around url_unescape to handle
# unmatched optional groups correctly
def unquote(s):
if s is None:
return s
return escape.url_unescape(s, encoding=None,
plus=False)
# Pass matched groups to the handler. Since
# match.groups() includes both named and unnamed groups,
# we want to use either groups or groupdict but not both.
# Note that args are passed as bytes so the handler can
# decide what encoding to use.
if spec.regex.groupindex:
kwargs = dict(
(str(k), unquote(v))
for (k, v) in match.groupdict().items())
else:
args = [unquote(s) for s in match.groups()]
break
if not handler:
handler = ErrorHandler(self, request, status_code=404)
# In debug mode, re-compile templates and reload static files on every
# request so you don't need to restart to see changes
if self.settings.get("debug"):
with RequestHandler._template_loader_lock:
for loader in RequestHandler._template_loaders.values():
loader.reset()
StaticFileHandler.reset()
handler._execute(transforms, *args, **kwargs)
return handler
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:51,
注:本文中的tornado.escape.url_unescape方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
python unescape函数_Python escape.url_unescape方法代碼示例相关推荐
- python linspace函数_Python torch.linspace方法代碼示例
本文整理匯總了Python中torch.linspace方法的典型用法代碼示例.如果您正苦於以下問題:Python torch.linspace方法的具體用法?Python torch.linspac ...
- python markdown2 样式_Python markdown2.markdown方法代碼示例
本文整理匯總了Python中markdown2.markdown方法的典型用法代碼示例.如果您正苦於以下問題:Python markdown2.markdown方法的具體用法?Python markd ...
- python socketio例子_Python socket.SocketIO方法代碼示例
本文整理匯總了Python中socket.SocketIO方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.SocketIO方法的具體用法?Python socket.Sock ...
- python wheel使用_Python wheel.Wheel方法代碼示例
# 需要導入模塊: from pip import wheel [as 別名] # 或者: from pip.wheel import Wheel [as 別名] def from_line(cls, ...
- python的from_bytes属性_Python parse.quote_from_bytes方法代碼示例
本文整理匯總了Python中urllib.parse.quote_from_bytes方法的典型用法代碼示例.如果您正苦於以下問題:Python parse.quote_from_bytes方法的具體 ...
- python里turtle.circle什么意思_Python turtle.circle方法代碼示例
本文整理匯總了Python中turtle.circle方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.circle方法的具體用法?Python turtle.circle怎麽 ...
- python中startout是什么意思_Python socket.timeout方法代碼示例
本文整理匯總了Python中gevent.socket.timeout方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.timeout方法的具體用法?Python socket ...
- python dict get default_Python locale.getdefaultlocale方法代碼示例
本文整理匯總了Python中locale.getdefaultlocale方法的典型用法代碼示例.如果您正苦於以下問題:Python locale.getdefaultlocale方法的具體用法?Py ...
- pythonitems方法_Python environ.items方法代碼示例
本文整理匯總了Python中os.environ.items方法的典型用法代碼示例.如果您正苦於以下問題:Python environ.items方法的具體用法?Python environ.item ...
最新文章
- Failed to instantiate one or more classes
- 初步了解React Native的新组件库firstBorn
- mysql date week_mysql weekday(date)/subdate(date,间隔天数)查询年龄/本月/周过生日
- Centos6.6安装zabbix server 3.2
- CouncurrentHashMap源码解析
- 让你的man手册显示与众不同
- 高仿微信实现左滑显示删除button功能
- iOS中的JSON解析
- web中hasmoreelements_Web开发模式【Mode I 和Mode II的介绍、应用案例】
- sql:数据定义语言ddl
- 如何在JavaScript中使用apply(?),call(?)和bind(➰)方法
- mysql ndb 命令_Mysql入门基础命令
- 使用批处理设置、启动和停止服务
- WDM驱动开发 电源管理
- 如何提高团队的研发效率呢?
- 公安大数据智能化平台(大数据人工智能公司)
- 微信小程序-如何解决onShareAppMessage转发gif格式图片不展示?【亲测有效】
- 学计算机要选什么科,计算机要学什么科目
- vxwork任务切换分析
- xshell突出显示集——自定义配置