prompt_id int64 0 941 | project stringclasses 24
values | module stringlengths 7 49 | class stringlengths 0 32 | method stringlengths 2 37 | focal_method_txt stringlengths 43 41.5k | focal_method_lines listlengths 2 2 | in_stack bool 2
classes | globals listlengths 0 16 | type_context stringlengths 79 41.9k | has_branch bool 2
classes | total_branches int64 0 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|
645 | tornado | tornado.auth | OpenIdMixin | authenticate_redirect | def authenticate_redirect(
self,
callback_uri: Optional[str] = None,
ax_attrs: List[str] = ["name", "email", "language", "username"],
) -> None:
"""Redirects to the authentication URL for this service.
After authentication, the service will redirect back to the given
... | [
87,
113
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | false | 0 |
646 | tornado | tornado.auth | OpenIdMixin | get_authenticated_user | async def get_authenticated_user(
self, http_client: Optional[httpclient.AsyncHTTPClient] = None
) -> Dict[str, Any]:
"""Fetches the authenticated user data upon redirect.
This method should be called by the handler that receives the
redirect from the `authenticate_redirect()` m... | [
115,
145
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
647 | tornado | tornado.auth | OAuthMixin | authorize_redirect | async def authorize_redirect(
self,
callback_uri: Optional[str] = None,
extra_params: Optional[Dict[str, Any]] = None,
http_client: Optional[httpclient.AsyncHTTPClient] = None,
) -> None:
"""Redirects the user to obtain OAuth authorization for this service.
The `... | [
289,
336
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
648 | tornado | tornado.auth | OAuthMixin | get_authenticated_user | async def get_authenticated_user(
self, http_client: Optional[httpclient.AsyncHTTPClient] = None
) -> Dict[str, Any]:
"""Gets the OAuth authorized user and access token.
This method should be called from the handler for your
OAuth callback URL to complete the registration proces... | [
338,
382
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
649 | tornado | tornado.auth | OAuth2Mixin | authorize_redirect | def authorize_redirect(
self,
redirect_uri: Optional[str] = None,
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
extra_params: Optional[Dict[str, Any]] = None,
scope: Optional[List[str]] = None,
response_type: str = "code",
) -> None... | [
552,
585
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
650 | tornado | tornado.auth | OAuth2Mixin | oauth2_request | async def oauth2_request(
self,
url: str,
access_token: Optional[str] = None,
post_args: Optional[Dict[str, Any]] = None,
**args: Any
) -> Any:
"""Fetches the given URL auth an OAuth2 access token.
If the request is a POST, ``post_args`` should be provide... | [
609,
663
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
651 | tornado | tornado.auth | TwitterMixin | authenticate_redirect | async def authenticate_redirect(self, callback_uri: Optional[str] = None) -> None:
"""Just like `~OAuthMixin.authorize_redirect`, but
auto-redirects if authorized.
This is generally the right interface to use if you are using
Twitter for single-sign on.
.. versionchanged:: ... | [
716,
736
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | false | 0 |
652 | tornado | tornado.auth | TwitterMixin | twitter_request | async def twitter_request(
self,
path: str,
access_token: Dict[str, Any],
post_args: Optional[Dict[str, Any]] = None,
**args: Any
) -> Any:
"""Fetches the given API path, e.g., ``statuses/user_timeline/btaylor``
The path should not include the format or A... | [
738,
811
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
653 | tornado | tornado.auth | GoogleOAuth2Mixin | get_authenticated_user | async def get_authenticated_user(
self, redirect_uri: str, code: str
) -> Dict[str, Any]:
"""Handles the login for the Google user, returning an access token.
The result is a dictionary containing an ``access_token`` field
([among others](https://developers.google.com/identity/p... | [
858,
920
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | false | 0 |
654 | tornado | tornado.auth | FacebookGraphMixin | get_authenticated_user | async def get_authenticated_user(
self,
redirect_uri: str,
client_id: str,
client_secret: str,
code: str,
extra_fields: Optional[Dict[str, Any]] = None,
) -> Optional[Dict[str, Any]]:
"""Handles the login for the Facebook user, returning a user object.
... | [
931,
1036
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | true | 2 |
655 | tornado | tornado.auth | FacebookGraphMixin | facebook_request | async def facebook_request(
self,
path: str,
access_token: Optional[str] = None,
post_args: Optional[Dict[str, Any]] = None,
**args: Any
) -> Any:
"""Fetches the given relative API path, e.g., "/btaylor/picture"
If the request is a POST, ``post_args`` sho... | [
1038,
1096
] | false | [] | import base64
import binascii
import hashlib
import hmac
import time
import urllib.parse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import unicode_type
from tornado.web import RequestHandler
from typing import List, Any, Dict, cast, It... | false | 0 |
656 | tornado | tornado.concurrent | run_on_executor | def run_on_executor(*args: Any, **kwargs: Any) -> Callable:
"""Decorator to run a synchronous method asynchronously on an executor.
Returns a future.
The executor to be used is determined by the ``executor``
attributes of ``self``. To use a different attribute name, pass a
keyword argument to the ... | [
73,
133
] | false | [
"_T",
"Future",
"FUTURES",
"dummy_executor",
"_NO_RESULT"
] | import asyncio
from concurrent import futures
import functools
import sys
import types
from tornado.log import app_log
import typing
from typing import Any, Callable, Optional, Tuple, Union
_T = typing.TypeVar("_T")
Future = asyncio.Future
FUTURES = (futures.Future, Future)
dummy_executor = DummyExecutor()
_NO_RESULT ... | true | 2 | |
657 | tornado | tornado.concurrent | chain_future | def chain_future(a: "Future[_T]", b: "Future[_T]") -> None:
"""Chain two futures together so that when one completes, so does the other.
The result (success or failure) of ``a`` will be copied to ``b``, unless
``b`` has already been completed or cancelled by the time ``a`` finishes.
.. versionchanged:... | [
139,
169
] | false | [
"_T",
"Future",
"FUTURES",
"dummy_executor",
"_NO_RESULT"
] | import asyncio
from concurrent import futures
import functools
import sys
import types
from tornado.log import app_log
import typing
from typing import Any, Callable, Optional, Tuple, Union
_T = typing.TypeVar("_T")
Future = asyncio.Future
FUTURES = (futures.Future, Future)
dummy_executor = DummyExecutor()
_NO_RESULT ... | true | 2 | |
658 | tornado | tornado.concurrent | future_set_result_unless_cancelled | def future_set_result_unless_cancelled(
future: "Union[futures.Future[_T], Future[_T]]", value: _T
) -> None:
"""Set the given ``value`` as the `Future`'s result, if not cancelled.
Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on
a cancelled `asyncio.Future`.
.. versionadded::... | [
172,
183
] | false | [
"_T",
"Future",
"FUTURES",
"dummy_executor",
"_NO_RESULT"
] | import asyncio
from concurrent import futures
import functools
import sys
import types
from tornado.log import app_log
import typing
from typing import Any, Callable, Optional, Tuple, Union
_T = typing.TypeVar("_T")
Future = asyncio.Future
FUTURES = (futures.Future, Future)
dummy_executor = DummyExecutor()
_NO_RESULT ... | true | 2 | |
659 | tornado | tornado.concurrent | future_set_exception_unless_cancelled | def future_set_exception_unless_cancelled(
future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException
) -> None:
"""Set the given ``exc`` as the `Future`'s exception.
If the Future is already canceled, logs the exception instead. If
this logging is not desired, the caller should explicitly che... | [
186,
205
] | false | [
"_T",
"Future",
"FUTURES",
"dummy_executor",
"_NO_RESULT"
] | import asyncio
from concurrent import futures
import functools
import sys
import types
from tornado.log import app_log
import typing
from typing import Any, Callable, Optional, Tuple, Union
_T = typing.TypeVar("_T")
Future = asyncio.Future
FUTURES = (futures.Future, Future)
dummy_executor = DummyExecutor()
_NO_RESULT ... | true | 2 | |
660 | tornado | tornado.concurrent | DummyExecutor | submit | def submit(
self, fn: Callable[..., _T], *args: Any, **kwargs: Any
) -> "futures.Future[_T]":
future = futures.Future() # type: futures.Future[_T]
try:
future_set_result_unless_cancelled(future, fn(*args, **kwargs))
except Exception:
future_set_exc_info(f... | [
56,
64
] | false | [
"_T",
"Future",
"FUTURES",
"dummy_executor",
"_NO_RESULT"
] | import asyncio
from concurrent import futures
import functools
import sys
import types
from tornado.log import app_log
import typing
from typing import Any, Callable, Optional, Tuple, Union
_T = typing.TypeVar("_T")
Future = asyncio.Future
FUTURES = (futures.Future, Future)
dummy_executor = DummyExecutor()
_NO_RESULT ... | false | 0 |
661 | tornado | tornado.escape | url_unescape | def url_unescape( # noqa: F811
value: Union[str, bytes], encoding: Optional[str] = "utf-8", plus: bool = True
) -> Union[str, bytes]:
"""Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the ... | [
117,
143
] | false | [
"_XHTML_ESCAPE_RE",
"_XHTML_ESCAPE_DICT",
"_UTF8_TYPES",
"_TO_UNICODE_TYPES",
"_unicode",
"native_str",
"to_basestring",
"_URL_RE",
"_HTML_UNICODE_MAP"
] | import html.entities
import json
import re
import urllib.parse
from tornado.util import unicode_type
import typing
from typing import Union, Any, Optional, Dict, List, Callable
_XHTML_ESCAPE_RE = re.compile("[&<>\"']")
_XHTML_ESCAPE_DICT = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'... | true | 2 | |
662 | tornado | tornado.escape | utf8 | def utf8(value: Union[None, str, bytes]) -> Optional[bytes]: # noqa: F811
"""Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8.
"""
if isinstance(value, _UTF8_TYPES):... | [
187,
197
] | false | [
"_XHTML_ESCAPE_RE",
"_XHTML_ESCAPE_DICT",
"_UTF8_TYPES",
"_TO_UNICODE_TYPES",
"_unicode",
"native_str",
"to_basestring",
"_URL_RE",
"_HTML_UNICODE_MAP"
] | import html.entities
import json
import re
import urllib.parse
from tornado.util import unicode_type
import typing
from typing import Union, Any, Optional, Dict, List, Callable
_XHTML_ESCAPE_RE = re.compile("[&<>\"']")
_XHTML_ESCAPE_DICT = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'... | true | 2 | |
663 | tornado | tornado.escape | recursive_unicode | def recursive_unicode(obj: Any) -> Any:
"""Walks a simple data structure, converting byte strings to unicode.
Supports lists, tuples, and dictionaries.
"""
if isinstance(obj, dict):
return dict(
(recursive_unicode(k), recursive_unicode(v)) for (k, v) in obj.items()
)
eli... | [
241,
257
] | false | [
"_XHTML_ESCAPE_RE",
"_XHTML_ESCAPE_DICT",
"_UTF8_TYPES",
"_TO_UNICODE_TYPES",
"_unicode",
"native_str",
"to_basestring",
"_URL_RE",
"_HTML_UNICODE_MAP"
] | import html.entities
import json
import re
import urllib.parse
from tornado.util import unicode_type
import typing
from typing import Union, Any, Optional, Dict, List, Callable
_XHTML_ESCAPE_RE = re.compile("[&<>\"']")
_XHTML_ESCAPE_DICT = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'... | true | 2 | |
664 | tornado | tornado.escape | linkify | def linkify(
text: Union[str, bytes],
shorten: bool = False,
extra_params: Union[str, Callable[[str], str]] = "",
require_protocol: bool = False,
permitted_protocols: List[str] = ["http", "https"],
) -> str:
"""Converts plain text into HTML with links.
For example: ``linkify("Hello http://t... | [
274,
376
] | false | [
"_XHTML_ESCAPE_RE",
"_XHTML_ESCAPE_DICT",
"_UTF8_TYPES",
"_TO_UNICODE_TYPES",
"_unicode",
"native_str",
"to_basestring",
"_URL_RE",
"_HTML_UNICODE_MAP"
] | import html.entities
import json
import re
import urllib.parse
from tornado.util import unicode_type
import typing
from typing import Union, Any, Optional, Dict, List, Callable
_XHTML_ESCAPE_RE = re.compile("[&<>\"']")
_XHTML_ESCAPE_DICT = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'... | true | 2 | |
665 | tornado | tornado.httpclient | main | def main() -> None:
from tornado.options import define, options, parse_command_line
define("print_headers", type=bool, default=False)
define("print_body", type=bool, default=True)
define("follow_redirects", type=bool, default=True)
define("validate_cert", type=bool, default=True)
define("proxy_... | [
756,
785
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 | |
666 | tornado | tornado.httpclient | HTTPClient | __init__ | def __init__(
self,
async_client_class: "Optional[Type[AsyncHTTPClient]]" = None,
**kwargs: Any
) -> None:
# Initialize self._closed at the beginning of the constructor
# so that an exception raised here doesn't lead to confusing
# failures in __del__.
sel... | [
88,
109
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
667 | tornado | tornado.httpclient | HTTPClient | fetch | def fetch(
self, request: Union["HTTPRequest", str], **kwargs: Any
) -> "HTTPResponse":
"""Executes a request, returning an `HTTPResponse`.
The request may be either a string URL or an `HTTPRequest` object.
If it is a string, we construct an `HTTPRequest` using any additional
... | [
121,
136
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | false | 0 |
668 | tornado | tornado.httpclient | AsyncHTTPClient | __new__ | def __new__(cls, force_instance: bool = False, **kwargs: Any) -> "AsyncHTTPClient":
io_loop = IOLoop.current()
if force_instance:
instance_cache = None
else:
instance_cache = cls._async_clients()
if instance_cache is not None and io_loop in instance_cache:
... | [
197,
213
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
669 | tornado | tornado.httpclient | AsyncHTTPClient | initialize | def initialize(self, defaults: Optional[Dict[str, Any]] = None) -> None:
self.io_loop = IOLoop.current()
self.defaults = dict(HTTPRequest._DEFAULTS)
if defaults is not None:
self.defaults.update(defaults)
self._closed = False | [
215,
220
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
670 | tornado | tornado.httpclient | AsyncHTTPClient | close | def close(self) -> None:
"""Destroys this HTTP client, freeing any file descriptors used.
This method is **not needed in normal use** due to the way
that `AsyncHTTPClient` objects are transparently reused.
``close()`` is generally only necessary when either the
`.IOLoop` is ... | [
222,
246
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
671 | tornado | tornado.httpclient | AsyncHTTPClient | fetch | def fetch(
self,
request: Union[str, "HTTPRequest"],
raise_error: bool = True,
**kwargs: Any
) -> "Future[HTTPResponse]":
"""Executes a request, asynchronously returning an `HTTPResponse`.
The request may be either a string URL or an `HTTPRequest` object.
... | [
248,
306
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
672 | tornado | tornado.httpclient | AsyncHTTPClient | fetch_impl | def fetch_impl(
self, request: "HTTPRequest", callback: Callable[["HTTPResponse"], None]
) -> None:
raise NotImplementedError() | [
308,
311
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | false | 0 |
673 | tornado | tornado.httpclient | HTTPRequest | __init__ | def __init__(
self,
url: str,
method: str = "GET",
headers: Optional[Union[Dict[str, str], httputil.HTTPHeaders]] = None,
body: Optional[Union[bytes, str]] = None,
auth_username: Optional[str] = None,
auth_password: Optional[str] = None,
auth_mode: Opt... | [
357,
548
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
674 | tornado | tornado.httpclient | HTTPResponse | __init__ | def __init__(
self,
request: HTTPRequest,
code: int,
headers: Optional[httputil.HTTPHeaders] = None,
buffer: Optional[BytesIO] = None,
effective_url: Optional[str] = None,
error: Optional[BaseException] = None,
request_time: Optional[float] = None,
... | [
628,
668
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
675 | tornado | tornado.httpclient | HTTPResponse | rethrow | def rethrow(self) -> None:
"""If there was an error on the request, raise an `HTTPError`."""
if self.error:
raise self.error | [
679,
682
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
676 | tornado | tornado.httpclient | _RequestProxy | __getattr__ | def __getattr__(self, name: str) -> Any:
request_attr = getattr(self.request, name)
if request_attr is not None:
return request_attr
elif self.defaults is not None:
return self.defaults.get(name, None)
else:
return None | [
746,
753
] | false | [
"HTTPError"
] | import datetime
import functools
from io import BytesIO
import ssl
import time
import weakref
from tornado.concurrent import (
Future,
future_set_result_unless_cancelled,
future_set_exception_unless_cancelled,
)
from tornado.escape import utf8, native_str
from tornado import gen, httputil
from tornado.ioloo... | true | 2 |
677 | tornado | tornado.locale | load_translations | def load_translations(directory: str, encoding: Optional[str] = None) -> None:
"""Loads translations from CSV files in a directory.
Translations are strings with optional Python-style named placeholders
(e.g., ``My name is %(name)s``) and their associated translations.
The directory should have transl... | [
88,
172
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 | |
678 | tornado | tornado.locale | load_gettext_translations | def load_gettext_translations(directory: str, domain: str) -> None:
"""Loads translations from `gettext`'s locale tree
Locale tree is similar to system's ``/usr/share/locale``, like::
{directory}/{lang}/LC_MESSAGES/{domain}.mo
Three steps are required to have your app translated:
1. Generate... | [
175,
215
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 | |
679 | tornado | tornado.locale | Locale | __init__ | def __init__(self, code: str) -> None:
self.code = code
self.name = LOCALE_NAMES.get(code, {}).get("name", u"Unknown")
self.rtl = False
for prefix in ["fa", "ar", "he"]:
if self.code.startswith(prefix):
self.rtl = True
break
# Init... | [
268,
293
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
680 | tornado | tornado.locale | Locale | pgettext | def pgettext(
self,
context: str,
message: str,
plural_message: Optional[str] = None,
count: Optional[int] = None,
) -> str:
raise NotImplementedError() | [
318,
325
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | false | 0 |
681 | tornado | tornado.locale | Locale | format_date | def format_date(
self,
date: Union[int, float, datetime.datetime],
gmt_offset: int = 0,
relative: bool = True,
shorter: bool = False,
full_format: bool = False,
) -> str:
"""Formats the given date (which should be GMT).
By default, we return a rel... | [
327,
419
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
682 | tornado | tornado.locale | Locale | format_day | def format_day(
self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True
) -> bool:
"""Formats the given date as a day of week.
Example: "Monday, January 22". You can remove the day of week with
``dow=False``.
"""
local_date = date - datetime.timedelt... | [
427,
444
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
683 | tornado | tornado.locale | Locale | list | def list(self, parts: Any) -> str:
"""Returns a comma-separated list for the given list of parts.
The format is, e.g., "A, B and C", "A and B" or just "A" for lists
of size 1.
"""
_ = self.translate
if len(parts) == 0:
return ""
if len(parts) == 1... | [
449,
461
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
684 | tornado | tornado.locale | Locale | friendly_number | def friendly_number(self, value: int) -> str:
"""Returns a comma-separated number for the given integer."""
if self.code not in ("en", "en_US"):
return str(value)
s = str(value)
parts = []
while s:
parts.append(s[-3:])
s = s[:-3]
re... | [
466,
475
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
685 | tornado | tornado.locale | CSVLocale | translate | def translate(
self,
message: str,
plural_message: Optional[str] = None,
count: Optional[int] = None,
) -> str:
if plural_message is not None:
assert count is not None
if count != 1:
message = plural_message
message_... | [
485,
500
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
686 | tornado | tornado.locale | GettextLocale | translate | def translate(
self,
message: str,
plural_message: Optional[str] = None,
count: Optional[int] = None,
) -> str:
if plural_message is not None:
assert count is not None
return self.ngettext(message, plural_message, count)
else:
r... | [
524,
534
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
687 | tornado | tornado.locale | GettextLocale | pgettext | def pgettext(
self,
context: str,
message: str,
plural_message: Optional[str] = None,
count: Optional[int] = None,
) -> str:
"""Allows to set context for translation, accepts plural forms.
Usage example::
pgettext("law", "right")
... | [
536,
580
] | false | [
"_default_locale",
"_translations",
"_supported_locales",
"_use_gettext",
"CONTEXT_SEPARATOR"
] | import codecs
import csv
import datetime
import gettext
import os
import re
from tornado import escape
from tornado.log import gen_log
from tornado._locale_data import LOCALE_NAMES
from typing import Iterable, Any, Union, Dict, Optional
_default_locale = "en_US"
_translations = {}
_supported_locales = frozenset([_defa... | true | 2 |
688 | tornado | tornado.locks | Condition | __repr__ | def __repr__(self) -> str:
result = "<%s" % (self.__class__.__name__,)
if self._waiters:
result += " waiters[%s]" % len(self._waiters)
return result + ">" | [
116,
120
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Condition(_Ti... | true | 2 |
689 | tornado | tornado.locks | Condition | wait | def wait(
self, timeout: Optional[Union[float, datetime.timedelta]] = None
) -> Awaitable[bool]:
"""Wait for `.notify`.
Returns a `.Future` that resolves ``True`` if the condition is notified,
or ``False`` after a timeout.
"""
waiter = Future() # type: Future[bo... | [
122,
142
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Condition(_Ti... | true | 2 |
690 | tornado | tornado.locks | Condition | notify | def notify(self, n: int = 1) -> None:
"""Wake ``n`` waiters."""
waiters = [] # Waiters we plan to run right now.
while n and self._waiters:
waiter = self._waiters.popleft()
if not waiter.done(): # Might have timed out.
n -= 1
waiters.... | [
144,
154
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Condition(_Ti... | true | 2 |
691 | tornado | tornado.locks | Condition | notify_all | def notify_all(self) -> None:
"""Wake all waiters."""
self.notify(len(self._waiters)) | [
156,
158
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Condition(_Ti... | false | 0 |
692 | tornado | tornado.locks | Event | set | def set(self) -> None:
"""Set the internal flag to ``True``. All waiters are awakened.
Calling `.wait` once the flag is set will not block.
"""
if not self._value:
self._value = True
for fut in self._waiters:
if not fut.done():
... | [
215,
225
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Event(object)... | true | 2 |
693 | tornado | tornado.locks | Event | wait | def wait(
self, timeout: Optional[Union[float, datetime.timedelta]] = None
) -> Awaitable[None]:
"""Block until the internal flag is true.
Returns an awaitable, which raises `tornado.util.TimeoutError` after a
timeout.
"""
fut = Future() # type: Future[None]
... | [
234,
258
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Event(object)... | true | 2 |
694 | tornado | tornado.locks | _ReleasingContextManager | __exit__ | def __exit__(
self,
exc_type: "Optional[Type[BaseException]]",
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType],
) -> None:
self._obj.release() | [
276,
282
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class _ReleasingCon... | false | 0 |
695 | tornado | tornado.locks | Semaphore | __repr__ | def __repr__(self) -> str:
res = super().__repr__()
extra = (
"locked" if self._value == 0 else "unlocked,value:{0}".format(self._value)
)
if self._waiters:
extra = "{0},waiters:{1}".format(extra, len(self._waiters))
return "<{0} [{1}]>".format(res[1:-... | [
388,
395
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Semaphore(_Ti... | true | 2 |
696 | tornado | tornado.locks | Semaphore | release | def release(self) -> None:
"""Increment the counter and wake one waiter."""
self._value += 1
while self._waiters:
waiter = self._waiters.popleft()
if not waiter.done():
self._value -= 1
# If the waiter is a coroutine paused at
... | [
397,
412
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class _ReleasingCon... | true | 2 |
697 | tornado | tornado.locks | Semaphore | acquire | def acquire(
self, timeout: Optional[Union[float, datetime.timedelta]] = None
) -> Awaitable[_ReleasingContextManager]:
"""Decrement the counter. Returns an awaitable.
Block if the counter is zero and wait for a `.release`. The awaitable
raises `.TimeoutError` after the deadline... | [
414,
440
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class _ReleasingCon... | true | 2 |
698 | tornado | tornado.locks | Semaphore | __aenter__ | async def __aenter__(self) -> None:
await self.acquire() | [
453,
454
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Semaphore(_Ti... | false | 0 |
699 | tornado | tornado.locks | Semaphore | __aexit__ | async def __aexit__(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[types.TracebackType],
) -> None:
self.release() | [
456,
462
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Semaphore(_Ti... | false | 0 |
700 | tornado | tornado.locks | BoundedSemaphore | release | def release(self) -> None:
"""Increment the counter and wake one waiter."""
if self._value >= self._initial_value:
raise ValueError("Semaphore released too many times")
super().release() | [
478,
482
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Semaphore(_Ti... | true | 2 |
701 | tornado | tornado.locks | Lock | release | def release(self) -> None:
"""Unlock.
The first coroutine in line waiting for `acquire` gets the lock.
If not locked, raise a `RuntimeError`.
"""
try:
self._block.release()
except ValueError:
raise RuntimeError("release unlocked lock") | [
538,
548
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Lock(object):... | false | 0 |
702 | tornado | tornado.locks | Lock | __aenter__ | async def __aenter__(self) -> None:
await self.acquire() | [
561,
562
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Lock(object):... | false | 0 |
703 | tornado | tornado.locks | Lock | __aexit__ | async def __aexit__(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[types.TracebackType],
) -> None:
self.release() | [
564,
570
] | false | [
"__all__"
] | import collections
import datetime
import types
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from typing import Union, Optional, Type, Any, Awaitable
import typing
__all__ = ["Condition", "Event", "Semaphore", "BoundedSemaphore", "Lock"]
class Lock(object):... | false | 0 |
704 | tornado | tornado.log | enable_pretty_logging | def enable_pretty_logging(
options: Any = None, logger: Optional[logging.Logger] = None
) -> None:
"""Turns on formatted logging output as configured.
This is called automatically by `tornado.options.parse_command_line`
and `tornado.options.parse_config_file`.
"""
if options is None:
im... | [
210,
257
] | false | [
"access_log",
"app_log",
"gen_log"
] | import logging
import logging.handlers
import sys
from tornado.escape import _unicode
from tornado.util import unicode_type, basestring_type
from typing import Dict, Any, cast, Optional
access_log = logging.getLogger("tornado.access")
app_log = logging.getLogger("tornado.application")
gen_log = logging.getLogger("torn... | true | 2 | |
705 | tornado | tornado.log | define_logging_options | def define_logging_options(options: Any = None) -> None:
"""Add logging-related flags to ``options``.
These options are present automatically on the default options instance;
this method is only necessary if you have created your own `.OptionParser`.
.. versionadded:: 4.2
This function existed... | [
260,
338
] | false | [
"access_log",
"app_log",
"gen_log"
] | import logging
import logging.handlers
import sys
from tornado.escape import _unicode
from tornado.util import unicode_type, basestring_type
from typing import Dict, Any, cast, Optional
access_log = logging.getLogger("tornado.access")
app_log = logging.getLogger("tornado.application")
gen_log = logging.getLogger("torn... | true | 2 | |
706 | tornado | tornado.log | LogFormatter | __init__ | def __init__(
self,
fmt: str = DEFAULT_FORMAT,
datefmt: str = DEFAULT_DATE_FORMAT,
style: str = "%",
color: bool = True,
colors: Dict[int, int] = DEFAULT_COLORS,
) -> None:
r"""
:arg bool color: Enables color support.
:arg str fmt: Log mess... | [
115,
161
] | false | [
"access_log",
"app_log",
"gen_log"
] | import logging
import logging.handlers
import sys
from tornado.escape import _unicode
from tornado.util import unicode_type, basestring_type
from typing import Dict, Any, cast, Optional
access_log = logging.getLogger("tornado.access")
app_log = logging.getLogger("tornado.application")
gen_log = logging.getLogger("torn... | true | 2 |
707 | tornado | tornado.log | LogFormatter | format | def format(self, record: Any) -> str:
try:
message = record.getMessage()
assert isinstance(message, basestring_type) # guaranteed by logging
# Encoding notes: The logging module prefers to work with character
# strings, but only enforces that log messages ar... | [
163,
207
] | false | [
"access_log",
"app_log",
"gen_log"
] | import logging
import logging.handlers
import sys
from tornado.escape import _unicode
from tornado.util import unicode_type, basestring_type
from typing import Dict, Any, cast, Optional
access_log = logging.getLogger("tornado.access")
app_log = logging.getLogger("tornado.application")
gen_log = logging.getLogger("torn... | true | 2 |
708 | tornado | tornado.netutil | bind_sockets | def bind_sockets(
port: int,
address: Optional[str] = None,
family: socket.AddressFamily = socket.AF_UNSPEC,
backlog: int = _DEFAULT_BACKLOG,
flags: Optional[int] = None,
reuse_port: bool = False,
) -> List[socket.socket]:
"""Creates listening sockets bound to the given port and address.
... | [
54,
185
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 | |
709 | tornado | tornado.netutil | add_accept_handler | def add_accept_handler(
sock: socket.socket, callback: Callable[[socket.socket, Any], None]
) -> Callable[[], None]:
"""Adds an `.IOLoop` event handler to accept new connections on ``sock``.
When a connection is accepted, ``callback(connection, address)`` will
be run (``connection`` is a socket object,... | [
225,
282
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 | |
710 | tornado | tornado.netutil | is_valid_ip | def is_valid_ip(ip: str) -> bool:
"""Returns ``True`` if the given string is a well-formed IP address.
Supports IPv4 and IPv6.
"""
if not ip or "\x00" in ip:
# getaddrinfo resolves empty strings to localhost, and truncates
# on zero bytes.
return False
try:
res = soc... | [
285,
303
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 | |
711 | tornado | tornado.netutil | ssl_options_to_context | def ssl_options_to_context(
ssl_options: Union[Dict[str, Any], ssl.SSLContext]
) -> ssl.SSLContext:
"""Try to convert an ``ssl_options`` dictionary to an
`~ssl.SSLContext` object.
The ``ssl_options`` dictionary contains keywords to be passed to
`ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext`... | [
554,
590
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 | |
712 | tornado | tornado.netutil | ssl_wrap_socket | def ssl_wrap_socket(
socket: socket.socket,
ssl_options: Union[Dict[str, Any], ssl.SSLContext],
server_hostname: Optional[str] = None,
**kwargs: Any
) -> ssl.SSLSocket:
"""Returns an ``ssl.SSLSocket`` wrapping the given socket.
``ssl_options`` may be either an `ssl.SSLContext` object or a
d... | [
593,
616
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 | |
713 | tornado | tornado.netutil | Resolver | resolve | def resolve(
self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
) -> Awaitable[List[Tuple[int, Any]]]:
"""Resolves an address.
The ``host`` argument is a string which may be a hostname or a
literal IP address.
Returns a `.Future` whose result is... | [
338,
362
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | false | 0 |
714 | tornado | tornado.netutil | DefaultExecutorResolver | resolve | async def resolve(
self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
) -> List[Tuple[int, Any]]:
result = await IOLoop.current().run_in_executor(
None, _resolve_addr, host, port, family
)
return result | [
394,
400
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | false | 0 |
715 | tornado | tornado.netutil | ExecutorResolver | initialize | def initialize(
self,
executor: Optional[concurrent.futures.Executor] = None,
close_executor: bool = True,
) -> None:
self.io_loop = IOLoop.current()
if executor is not None:
self.executor = executor
self.close_executor = close_executor
els... | [
421,
432
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 |
716 | tornado | tornado.netutil | ExecutorResolver | close | def close(self) -> None:
if self.close_executor:
self.executor.shutdown()
self.executor = None | [
434,
437
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 |
717 | tornado | tornado.netutil | ExecutorResolver | resolve | @run_on_executor
def resolve(
self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
) -> List[Tuple[int, Any]]:
return _resolve_addr(host, port, family) | [
440,
443
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | false | 0 |
718 | tornado | tornado.netutil | OverrideResolver | initialize | def initialize(self, resolver: Resolver, mapping: dict) -> None:
self.resolver = resolver
self.mapping = mapping | [
527,
529
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | false | 0 |
719 | tornado | tornado.netutil | OverrideResolver | close | def close(self) -> None:
self.resolver.close() | [
531,
532
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | false | 0 |
720 | tornado | tornado.netutil | OverrideResolver | resolve | def resolve(
self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
) -> Awaitable[List[Tuple[int, Any]]]:
if (host, port, family) in self.mapping:
host, port = self.mapping[(host, port, family)]
elif (host, port) in self.mapping:
host, port =... | [
534,
543
] | false | [
"_client_ssl_defaults",
"_server_ssl_defaults",
"_DEFAULT_BACKLOG",
"_SSL_CONTEXT_KEYWORDS"
] | import concurrent.futures
import errno
import os
import sys
import socket
import ssl
import stat
from tornado.concurrent import dummy_executor, run_on_executor
from tornado.ioloop import IOLoop
from tornado.util import Configurable, errno_from_exception
from typing import List, Callable, Any, Type, Dict, Union, Tuple, ... | true | 2 |
721 | tornado | tornado.options | OptionParser | __setattr__ | def __setattr__(self, name: str, value: Any) -> None:
name = self._normalize_name(name)
if isinstance(self._options.get(name), _Option):
return self._options[name].set(value)
raise AttributeError("Unrecognized option %r" % name) | [
153,
157
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
722 | tornado | tornado.options | OptionParser | __iter__ | def __iter__(self) -> Iterator:
return (opt.name for opt in self._options.values()) | [
159,
160
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | false | 0 |
723 | tornado | tornado.options | OptionParser | group_dict | def group_dict(self, group: str) -> Dict[str, Any]:
"""The names and values of options in a group.
Useful for copying options into Application settings::
from tornado.options import define, parse_command_line, options
define('template_path', group='application')
... | [
186,
203
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | false | 0 |
724 | tornado | tornado.options | OptionParser | define | def define(
self,
name: str,
default: Any = None,
type: Optional[type] = None,
help: Optional[str] = None,
metavar: Optional[str] = None,
multiple: bool = False,
group: Optional[str] = None,
callback: Optional[Callable[[Any], None]] = None,
... | [
216,
301
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
725 | tornado | tornado.options | OptionParser | parse_command_line | def parse_command_line(
self, args: Optional[List[str]] = None, final: bool = True
) -> List[str]:
"""Parses all options given on the command line (defaults to
`sys.argv`).
Options look like ``--option=value`` and are parsed according
to their ``type``. For boolean optio... | [
303,
355
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
726 | tornado | tornado.options | OptionParser | parse_config_file | def parse_config_file(self, path: str, final: bool = True) -> None:
"""Parses and loads the config file at the given path.
The config file contains Python code that will be executed (so
it is **not safe** to use untrusted config files). Anything in
the global namespace that matches ... | [
357,
424
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
727 | tornado | tornado.options | OptionParser | print_help | def print_help(self, file: Optional[TextIO] = None) -> None:
"""Prints all the command line options to stderr (or another file)."""
if file is None:
file = sys.stderr
print("Usage: %s [OPTIONS]" % sys.argv[0], file=file)
print("\nOptions:\n", file=file)
by_group =... | [
426,
454
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
728 | tornado | tornado.options | _Mockable | __setattr__ | def __setattr__(self, name: str, value: Any) -> None:
assert name not in self._originals, "don't reuse mockable objects"
self._originals[name] = getattr(self._options, name)
setattr(self._options, name, value) | [
508,
511
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | false | 0 |
729 | tornado | tornado.options | _Option | __init__ | def __init__(
self,
name: str,
default: Any = None,
type: Optional[type] = None,
help: Optional[str] = None,
metavar: Optional[str] = None,
multiple: bool = False,
file_name: Optional[str] = None,
group_name: Optional[str] = None,
callb... | [
523,
548
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
730 | tornado | tornado.options | _Option | value | def value(self) -> Any:
return self.default if self._value is _Option.UNSET else self._value | [
550,
551
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | false | 0 |
731 | tornado | tornado.options | _Option | parse | def parse(self, value: str) -> Any:
_parse = {
datetime.datetime: self._parse_datetime,
datetime.timedelta: self._parse_timedelta,
bool: self._parse_bool,
basestring_type: self._parse_string,
}.get(
self.type, self.type
) # type: C... | [
553,
577
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
732 | tornado | tornado.options | _Option | set | def set(self, value: Any) -> None:
if self.multiple:
if not isinstance(value, list):
raise Error(
"Option %r is required to be a list of %s"
% (self.name, self.type.__name__)
)
for item in value:
... | [
579,
600
] | false | [
"options"
] | import datetime
import numbers
import re
import sys
import os
import textwrap
from tornado.escape import _unicode, native_str
from tornado.log import define_logging_options
from tornado.util import basestring_type, exec_in
from typing import (
Any,
Iterator,
Iterable,
Tuple,
Set,
Dict,
Calla... | true | 2 |
733 | tornado | tornado.queues | Queue | put | def put(
self, item: _T, timeout: Optional[Union[float, datetime.timedelta]] = None
) -> "Future[None]":
"""Put an item into the queue, perhaps waiting until there is room.
Returns a Future, which raises `tornado.util.TimeoutError` after a
timeout.
``timeout`` may be a ... | [
185,
206
] | false | [
"_T",
"__all__"
] | import collections
import datetime
import heapq
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado.locks import Event
from typing import Union, TypeVar, Generic, Awaitable, Optional
import typing
_T = TypeVar("_T")
__all__ = ["Queue", "PriorityQueue",... | false | 0 |
734 | tornado | tornado.queues | Queue | put_nowait | def put_nowait(self, item: _T) -> None:
"""Put an item into the queue without blocking.
If no free slot is immediately available, raise `QueueFull`.
"""
self._consume_expired()
if self._getters:
assert self.empty(), "queue non-empty, why are getters waiting?"
... | [
208,
222
] | false | [
"_T",
"__all__"
] | import collections
import datetime
import heapq
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado.locks import Event
from typing import Union, TypeVar, Generic, Awaitable, Optional
import typing
_T = TypeVar("_T")
__all__ = ["Queue", "PriorityQueue",... | true | 2 |
735 | tornado | tornado.queues | Queue | get | def get(
self, timeout: Optional[Union[float, datetime.timedelta]] = None
) -> Awaitable[_T]:
"""Remove and return an item from the queue.
Returns an awaitable which resolves once an item is available, or raises
`tornado.util.TimeoutError` after a timeout.
``timeout`` m... | [
224,
253
] | false | [
"_T",
"__all__"
] | import collections
import datetime
import heapq
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado.locks import Event
from typing import Union, TypeVar, Generic, Awaitable, Optional
import typing
_T = TypeVar("_T")
__all__ = ["Queue", "PriorityQueue",... | false | 0 |
736 | tornado | tornado.queues | Queue | get_nowait | def get_nowait(self) -> _T:
"""Remove and return an item from the queue without blocking.
Return an item if one is immediately available, else raise
`QueueEmpty`.
"""
self._consume_expired()
if self._putters:
assert self.full(), "queue not full, why are p... | [
255,
271
] | false | [
"_T",
"__all__"
] | import collections
import datetime
import heapq
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado.locks import Event
from typing import Union, TypeVar, Generic, Awaitable, Optional
import typing
_T = TypeVar("_T")
__all__ = ["Queue", "PriorityQueue",... | true | 2 |
737 | tornado | tornado.queues | Queue | task_done | def task_done(self) -> None:
"""Indicate that a formerly enqueued task is complete.
Used by queue consumers. For each `.get` used to fetch a task, a
subsequent call to `.task_done` tells the queue that the processing
on the task is complete.
If a `.join` is blocking, it res... | [
273,
289
] | false | [
"_T",
"__all__"
] | import collections
import datetime
import heapq
from tornado import gen, ioloop
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado.locks import Event
from typing import Union, TypeVar, Generic, Awaitable, Optional
import typing
_T = TypeVar("_T")
__all__ = ["Queue", "PriorityQueue",... | true | 2 |
738 | tornado | tornado.simple_httpclient | HTTPTimeoutError | __str__ | def __str__(self) -> str:
return self.message or "Timeout" | [
55,
56
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | false | 0 |
739 | tornado | tornado.simple_httpclient | HTTPStreamClosedError | __str__ | def __str__(self) -> str:
return self.message or "Stream closed" | [
74,
75
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | false | 0 |
740 | tornado | tornado.simple_httpclient | SimpleAsyncHTTPClient | initialize | def initialize( # type: ignore
self,
max_clients: int = 10,
hostname_mapping: Optional[Dict[str, str]] = None,
max_buffer_size: int = 104857600,
resolver: Optional[Resolver] = None,
defaults: Optional[Dict[str, Any]] = None,
max_header_size: Optional[int] = N... | [
88,
156
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | true | 2 |
741 | tornado | tornado.simple_httpclient | SimpleAsyncHTTPClient | close | def close(self) -> None:
super().close()
if self.own_resolver:
self.resolver.close()
self.tcp_client.close() | [
158,
162
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | true | 2 |
742 | tornado | tornado.simple_httpclient | SimpleAsyncHTTPClient | fetch_impl | def fetch_impl(
self, request: HTTPRequest, callback: Callable[[HTTPResponse], None]
) -> None:
key = object()
self.queue.append((key, request, callback))
assert request.connect_timeout is not None
assert request.request_timeout is not None
timeout_handle = None
... | [
164,
186
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | true | 2 |
743 | tornado | tornado.simple_httpclient | _HTTPConnection | __init__ | def __init__(
self,
client: Optional[SimpleAsyncHTTPClient],
request: HTTPRequest,
release_callback: Callable[[], None],
final_callback: Callable[[HTTPResponse], None],
max_buffer_size: int,
tcp_client: TCPClient,
max_header_size: int,
max_body... | [
259,
288
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | false | 0 |
744 | tornado | tornado.simple_httpclient | _HTTPConnection | run | async def run(self) -> None:
try:
self.parsed = urllib.parse.urlsplit(_unicode(self.request.url))
if self.parsed.scheme not in ("http", "https"):
raise ValueError("Unsupported url scheme: %s" % self.request.url)
# urlsplit results have hostname and port re... | [
292,
446
] | false | [] | from tornado.escape import _unicode
from tornado import gen, version
from tornado.httpclient import (
HTTPResponse,
HTTPError,
AsyncHTTPClient,
main,
_RequestProxy,
HTTPRequest,
)
from tornado import httputil
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tor... | true | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.