repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
tornado | tornado/web.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 3,808 | 147,177 |
tornado | tornado/ioloop.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 979 | 36,988 |
tornado | tornado/tcpserver.py | .py | #
# Copyright 2011 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 384 | 14,826 |
tornado | tornado/wsgi.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 267 | 10,679 |
tornado | tornado/template.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 1,043 | 37,473 |
tornado | tornado/process.py | .py | #
# Copyright 2011 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 363 | 12,525 |
tornado | tornado/options.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 734 | 25,689 |
tornado | tornado/iostream.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 1,609 | 63,419 |
tornado | tornado/httpclient.py | .py | """Blocking and non-blocking HTTP client interfaces.
This module defines a common interface shared by two implementations,
``simple_httpclient`` and ``curl_httpclient``. Applications may either
instantiate their chosen implementation class directly or use the
`AsyncHTTPClient` class from this module, which selects an... | 789 | 31,630 |
tornado | tornado/autoreload.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 351 | 13,090 |
tornado | tornado/httputil.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 1,427 | 50,585 |
tornado | tornado/http1connection.py | .py | #
# Copyright 2014 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 899 | 38,035 |
tornado | tornado/util.py | .py | """Miscellaneous utility functions and classes.
This module is used internally by Tornado. It is not necessarily expected
that the functions and classes defined here will be useful to other
applications, but they are documented here in case they are.
The one public-facing part of this module is the `Configurable` cl... | 437 | 15,608 |
tornado | tornado/curl_httpclient.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 573 | 24,091 |
tornado | tornado/__init__.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 68 | 1,767 |
tornado | tornado/locks.py | .py | # Copyright 2015 The Tornado Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | 583 | 17,901 |
tornado | tornado/websocket.py | .py | """Implementation of the WebSocket protocol.
`WebSockets <http://dev.w3.org/html5/websockets/>`_ allow for bidirectional
communication between the browser and server. WebSockets are supported in the
current versions of all major browsers.
This module implements the final version of the WebSocket protocol as
defined i... | 1,721 | 63,345 |
tornado | tornado/gen.py | .py | """``tornado.gen`` implements generator-based coroutines.
.. note::
The "decorator and generator" approach in this module is a
precursor to native coroutines (using ``async def`` and ``await``)
which were introduced in Python 3.5. Applications that do not
require compatibility with older versions of Pytho... | 888 | 31,332 |
tornado | tornado/testing.py | .py | """Support classes for automated testing.
* `AsyncTestCase` and `AsyncHTTPTestCase`: Subclasses of unittest.TestCase
with additional support for testing asynchronous (`.IOLoop`-based) code.
* `ExpectLog`: Make test logs less spammy.
* `main()`: A simple test runner (wrapper around unittest.main()) with support
... | 864 | 32,915 |
tornado | tornado/httpserver.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 406 | 15,915 |
tornado | tornado/auth.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 1,245 | 49,146 |
tornado | tornado/locale.py | .py | # Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | 589 | 21,058 |
tornado | tornado/concurrent.py | .py | #
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 267 | 8,190 |
tornado | tornado/log.py | .py | #
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 345 | 12,513 |
tornado | tornado/escape.py | .py | #
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 412 | 14,373 |
tornado | tornado/simple_httpclient.py | .py | import base64
import collections
import copy
import functools
import re
import socket
import ssl
import sys
import time
import urllib.parse
from collections.abc import Awaitable, Callable
from io import BytesIO
from types import TracebackType
from typing import Any, Optional, Type
from tornado import gen, httputil, ve... | 733 | 29,849 |
tornado | tornado/queues.py | .py | # Copyright 2015 The Tornado Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | 430 | 13,014 |
tornado | tornado/tcpclient.py | .py | #
# Copyright 2014 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 324 | 11,902 |
tornado | tornado/_locale_data.py | .py | # Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | 81 | 4,503 |
tornado | tornado/routing.py | .py | # Copyright 2015 The Tornado Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | 723 | 24,937 |
tornado | tornado/platform/twisted.py | .py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... | 64 | 2,135 |
tornado | tornado/platform/asyncio.py | .py | """Bridges between the `asyncio` module and Tornado IOLoop.
.. versionadded:: 3.2
This module integrates Tornado with the ``asyncio`` module introduced
in Python 3.4. This makes it possible to combine the two libraries on
the same event loop.
.. deprecated:: 5.0
While the code in this module is still used, it is... | 749 | 28,074 |
tornado | tornado/platform/caresresolver.py | .py | import socket
import typing
from collections.abc import Generator
from typing import Any
import pycares # type: ignore
from tornado import gen
from tornado.concurrent import Future
from tornado.ioloop import IOLoop
from tornado.netutil import Resolver, is_valid_ip
class CaresResolver(Resolver):
"""Name resolve... | 94 | 3,448 |
tornado | tornado/test/httpclient_test.py | .py | import base64
import binascii
import copy
import datetime
import gzip
import subprocess
import sys
import threading
import time
import unicodedata
import unittest
from contextlib import closing
from io import BytesIO
from tornado.escape import utf8, native_str, to_unicode, json_encode, json_decode
from tornado import ... | 1,025 | 40,634 |
tornado | tornado/test/gen_test.py | .py | import asyncio
import contextvars
import datetime
import gc
import platform
import sys
import time
import unittest
import weakref
from concurrent import futures
from tornado import gen
from tornado.concurrent import Future
from tornado.log import app_log
from tornado.test.util import skipNotCPython
from tornado.testin... | 1,112 | 33,429 |
tornado | tornado/test/httputil_test.py | .py | import copy
import datetime
import logging
import pickle
import time
import unittest
import urllib.parse
from tornado.escape import native_str, utf8
from tornado.httputil import (
HTTPFile,
HTTPHeaders,
HTTPInputError,
HTTPServerRequest,
ParseMultipartConfig,
RequestStartLine,
format_timest... | 759 | 29,239 |
tornado | tornado/test/concurrent_test.py | .py | #
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 232 | 6,638 |
tornado | tornado/test/process_test.py | .py | import os
import signal
import subprocess
import sys
import time
import unittest
from tornado.process import Subprocess
from tornado.test.util import skipIfNonUnix
from tornado.testing import AsyncTestCase, gen_test
# Body of the multi-process test, factored out so it can be launched in a
# clean Python subprocess. f... | 296 | 11,272 |
tornado | tornado/test/http1connection_test.py | .py | import socket
from tornado.http1connection import HTTP1Connection
from tornado.httputil import HTTPMessageDelegate
from tornado.iostream import IOStream
from tornado.locks import Event
from tornado.netutil import add_accept_handler
from tornado.testing import AsyncTestCase, bind_unused_port, gen_test
class HTTP1Conn... | 61 | 1,918 |
tornado | tornado/test/netutil_test.py | .py | import errno
import signal
import socket
import sys
import time
import typing
import unittest
from subprocess import Popen
from tornado.netutil import (
BlockingResolver,
OverrideResolver,
ThreadedResolver,
bind_sockets,
is_valid_ip,
)
from tornado.test.util import abstract_base_test, skipIfNoNetwo... | 214 | 7,257 |
tornado | tornado/test/websocket_test.py | .py | import asyncio
import contextlib
import datetime
import functools
import socket
import traceback
import typing
import unittest
from tornado import gen
from tornado.concurrent import Future
from tornado.httpclient import HTTPError, HTTPRequest
from tornado.locks import Event
from tornado.log import app_log, gen_log
fro... | 995 | 33,152 |
tornado | tornado/test/util_test.py | .py | import datetime
import re
import sys
import textwrap
import unittest
from typing import Any, cast
import tornado
from tornado.escape import utf8
from tornado.util import (
ArgReplacer,
Configurable,
exec_in,
import_object,
raise_exc_info,
re_unescape,
timedelta_to_seconds,
)
class RaiseEx... | 369 | 12,956 |
tornado | tornado/test/util.py | .py | import contextlib
import os
import platform
import socket
import sys
import sysconfig
import textwrap
import typing
import unittest
import warnings
from tornado.testing import bind_unused_port
_TestCaseType = typing.TypeVar("_TestCaseType", bound=type[unittest.TestCase])
skipIfNonUnix = unittest.skipIf(
os.name ... | 133 | 4,481 |
tornado | tornado/test/testing_test.py | .py | import asyncio
import contextlib
import gc
import os
import platform
import sys
import traceback
import unittest
import warnings
from tornado import gen, ioloop
from tornado.httpserver import HTTPServer
from tornado.locks import Event
from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, bind_unused_port, gen_... | 342 | 10,510 |
tornado | tornado/test/tcpserver_test.py | .py | import socket
import subprocess
import sys
import textwrap
import unittest
from tornado import gen
from tornado.iostream import IOStream
from tornado.log import app_log
from tornado.tcpserver import TCPServer
from tornado.test.util import skipIfNonUnix
from tornado.testing import AsyncTestCase, ExpectLog, bind_unused_... | 221 | 7,597 |
tornado | tornado/test/__main__.py | .py | """Shim to allow python -m tornado.test."""
from tornado.test.runtests import all, main
# tornado.testing.main autodiscovery relies on 'all' being present in
# the main module, so import it here even though it is not used directly.
# The following line prevents a pyflakes warning.
all = all
main()
| 11 | 302 |
tornado | tornado/test/httpserver_test.py | .py | import datetime
import gzip
import logging
import os
import shutil
import socket
import ssl
import sys
import tempfile
import textwrap
import typing
import unittest
import urllib.parse
import uuid
from contextlib import closing, contextmanager
from io import BytesIO
from tornado import gen, netutil
from tornado.escape... | 1,512 | 53,308 |
tornado | tornado/test/routing_test.py | .py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... | 277 | 8,783 |
tornado | tornado/test/import_test.py | .py | import subprocess
import sys
import unittest
_import_everything = b"""
# The event loop is not fork-safe, and it's easy to initialize an asyncio.Future
# at startup, which in turn creates the default event loop and prevents forking.
# Explicitly disallow the default event loop so that an error will be raised
# if some... | 69 | 2,325 |
tornado | tornado/test/runtests.py | .py | import gc
import io
import locale # system locale module, not tornado.locale
import logging
import operator
import sys
import textwrap
import unittest
import warnings
from functools import reduce
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
from tornado.netutil import Resol... | 223 | 7,458 |
tornado | tornado/test/simple_httpclient_test.py | .py | import collections
import errno
import logging
import os
import re
import socket
import ssl
import sys
import typing
from contextlib import closing
from tornado import gen, version
from tornado.escape import to_unicode, utf8
from tornado.httpclient import AsyncHTTPClient, HTTPResponse
from tornado.httpserver import HT... | 886 | 32,184 |
tornado | tornado/test/iostream_test.py | .py | import asyncio
import errno
import hashlib
import logging
import os
import platform
import random
import socket
import ssl
import typing
import unittest
from unittest import mock
from tornado import gen, netutil
from tornado.concurrent import Future
from tornado.httpclient import AsyncHTTPClient, HTTPResponse
from tor... | 1,420 | 51,689 |
tornado | tornado/test/asyncio_test.py | .py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... | 299 | 11,891 |
tornado | tornado/test/log_test.py | .py | #
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 234 | 8,912 |
tornado | tornado/test/escape_test.py | .py | import unittest
from typing import Any
import tornado
from tornado.escape import (
json_decode,
json_encode,
recursive_unicode,
squeeze,
to_unicode,
url_escape,
url_unescape,
utf8,
xhtml_escape,
xhtml_unescape,
)
from tornado.util import unicode_type
linkify_tests: list[tuple[s... | 324 | 12,241 |
tornado | tornado/test/tcpclient_test.py | .py | #
# Copyright 2014 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 431 | 16,369 |
tornado | tornado/test/circlerefs_test.py | .py | """Test script to find circular references.
Circular references are not leaks per se, because they will eventually
be GC'd. However, on CPython, they prevent the reference-counting fast
path from being used and instead rely on the slower full GC. This
increases memory footprint and CPU overhead, so we try to eliminate... | 217 | 7,270 |
tornado | tornado/test/queues_test.py | .py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... | 440 | 14,036 |
tornado | tornado/test/autoreload_test.py | .py | import os
import shutil
import subprocess
import sys
import textwrap
import time
import unittest
from subprocess import Popen
from tempfile import mkdtemp
class AutoreloadTest(unittest.TestCase):
def setUp(self):
# When these tests fail the output sometimes exceeds the default maxDiff.
self.maxDif... | 265 | 9,124 |
tornado | tornado/test/locks_test.py | .py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under th... | 535 | 16,942 |
tornado | tornado/test/web_test.py | .py | import binascii
import contextlib
import copy
import datetime
import email.utils
import gzip
import http
import itertools
import logging
import os
import re
import socket
import typing
import unittest
import urllib.parse
from io import BytesIO
from tornado import gen, locale
from tornado.concurrent import Future
from ... | 3,449 | 127,910 |
tornado | tornado/test/wsgi_test.py | .py | import asyncio
import concurrent.futures
import threading
from wsgiref.validate import validator
from tornado.routing import RuleRouter
from tornado.testing import AsyncHTTPTestCase, gen_test
from tornado.wsgi import WSGIContainer
class WSGIAppMixin:
# TODO: Now that WSGIAdapter is gone, this is a pretty weak te... | 116 | 3,917 |
tornado | tornado/test/curl_httpclient_test.py | .py | from hashlib import md5
import os
import ssl
import unittest
from tornado import gen
from tornado.escape import utf8
from tornado.netutil import ssl_options_to_context
from tornado.test import httpclient_test
from tornado.testing import AsyncHTTPSTestCase, AsyncHTTPTestCase
from tornado.web import Application, Request... | 240 | 8,271 |
tornado | tornado/test/twisted_test.py | .py | # Author: Ovidiu Predescu
# Date: July 2011
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 71 | 2,104 |
tornado | tornado/test/ioloop_test.py | .py | import asyncio
import contextlib
import datetime
import functools
import socket
import subprocess
import sys
import threading
import time
import types
import unittest
from collections.abc import Generator
from concurrent import futures
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
from to... | 808 | 27,879 |
tornado | tornado/test/auth_test.py | .py | # These tests do not currently do much to verify the correct implementation
# of the openid/oauth protocols, they just exercise the major code paths
# and ensure that it doesn't blow up (e.g. with unicode/bytes issues in
# python 3)
from unittest import mock
from tornado import gen
from tornado.auth import (
Face... | 630 | 24,342 |
tornado | tornado/test/options_test.py | .py | import datetime
import os
import sys
import unittest
from io import StringIO
from unittest import mock
from tornado.options import Error, OptionParser
from tornado.util import basestring_type
class Email:
def __init__(self, value):
if isinstance(value, str) and "@" in value:
self._value = val... | 324 | 11,790 |
tornado | tornado/test/template_test.py | .py | import os
import traceback
import unittest
from tornado.escape import native_str, to_unicode, utf8
from tornado.template import DictLoader, Loader, ParseError, Template
from tornado.util import ObjectDict
class TemplateTest(unittest.TestCase):
def test_simple(self):
template = Template("Hello {{ name }}!... | 503 | 18,182 |
tornado | tornado/test/locale_test.py | .py | import datetime
import os
import shutil
import tempfile
import unittest
import tornado.locale
from tornado.escape import to_unicode, utf8
from tornado.util import unicode_type
class TranslationLoaderTest(unittest.TestCase):
# TODO: less hacky way to get isolated tests
SAVE_VARS = ["_translations", "_supporte... | 160 | 6,342 |
tornado | tornado/test/gettext_translations/extract_me.py | .py | # flake8: noqa
# Dummy source file to allow creation of the initial .po file in the
# same way as a real project. I'm not entirely sure about the real
# workflow here, but this seems to work.
#
# 1) xgettext --language=Python --keyword=_:1,2 --keyword=pgettext:1c,2 --keyword=pgettext:1c,2,3 extract_me.py -o tornado_te... | 16 | 806 |
tornado | demos/webspider/webspider.py | .py | #!/usr/bin/env python3
import asyncio
import time
from datetime import timedelta
from html.parser import HTMLParser
from urllib.parse import urljoin, urldefrag
from tornado import gen, httpclient, queues
base_url = "http://www.tornadoweb.org/en/stable/"
concurrency = 10
async def get_links_from_url(url):
"""D... | 99 | 2,699 |
tornado | demos/google_auth/main.py | .py | """Demo app for GoogleOAuth2Mixin
Recommended usage:
- Register an app with Google following the instructions at
https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin
- Use "http://localhost:8888/auth/google" as the redirect URI.
- Create a file in this directory called main.cfg, containing t... | 115 | 3,991 |
tornado | demos/helloworld/helloworld.py | .py | #!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 40 | 1,155 |
tornado | demos/blog/blog.py | .py | #!/usr/bin/env python3
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 321 | 10,685 |
tornado | demos/facebook/facebook.py | .py | #!/usr/bin/env python3
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 114 | 3,954 |
tornado | demos/tcpecho/server.py | .py | #!/usr/bin/env python
import asyncio
import logging
from tornado import gen
from tornado.iostream import StreamClosedError
from tornado.tcpserver import TCPServer
from tornado.options import options, define
define("port", default=9888, help="TCP port to listen on")
logger = logging.getLogger(__name__)
class EchoSer... | 41 | 1,118 |
tornado | demos/tcpecho/client.py | .py | #!/usr/bin/env python
import asyncio
from tornado.tcpclient import TCPClient
from tornado.options import options, define
define("host", default="localhost", help="TCP server host")
define("port", default=9888, help="TCP port to connect to")
define("message", default="ping", help="Message to send")
async def send_me... | 23 | 696 |
tornado | demos/websocket/chatdemo.py | .py | #!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 100 | 3,013 |
tornado | demos/file_upload/file_uploader.py | .py | #!/usr/bin/env python
"""Usage: python file_uploader.py [--put] file1.txt file2.png ...
Demonstrates uploading files to a server, without concurrency. It can either
POST a multipart-form-encoded request containing one or more files, or PUT a
single file without encoding.
See also file_receiver.py in this directory, ... | 111 | 3,388 |
tornado | demos/file_upload/file_receiver.py | .py | #!/usr/bin/env python
"""Usage: python file_receiver.py
Demonstrates a server that receives a multipart-form-encoded set of files in an
HTTP POST, or streams in the raw data of a single file in an HTTP PUT.
See file_uploader.py in this directory for code that uploads files in this format.
"""
import asyncio
import ... | 60 | 1,562 |
tornado | demos/chat/chatdemo.py | .py | #!/usr/bin/env python3
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 131 | 4,384 |
tornado | docs/conf.py | .py | import os
import sphinx.errors
import sys
# Ensure we get the local copy of tornado instead of what's on the standard path
sys.path.insert(0, os.path.abspath(".."))
import tornado
master_doc = "index"
project = "Tornado"
copyright = "The Tornado Authors"
version = release = tornado.version
extensions = [
"sphi... | 159 | 4,327 |
bottle | bottle.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Bottle is a fast and simple micro-framework for small web applications. It
offers request dispatching (Routes) with URL parameter support, templates,
a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and
template engines - all in a single file an... | 4,585 | 175,882 |
bottle | docs/conf.py | .py | # -*- coding: utf-8 -*-
import sys
import os
import time
# Use the matching bottle version, not a globally installed one.
bottle_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
sys.path.insert(0, bottle_dir)
import bottle
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
... | 30 | 910 |
bottle | test/test_sendfile.py | .py | import sys
import unittest
from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob
import bottle
import wsgiref.util
import os
import tempfile
import time
basename = os.path.basename(__file__)
root = os.path.dirname(__file__)
basename2 = os.path.basename(bottle.__file__)
root2 =... | 192 | 7,962 |
bottle | test/test_route.py | .py | import functools
import unittest
import bottle
from .tools import api
from bottle import _re_flatten
class TestReFlatten(unittest.TestCase):
def test_re_flatten(self):
self.assertEqual(_re_flatten(r"(?:aaa)(_bbb)"), '(?:aaa)(?:_bbb)')
self.assertEqual(_re_flatten(r"(aaa)(_bbb)"), '(?:aaa)(?:_bbb)... | 125 | 4,115 |
bottle | test/test_mdict.py | .py | import unittest
from bottle import MultiDict, HeaderDict
class TestMultiDict(unittest.TestCase):
def test_isadict(self):
""" MultiDict should behaves like a normal dict """
d, m = dict(a=5), MultiDict(a=5)
d['key'], m['key'] = 'value', 'value'
d['k2'], m['k2'] = 'v1', 'v1'
d... | 48 | 1,975 |
bottle | test/test_app.py | .py | # -*- coding: utf-8 -*-
""" Tests for the functionality of the application object.
TODO: Move other tests here.
"""
import unittest
from bottle import Bottle
class TestApplicationObject(unittest.TestCase):
def test_setattr(self):
""" Attributed can be assigned, but only once. """
app = ... | 21 | 536 |
bottle | test/test_mount.py | .py | # -*- coding: utf-8 -*-
import bottle
from .tools import ServerTestBase, api
from bottle import response
class TestAppMounting(ServerTestBase):
def setUp(self):
ServerTestBase.setUp(self)
self.subapp = bottle.Bottle()
@self.subapp.route('/')
@self.subapp.route('/test/<test>')
... | 129 | 4,416 |
bottle | test/test_resources.py | .py | import os.path
import sys
import unittest
from bottle import ResourceManager
if sys.platform == 'win32':
TEST_PATHS = ('C:\\foo\\bar\\', 'C:\\foo\\bar\\baz', 'C:\\foo\\baz\\..\\bar\\blub')
EXPECTED = ['C:\\foo\\bar\\']
else:
TEST_PATHS = ('/foo/bar/', '/foo/bar/baz', '/foo/baz/../bar/blub')
EXPECTED = ... | 98 | 3,129 |
bottle | test/test_config.py | .py | import os
import tempfile
import unittest
from bottle import ConfigDict
class TestConfDict(unittest.TestCase):
def test_isadict(self):
""" ConfigDict should behaves like a normal dict. """
# It is a dict-subclass, so this kind of pointless, but it doen't hurt.
d, m = dict(), ConfigDict()
... | 201 | 7,372 |
bottle | test/__init__.py | .py | from __future__ import with_statement
from .tools import chdir
import unittest
import sys, os
try:
import coverage
coverage.process_startup()
except ImportError:
pass
import bottle
bottle.debug(True)
| 15 | 215 |
bottle | test/test_auth.py | .py | # -*- coding: utf-8 -*-
import bottle
from .tools import ServerTestBase
class TestBasicAuth(ServerTestBase):
def test__header(self):
@bottle.route('/')
@bottle.auth_basic(lambda x, y: False)
def test(): return {}
self.assertStatus(401)
self.assertHeader('Www-Authenticate', ... | 13 | 345 |
bottle | test/test_router.py | .py | # -*- coding: utf-8 -*-
import unittest
import bottle
import warnings
class TestRouter(unittest.TestCase):
CGI = False
def setUp(self):
self.r = bottle.Router()
def add(self, path, target, method='GET', **ka):
with warnings.catch_warnings() as r:
warnings.simplefilte... | 167 | 6,934 |
bottle | test/test_multipart.py | .py | # -*- coding: utf-8 -*-
import unittest
import base64
import sys, os.path, tempfile
from io import BytesIO
import bottle
class BaseMultipartTest(unittest.TestCase):
def setUp(self):
self.reset()
def reset(self):
self.data = BytesIO()
self.parts = None
def write(self, *lines):
... | 708 | 38,342 |
bottle | test/test_contextlocals.py | .py | # -*- coding: utf-8 -*-
'''
Some objects are context-local, meaning that they have different values depending on the context they are accessed from. A context is currently defined as a thread.
'''
import unittest
import bottle
import threading
def run_thread(func):
t = threading.Thread(target=func)
t.start()... | 42 | 1,238 |
bottle | test/test_formsdict.py | .py | # -*- coding: utf-8 -*-
# '瓶' means "Bottle"
import unittest
from bottle import FormsDict, touni, tob
class TestFormsDict(unittest.TestCase):
def test_attr_access(self):
""" FomsDict.attribute returs string values as unicode. """
d = FormsDict(py3='瓶')
self.assertEqual('瓶', d.py3)
... | 18 | 521 |
bottle | test/test_securecookies.py | .py | #coding: utf-8
import unittest
import bottle
from bottle import tob, touni
from .tools import api
class TestSignedCookies(unittest.TestCase):
def setUp(self):
self.data = touni('υηι¢σ∂є')
self.secret = tob('secret')
bottle.app.push()
bottle.response.bind()
def tear_down(self)... | 56 | 1,761 |
bottle | test/example_settings.py | .py | A = {
"B": {
"C": 3
}
} | 5 | 39 |
bottle | test/test_oorouting.py | .py | """
Tests & demonstrates various OO approaches to routes
"""
import unittest
import sys
if sys.version_info >= (3, 0, 0):
from io import BytesIO
else:
from StringIO import StringIO as BytesIO
__author__ = 'atc'
from bottle import Bottle, request, tob, BaseRequest
class TestRouter(object):
"""
A tes... | 40 | 955 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.