Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
ProtoTestCase.assertProtoEquals
(self, expected_message_maybe_ascii, message, msg=None)
Asserts that message is same as parsed expected_message_ascii. Creates another prototype of message, reads the ascii message into it and then compares them using self._AssertProtoEqual(). Args: expected_message_maybe_ascii: proto message in original or ascii form. message: the message to valid...
Asserts that message is same as parsed expected_message_ascii.
def assertProtoEquals(self, expected_message_maybe_ascii, message, msg=None): """Asserts that message is same as parsed expected_message_ascii. Creates another prototype of message, reads the ascii message into it and then compares them using self._AssertProtoEqual(). Args: expected_message_mayb...
[ "def", "assertProtoEquals", "(", "self", ",", "expected_message_maybe_ascii", ",", "message", ",", "msg", "=", "None", ")", ":", "msg", "=", "msg", "if", "msg", "else", "''", "if", "isinstance", "(", "expected_message_maybe_ascii", ",", "type", "(", "message",...
[ 195, 2 ]
[ 219, 78 ]
python
en
['en', 'en', 'en']
True
get_requirement_info
(dist)
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
def get_requirement_info(dist): # type: (Distribution) -> RequirementInfo """ Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist(). """ if not dist_is_editable(dist): return (None, False, []) location = os.path.normcase(os.path.abspath(dist.lo...
[ "def", "get_requirement_info", "(", "dist", ")", ":", "# type: (Distribution) -> RequirementInfo", "if", "not", "dist_is_editable", "(", "dist", ")", ":", "return", "(", "None", ",", "False", ",", "[", "]", ")", "location", "=", "os", ".", "path", ".", "norm...
[ 174, 0 ]
[ 233, 34 ]
python
en
['en', 'error', 'th']
False
test_collect_functools_partial
(testdir)
Test that collection of functools.partial object works, and arguments to the wrapped functions are dealt correctly (see #811).
Test that collection of functools.partial object works, and arguments to the wrapped functions are dealt correctly (see #811).
def test_collect_functools_partial(testdir): """ Test that collection of functools.partial object works, and arguments to the wrapped functions are dealt correctly (see #811). """ testdir.makepyfile(""" import functools import pytest @pytest.fixture def fix1(): ...
[ "def", "test_collect_functools_partial", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import functools\n import pytest\n\n @pytest.fixture\n def fix1():\n return 'fix1'\n\n @pytest.fixture\n def fix2():\n r...
[ 1257, 0 ]
[ 1298, 44 ]
python
en
['en', 'error', 'th']
False
test_dont_collect_non_function_callable
(testdir)
Test for issue https://github.com/pytest-dev/pytest/issues/331 In this case an INTERNALERROR occurred trying to report the failure of a test like this one because py test failed to get the source lines.
Test for issue https://github.com/pytest-dev/pytest/issues/331
def test_dont_collect_non_function_callable(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/331 In this case an INTERNALERROR occurred trying to report the failure of a test like this one because py test failed to get the source lines. """ testdir.makepyfile(""" clas...
[ "def", "test_dont_collect_non_function_callable", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n class Oh(object):\n def __call__(self):\n pass\n\n test_a = Oh()\n\n def test_real():\n pass\n \"\"\"", ")", "...
[ 1301, 0 ]
[ 1322, 6 ]
python
en
['en', 'no', 'en']
True
test_class_injection_does_not_break_collection
(testdir)
Tests whether injection during collection time will terminate testing. In this case the error should not occur if the TestClass itself is modified during collection time, and the original method list is still used for collection.
Tests whether injection during collection time will terminate testing.
def test_class_injection_does_not_break_collection(testdir): """Tests whether injection during collection time will terminate testing. In this case the error should not occur if the TestClass itself is modified during collection time, and the original method list is still used for collection. """ ...
[ "def", "test_class_injection_does_not_break_collection", "(", "testdir", ")", ":", "testdir", ".", "makeconftest", "(", "\"\"\"\n from test_inject import TestClass\n def pytest_generate_tests(metafunc):\n TestClass.changed_var = {}\n \"\"\"", ")", "testdir", "."...
[ 1325, 0 ]
[ 1345, 47 ]
python
en
['en', 'en', 'en']
True
test_syntax_error_with_non_ascii_chars
(testdir)
Fix decoding issue while formatting SyntaxErrors during collection (#578)
Fix decoding issue while formatting SyntaxErrors during collection (#578)
def test_syntax_error_with_non_ascii_chars(testdir): """Fix decoding issue while formatting SyntaxErrors during collection (#578) """ testdir.makepyfile(u""" # -*- coding: UTF-8 -*- ☃ """) result = testdir.runpytest() result.stdout.fnmatch_lines([ '*ERROR collecting*', '...
[ "def", "test_syntax_error_with_non_ascii_chars", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "u\"\"\"\n # -*- coding: UTF-8 -*-\n\n ☃\n \"\"\"", ")", "result", "=", "testdir", ".", "runpytest", "(", ")", "result", ".", "stdout", ".", "fnmatch_l...
[ 1348, 0 ]
[ 1361, 6 ]
python
en
['en', 'en', 'en']
True
test_skip_duplicates_by_default
(testdir)
Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Ignore duplicate directories.
Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
def test_skip_duplicates_by_default(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Ignore duplicate directories. """ a = testdir.mkdir("a") fh = a.join("test_a.py") fh.write(_pytest._code.Source(""" import pytest def test_real(): ...
[ "def", "test_skip_duplicates_by_default", "(", "testdir", ")", ":", "a", "=", "testdir", ".", "mkdir", "(", "\"a\"", ")", "fh", "=", "a", ".", "join", "(", "\"test_a.py\"", ")", "fh", ".", "write", "(", "_pytest", ".", "_code", ".", "Source", "(", "\"\...
[ 1364, 0 ]
[ 1379, 6 ]
python
en
['en', 'no', 'en']
True
test_keep_duplicates
(testdir)
Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Use --keep-duplicates to collect tests from duplicate directories.
Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
def test_keep_duplicates(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Use --keep-duplicates to collect tests from duplicate directories. """ a = testdir.mkdir("a") fh = a.join("test_a.py") fh.write(_pytest._code.Source(""" import pytest de...
[ "def", "test_keep_duplicates", "(", "testdir", ")", ":", "a", "=", "testdir", ".", "mkdir", "(", "\"a\"", ")", "fh", "=", "a", ".", "join", "(", "\"test_a.py\"", ")", "fh", ".", "write", "(", "_pytest", ".", "_code", ".", "Source", "(", "\"\"\"\n ...
[ 1382, 0 ]
[ 1397, 6 ]
python
en
['en', 'no', 'en']
True
TestModule.test_show_traceback_import_error
(self, testdir, verbose)
Import errors when collecting modules should display the traceback (#1976). With low verbosity we omit pytest and internal modules, otherwise show all traceback entries.
Import errors when collecting modules should display the traceback (#1976).
def test_show_traceback_import_error(self, testdir, verbose): """Import errors when collecting modules should display the traceback (#1976). With low verbosity we omit pytest and internal modules, otherwise show all traceback entries. """ testdir.makepyfile( foo_traceback_im...
[ "def", "test_show_traceback_import_error", "(", "self", ",", "testdir", ",", "verbose", ")", ":", "testdir", ".", "makepyfile", "(", "foo_traceback_import_error", "=", "\"\"\"\n from bar_traceback_import_error import NOT_AVAILABLE\n \"\"\"", ",", "bar_trac...
[ 74, 4 ]
[ 103, 41 ]
python
en
['en', 'en', 'en']
True
TestModule.test_show_traceback_import_error_unicode
(self, testdir)
Check test modules collected which raise ImportError with unicode messages are handled properly (#2336).
Check test modules collected which raise ImportError with unicode messages are handled properly (#2336).
def test_show_traceback_import_error_unicode(self, testdir): """Check test modules collected which raise ImportError with unicode messages are handled properly (#2336). """ testdir.makepyfile(u""" # -*- coding: utf-8 -*- raise ImportError(u'Something bad happened ...
[ "def", "test_show_traceback_import_error_unicode", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "u\"\"\"\n # -*- coding: utf-8 -*-\n raise ImportError(u'Something bad happened ☺')\n \"\"\"", ")", "result", "=", "testdir", "....
[ 105, 4 ]
[ 119, 30 ]
python
en
['en', 'en', 'en']
True
TestClass.test_static_method
(self, testdir)
Support for collecting staticmethod tests (#2528, #2699)
Support for collecting staticmethod tests (#2528, #2699)
def test_static_method(self, testdir): """Support for collecting staticmethod tests (#2528, #2699)""" testdir.getmodulecol(""" import pytest class Test(object): @staticmethod def test_something(): pass @pytest.f...
[ "def", "test_static_method", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "getmodulecol", "(", "\"\"\"\n import pytest\n class Test(object):\n @staticmethod\n def test_something():\n pass\n\n @pyt...
[ 144, 4 ]
[ 165, 10 ]
python
en
['en', 'en', 'en']
True
TestFunction.test_parametrize_with_non_hashable_values
(self, testdir)
Test parametrization with non-hashable values.
Test parametrization with non-hashable values.
def test_parametrize_with_non_hashable_values(self, testdir): """Test parametrization with non-hashable values.""" testdir.makepyfile(""" archival_mapping = { '1.0': {'tag': '1.0'}, '1.2.2a1': {'tag': 'release-1.2.2a1'}, } import pytes...
[ "def", "test_parametrize_with_non_hashable_values", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n archival_mapping = {\n '1.0': {'tag': '1.0'},\n '1.2.2a1': {'tag': 'release-1.2.2a1'},\n }\n\n ...
[ 482, 4 ]
[ 498, 35 ]
python
en
['en', 'en', 'en']
True
TestFunction.test_parametrize_with_non_hashable_values_indirect
(self, testdir)
Test parametrization with non-hashable values with indirect parametrization.
Test parametrization with non-hashable values with indirect parametrization.
def test_parametrize_with_non_hashable_values_indirect(self, testdir): """Test parametrization with non-hashable values with indirect parametrization.""" testdir.makepyfile(""" archival_mapping = { '1.0': {'tag': '1.0'}, '1.2.2a1': {'tag': 'release-1.2.2a1'}, ...
[ "def", "test_parametrize_with_non_hashable_values_indirect", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n archival_mapping = {\n '1.0': {'tag': '1.0'},\n '1.2.2a1': {'tag': 'release-1.2.2a1'},\n }\n\n ...
[ 500, 4 ]
[ 525, 35 ]
python
en
['en', 'en', 'en']
True
TestFunction.test_parametrize_overrides_fixture
(self, testdir)
Test parametrization when parameter overrides existing fixture with same name.
Test parametrization when parameter overrides existing fixture with same name.
def test_parametrize_overrides_fixture(self, testdir): """Test parametrization when parameter overrides existing fixture with same name.""" testdir.makepyfile(""" import pytest @pytest.fixture def value(): return 'value' @pytest.mark.para...
[ "def", "test_parametrize_overrides_fixture", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import pytest\n\n @pytest.fixture\n def value():\n return 'value'\n\n @pytest.mark.parametrize('value',\...
[ 527, 4 ]
[ 552, 35 ]
python
en
['en', 'en', 'en']
True
TestFunction.test_parametrize_overrides_parametrized_fixture
(self, testdir)
Test parametrization when parameter overrides existing parametrized fixture with same name.
Test parametrization when parameter overrides existing parametrized fixture with same name.
def test_parametrize_overrides_parametrized_fixture(self, testdir): """Test parametrization when parameter overrides existing parametrized fixture with same name.""" testdir.makepyfile(""" import pytest @pytest.fixture(params=[1, 2]) def value(request): ...
[ "def", "test_parametrize_overrides_parametrized_fixture", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import pytest\n\n @pytest.fixture(params=[1, 2])\n def value(request):\n return request.param\n\n ...
[ 554, 4 ]
[ 569, 35 ]
python
en
['en', 'en', 'en']
True
TestConftestCustomization.test_issue2369_collect_module_fileext
(self, testdir)
Ensure we can collect files with weird file extensions as Python modules (#2369)
Ensure we can collect files with weird file extensions as Python modules (#2369)
def test_issue2369_collect_module_fileext(self, testdir): """Ensure we can collect files with weird file extensions as Python modules (#2369)""" # We'll implement a little finder and loader to import files containing # Python source code whose file extension is ".narf". testdir.m...
[ "def", "test_issue2369_collect_module_fileext", "(", "self", ",", "testdir", ")", ":", "# We'll implement a little finder and loader to import files containing", "# Python source code whose file extension is \".narf\".", "testdir", ".", "makeconftest", "(", "\"\"\"\n import sy...
[ 872, 4 ]
[ 898, 49 ]
python
en
['en', 'en', 'en']
True
TestTracebackCutting.test_traceback_filter_error_during_fixture_collection
(self, testdir)
integration test for issue #995.
integration test for issue #995.
def test_traceback_filter_error_during_fixture_collection(self, testdir): """integration test for issue #995. """ testdir.makepyfile(""" import pytest def fail_me(func): ns = {} exec('def w(): raise ValueError("fail me")', ns) ...
[ "def", "test_traceback_filter_error_during_fixture_collection", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import pytest\n\n def fail_me(func):\n ns = {}\n exec('def w(): raise ValueError(\"fail me\"...
[ 989, 4 ]
[ 1015, 10 ]
python
en
['en', 'en', 'en']
True
TestTracebackCutting.test_filter_traceback_generated_code
(self)
test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the entries on the traceback was produced by dynamically generated code. See: https://bitbucket.org/pytest-dev/py/issues/71 This fixes #995.
test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the entries on the traceback was produced by dynamically generated code. See: https://bitbucket.org/pytest-dev/py/issues/71 This fixes #995.
def test_filter_traceback_generated_code(self): """test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the entries on the traceback was produced by dynamically generated code. See: https://bitbucket.or...
[ "def", "test_filter_traceback_generated_code", "(", "self", ")", ":", "from", "_pytest", ".", "python", "import", "filter_traceback", "try", ":", "ns", "=", "{", "}", "exec", "(", "'def foo(): raise ValueError'", ",", "ns", ")", "ns", "[", "'foo'", "]", "(", ...
[ 1017, 4 ]
[ 1035, 43 ]
python
en
['en', 'en', 'en']
True
TestTracebackCutting.test_filter_traceback_path_no_longer_valid
(self, testdir)
test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the files in the traceback no longer exists. This fixes #1133.
test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the files in the traceback no longer exists. This fixes #1133.
def test_filter_traceback_path_no_longer_valid(self, testdir): """test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the files in the traceback no longer exists. This fixes #1133. """ from _py...
[ "def", "test_filter_traceback_path_no_longer_valid", "(", "self", ",", "testdir", ")", ":", "from", "_pytest", ".", "python", "import", "filter_traceback", "testdir", ".", "syspathinsert", "(", ")", "testdir", ".", "makepyfile", "(", "filter_traceback_entry_as_str", "...
[ 1037, 4 ]
[ 1058, 39 ]
python
en
['en', 'en', 'en']
True
TestReportInfo.test_generator_reportinfo
(self, testdir)
def test_func(): pass def test_genfunc(): def check(x): pass yield check, 3 class TestClass(object): def test_method(self): pass
def test_func(): pass def test_genfunc(): def check(x): pass yield check, 3 class TestClass(object): def test_method(self): pass
def test_generator_reportinfo(self, testdir): modcol = testdir.getmodulecol(""" # lineno 0 def test_gen(): def check(x): assert x yield check, 3 """) gencol = testdir.collect_by_name(modcol, "test_gen") fspath, l...
[ "def", "test_generator_reportinfo", "(", "self", ",", "testdir", ")", ":", "modcol", "=", "testdir", ".", "getmodulecol", "(", "\"\"\"\n # lineno 0\n def test_gen():\n def check(x):\n assert x\n yield check, 3\n ...
[ 1095, 4 ]
[ 1124, 10 ]
python
en
['en', 'error', 'th']
False
build_url
(label, base, end)
Build a url from the label, a base, and an end.
Build a url from the label, a base, and an end.
def build_url(label, base, end): """ Build a url from the label, a base, and an end. """ clean_label = re.sub(r'([ ]+_)|(_[ ]+)|([ ]+)', '_', label) return '%s%s%s'% (base, clean_label, end)
[ "def", "build_url", "(", "label", ",", "base", ",", "end", ")", ":", "clean_label", "=", "re", ".", "sub", "(", "r'([ ]+_)|(_[ ]+)|([ ]+)'", ",", "'_'", ",", "label", ")", "return", "'%s%s%s'", "%", "(", "base", ",", "clean_label", ",", "end", ")" ]
[ 83, 0 ]
[ 86, 45 ]
python
en
['en', 'en', 'en']
True
WikiLinks._getMeta
(self)
Return meta data or config data.
Return meta data or config data.
def _getMeta(self): """ Return meta data or config data. """ base_url = self.config['base_url'][0] end_url = self.config['end_url'][0] html_class = self.config['html_class'][0] if hasattr(self.md, 'Meta'): if self.md.Meta.has_key('wiki_base_url'): base...
[ "def", "_getMeta", "(", "self", ")", ":", "base_url", "=", "self", ".", "config", "[", "'base_url'", "]", "[", "0", "]", "end_url", "=", "self", ".", "config", "[", "'end_url'", "]", "[", "0", "]", "html_class", "=", "self", ".", "config", "[", "'h...
[ 132, 4 ]
[ 144, 44 ]
python
id
['id', 'id', 'en']
True
PublicURLTest.test_public_urls
(self)
Test which views are accessible when not logged in.
Test which views are accessible when not logged in.
def test_public_urls(self) -> None: """ Test which views are accessible when not logged in. """ # FIXME: We should also test the Tornado URLs -- this codepath # can't do so because this Django test mechanism doesn't go # through Tornado. denmark_stream_id = Stream...
[ "def", "test_public_urls", "(", "self", ")", "->", "None", ":", "# FIXME: We should also test the Tornado URLs -- this codepath", "# can't do so because this Django test mechanism doesn't go", "# through Tornado.", "denmark_stream_id", "=", "Stream", ".", "objects", ".", "get", "...
[ 28, 4 ]
[ 96, 60 ]
python
en
['en', 'error', 'th']
False
PublicURLTest.test_config_error_endpoints_dev_env
(self)
The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly.
The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly.
def test_config_error_endpoints_dev_env(self) -> None: """ The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly. """ auth_types = [auth.lower() for auth in Realm.AUTHENTICATION_FLAGS] for auth in [ ...
[ "def", "test_config_error_endpoints_dev_env", "(", "self", ")", "->", "None", ":", "auth_types", "=", "[", "auth", ".", "lower", "(", ")", "for", "auth", "in", "Realm", ".", "AUTHENTICATION_FLAGS", "]", "for", "auth", "in", "[", "\"azuread\"", ",", "\"email\...
[ 98, 4 ]
[ 121, 82 ]
python
en
['en', 'error', 'th']
False
init_worker
(counter: "multiprocessing.sharedctypes._Value")
This function runs only under parallel mode. It initializes the individual processes which are also called workers.
This function runs only under parallel mode. It initializes the individual processes which are also called workers.
def init_worker(counter: "multiprocessing.sharedctypes._Value") -> None: """ This function runs only under parallel mode. It initializes the individual processes which are also called workers. """ global _worker_id with counter.get_lock(): counter.value += 1 _worker_id = counter...
[ "def", "init_worker", "(", "counter", ":", "\"multiprocessing.sharedctypes._Value\"", ")", "->", "None", ":", "global", "_worker_id", "with", "counter", ".", "get_lock", "(", ")", ":", "counter", ".", "value", "+=", "1", "_worker_id", "=", "counter", ".", "val...
[ 207, 0 ]
[ 239, 56 ]
python
en
['en', 'error', 'th']
False
static_media
(request, path)
Serve static files below a given point in the directory structure.
Serve static files below a given point in the directory structure.
def static_media(request, path): """ Serve static files below a given point in the directory structure. """ from django.utils.http import http_date from django.views.static import was_modified_since import mimetypes import os.path import posixpath import stat import urllib.reques...
[ "def", "static_media", "(", "request", ",", "path", ")", ":", "from", "django", ".", "utils", ".", "http", "import", "http_date", "from", "django", ".", "views", ".", "static", "import", "was_modified_since", "import", "mimetypes", "import", "os", ".", "path...
[ 604, 0 ]
[ 648, 19 ]
python
en
['en', 'error', 'th']
False
lookupEncoding
(encoding)
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
def lookupEncoding(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, bytes): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return None ...
[ "def", "lookupEncoding", "(", "encoding", ")", ":", "if", "isinstance", "(", "encoding", ",", "bytes", ")", ":", "try", ":", "encoding", "=", "encoding", ".", "decode", "(", "\"ascii\"", ")", "except", "UnicodeDecodeError", ":", "return", "None", "if", "en...
[ 902, 0 ]
[ 917, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.__init__
(self, source)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indic...
[ "def", "__init__", "(", "self", ",", "source", ")", ":", "if", "not", "_utils", ".", "supports_lone_surrogates", ":", "# Such platforms will have already checked for such", "# surrogate errors, so no need to do this checking.", "self", ".", "reportCharacterErrors", "=", "None...
[ 157, 4 ]
[ 187, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLUnicodeInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) ...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "StringIO", "(", "source", ")", "return", "stream" ]
[ 203, 4 ]
[ 215, 21 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.position
(self)
Returns (line, col) of the current position in the stream.
Returns (line, col) of the current position in the stream.
def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col)
[ "def", "position", "(", "self", ")", ":", "line", ",", "col", "=", "self", ".", "_position", "(", "self", ".", "chunkOffset", ")", "return", "(", "line", "+", "1", ",", "col", ")" ]
[ 228, 4 ]
[ 231, 30 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.char
(self)
Read one character from the stream or queue if available. Return EOF when EOF is reached.
Read one character from the stream or queue if available. Return EOF when EOF is reached.
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
[ "def", "char", "(", "self", ")", ":", "# Read a new chunk from the input stream if necessary", "if", "self", ".", "chunkOffset", ">=", "self", ".", "chunkSize", ":", "if", "not", "self", ".", "readChunk", "(", ")", ":", "return", "EOF", "chunkOffset", "=", "se...
[ 233, 4 ]
[ 246, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.charsUntil
(self, characters, opposite=False)
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use ...
[ "def", "charsUntil", "(", "self", ",", "characters", ",", "opposite", "=", "False", ")", ":", "# Use a cache of regexps to find the required characters", "try", ":", "chars", "=", "charsUntilRegEx", "[", "(", "characters", ",", "opposite", ")", "]", "except", "Key...
[ 313, 4 ]
[ 358, 16 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.__init__
(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized ...
[ "def", "__init__", "(", "self", ",", "source", ",", "override_encoding", "=", "None", ",", "transport_encoding", "=", "None", ",", "same_origin_parent_encoding", "=", "None", ",", "likely_encoding", "=", "None", ",", "default_encoding", "=", "\"windows-1252\"", ",...
[ 385, 4 ]
[ 425, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLBinaryInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "BytesIO", "(", "source", ")", "try", ":", "stream", ".", ...
[ 431, 4 ]
[ 448, 21 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectBOM
(self)
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
def detectBOM(self): """Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None""" bomDict = { codecs.BOM_UTF8: 'utf-8', codecs.BOM_UTF16_LE: 'utf-16le', codecs.BOM_U...
[ "def", "detectBOM", "(", "self", ")", ":", "bomDict", "=", "{", "codecs", ".", "BOM_UTF8", ":", "'utf-8'", ",", "codecs", ".", "BOM_UTF16_LE", ":", "'utf-16le'", ",", "codecs", ".", "BOM_UTF16_BE", ":", "'utf-16be'", ",", "codecs", ".", "BOM_UTF32_LE", ":"...
[ 528, 4 ]
[ 560, 23 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectEncodingMeta
(self)
Report the encoding declared by the meta element
Report the encoding declared by the meta element
def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() i...
[ "def", "detectEncodingMeta", "(", "self", ")", ":", "buffer", "=", "self", ".", "rawStream", ".", "read", "(", "self", ".", "numBytesMeta", ")", "assert", "isinstance", "(", "buffer", ",", "bytes", ")", "parser", "=", "EncodingParser", "(", "buffer", ")", ...
[ 562, 4 ]
[ 574, 23 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.skip
(self, chars=spaceCharactersBytes)
Skip past a list of characters
Skip past a list of characters
def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c ...
[ "def", "skip", "(", "self", ",", "chars", "=", "spaceCharactersBytes", ")", ":", "p", "=", "self", ".", "position", "# use property for the error-checking", "while", "p", "<", "len", "(", "self", ")", ":", "c", "=", "self", "[", "p", ":", "p", "+", "1"...
[ 633, 4 ]
[ 643, 19 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.matchBytes
(self, bytes)
Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone
Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone
def matchBytes(self, bytes): """Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone""" rv = self.startswith(bytes, self.position) if rv:...
[ "def", "matchBytes", "(", "self", ",", "bytes", ")", ":", "rv", "=", "self", ".", "startswith", "(", "bytes", ",", "self", ".", "position", ")", "if", "rv", ":", "self", ".", "position", "+=", "len", "(", "bytes", ")", "return", "rv" ]
[ 656, 4 ]
[ 663, 17 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.jumpTo
(self, bytes)
Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match
Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match
def jumpTo(self, bytes): """Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match""" try: self._position = self.index(bytes, self.position) + len(bytes) - 1 except ValueError: raise St...
[ "def", "jumpTo", "(", "self", ",", "bytes", ")", ":", "try", ":", "self", ".", "_position", "=", "self", ".", "index", "(", "bytes", ",", "self", ".", "position", ")", "+", "len", "(", "bytes", ")", "-", "1", "except", "ValueError", ":", "raise", ...
[ 665, 4 ]
[ 672, 19 ]
python
en
['en', 'en', 'en']
True
EncodingParser.__init__
(self, data)
string - the data to work on for encoding detection
string - the data to work on for encoding detection
def __init__(self, data): """string - the data to work on for encoding detection""" self.data = EncodingBytes(data) self.encoding = None
[ "def", "__init__", "(", "self", ",", "data", ")", ":", "self", ".", "data", "=", "EncodingBytes", "(", "data", ")", "self", ".", "encoding", "=", "None" ]
[ 678, 4 ]
[ 681, 28 ]
python
en
['en', 'en', 'en']
True
EncodingParser.handleComment
(self)
Skip over comments
Skip over comments
def handleComment(self): """Skip over comments""" return self.data.jumpTo(b"-->")
[ "def", "handleComment", "(", "self", ")", ":", "return", "self", ".", "data", ".", "jumpTo", "(", "b\"-->\"", ")" ]
[ 713, 4 ]
[ 715, 39 ]
python
en
['en', 'en', 'en']
True
EncodingParser.getAttribute
(self)
Return a name,value pair for the next attribute in the stream, if one is found, or None
Return a name,value pair for the next attribute in the stream, if one is found, or None
def getAttribute(self): """Return a name,value pair for the next attribute in the stream, if one is found, or None""" data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if...
[ "def", "getAttribute", "(", "self", ")", ":", "data", "=", "self", ".", "data", "# Step 1 (skip chars)", "c", "=", "data", ".", "skip", "(", "spaceCharactersBytes", "|", "frozenset", "(", "[", "b\"/\"", "]", ")", ")", "assert", "c", "is", "None", "or", ...
[ 786, 4 ]
[ 860, 35 ]
python
en
['en', 'en', 'en']
True
fix_messages
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
Conceptually, this migration cleans up the old NEW_USER_BOT and FEEDBACK_BOT UserProfile objects (their implementations were removed long ago). We do this by: * Changing their sent messages to have been sent by NOTIFICATION_BOT. * Changing their 1:1 PMs to be PMs with NOTIFICATION_BOT and deleting thei...
Conceptually, this migration cleans up the old NEW_USER_BOT and FEEDBACK_BOT UserProfile objects (their implementations were removed long ago).
def fix_messages(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Conceptually, this migration cleans up the old NEW_USER_BOT and FEEDBACK_BOT UserProfile objects (their implementations were removed long ago). We do this by: * Changing their sent messages to have been sent by NOTIFICAT...
[ "def", "fix_messages", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "UserProfile", "=", "apps", ".", "get_model", "(", "\"zerver\"", ",", "\"UserProfile\"", ")", "Huddle", "=", "apps", ".", "get_mode...
[ 8, 0 ]
[ 77, 12 ]
python
en
['en', 'en', 'en']
True
FileUploadTest.test_rest_endpoint
(self)
Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key
Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key
def test_rest_endpoint(self) -> None: """ Tests the /api/v1/user_uploads API endpoint. Here a single file is uploaded and downloaded using a username and api_key """ fp = StringIO("zulip!") fp.name = "zulip.txt" # Upload file via API result = self.api_pos...
[ "def", "test_rest_endpoint", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "# Upload file via API", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", "(", ...
[ 83, 4 ]
[ 107, 63 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_mobile_api_endpoint
(self)
Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key
Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key
def test_mobile_api_endpoint(self) -> None: """ Tests the /api/v1/user_uploads API endpoint with ?api_key auth. Here a single file is uploaded and downloaded using a username and api_key """ fp = StringIO("zulip!") fp.name = "zulip.txt" # Upload file via ...
[ "def", "test_mobile_api_endpoint", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "# Upload file via API", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", ...
[ 109, 4 ]
[ 136, 41 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_upload_file_with_supplied_mimetype
(self)
When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter.
When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter.
def test_upload_file_with_supplied_mimetype(self) -> None: """ When files are copied into the system clipboard and pasted for upload the filename may not be supplied so the extension is determined from a query string parameter. """ fp = StringIO("zulip!") fp.name ...
[ "def", "test_upload_file_with_supplied_mimetype", "(", "self", ")", "->", "None", ":", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"pasted_file\"", "result", "=", "self", ".", "api_post", "(", "self", ".", "example_user", "(", "\...
[ 138, 4 ]
[ 151, 56 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_file_too_big_failure
(self)
Attempting to upload big files should fail.
Attempting to upload big files should fail.
def test_file_too_big_failure(self) -> None: """ Attempting to upload big files should fail. """ self.login("hamlet") fp = StringIO("bah!") fp.name = "a.txt" # Use MAX_FILE_UPLOAD_SIZE of 0, because the next increment # would be 1MB. with self.set...
[ "def", "test_file_too_big_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", "=", "\"a.txt\"", "# Use MAX_FILE_UPLOAD_SIZE of 0, because the next increment", ...
[ 153, 4 ]
[ 165, 97 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ self.login("hamlet") fp = StringIO("bah!") fp.name = "a.txt" fp2 = StringIO("pshaw!") fp2.name = "b.txt" result = self.client_post("/json/user_uplo...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", "=", "\"a.txt\"", "fp2", "=", "StringIO", "(", "\"pshaw!\"", ")", "f...
[ 167, 4 ]
[ 178, 80 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("hamlet") result = self.client_post("/json/user_uploads") self.assert_json_error(result, "You must specify a file to upload")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/user_uploads\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"You...
[ 180, 4 ]
[ 187, 75 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_file_upload_authed
(self)
A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it.
A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it.
def test_file_upload_authed(self) -> None: """ A call to /json/user_uploads should return a uri and actually create an entry in the database. This entry will be marked unclaimed till a message refers it. """ self.login("hamlet") fp = StringIO("zulip!") fp....
[ "def", "test_file_upload_authed", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "result", "=", "self", ".", "client_post", "(", "...
[ 191, 4 ]
[ 236, 49 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_removed_file_download
(self)
Trying to download deleted files should return 404 error
Trying to download deleted files should return 404 error
def test_removed_file_download(self) -> None: """ Trying to download deleted files should return 404 error """ self.login("hamlet") fp = StringIO("zulip!") fp.name = "zulip.txt" result = self.client_post("/json/user_uploads", {"file": fp}) destroy_uploads...
[ "def", "test_removed_file_download", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!\"", ")", "fp", ".", "name", "=", "\"zulip.txt\"", "result", "=", "self", ".", "client_post", "(", ...
[ 294, 4 ]
[ 306, 51 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_non_existing_file_download
(self)
Trying to download a file that was never uploaded will return a json_error
Trying to download a file that was never uploaded will return a json_error
def test_non_existing_file_download(self) -> None: """ Trying to download a file that was never uploaded will return a json_error """ hamlet = self.example_user("hamlet") self.login_user(hamlet) response = self.client_get( f"http://localhost:9991/user_uploads/...
[ "def", "test_non_existing_file_download", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "hamlet", ")", "response", "=", "self", ".", "client_get", "(", "f\"http://localh...
[ 308, 4 ]
[ 318, 60 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_claim_attachments
(self)
This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry.
This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry.
def test_multiple_claim_attachments(self) -> None: """ This test tries to claim the same attachment twice. The messages field in the Attachment model should have both the messages in its entry. """ self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.tx...
[ "def", "test_multiple_claim_attachments", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", "client_post", ...
[ 366, 4 ]
[ 384, 88 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_multiple_claim_attachments_different_owners
(self)
This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.
This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.
def test_multiple_claim_attachments_different_owners(self) -> None: """This test tries to claim the same attachment more than once, first with a private stream and then with different recipients.""" self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.txt" resu...
[ "def", "test_multiple_claim_attachments_different_owners", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", ...
[ 386, 4 ]
[ 436, 81 ]
python
en
['en', 'en', 'en']
True
FileUploadTest.test_file_name
(self)
Unicode filenames should be processed correctly.
Unicode filenames should be processed correctly.
def test_file_name(self) -> None: """ Unicode filenames should be processed correctly. """ self.login("hamlet") for expected in ["Здравейте.txt", "test"]: fp = StringIO("bah!") fp.name = urllib.parse.quote(expected) result = self.client_post(...
[ "def", "test_file_name", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "for", "expected", "in", "[", "\"Здравейте.txt\", \"test\"]:", "", "", "", "", "fp", "=", "StringIO", "(", "\"bah!\"", ")", "fp", ".", "name", ...
[ 506, 4 ]
[ 516, 66 ]
python
en
['en', 'error', 'th']
False
FileUploadTest.test_realm_quota
(self)
Realm quota for uploading should not be exceeded.
Realm quota for uploading should not be exceeded.
def test_realm_quota(self) -> None: """ Realm quota for uploading should not be exceeded. """ self.login("hamlet") d1 = StringIO("zulip!") d1.name = "dummy_1.txt" result = self.client_post("/json/user_uploads", {"file": d1}) d1_path_id = re.sub("/user_upl...
[ "def", "test_realm_quota", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "d1", "=", "StringIO", "(", "\"zulip!\"", ")", "d1", ".", "name", "=", "\"dummy_1.txt\"", "result", "=", "self", ".", "client_post", "(", "\"/js...
[ 518, 4 ]
[ 556, 40 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_avatar_url
(self)
Verifies URL schemes for avatars and realm icons.
Verifies URL schemes for avatars and realm icons.
def test_avatar_url(self) -> None: """Verifies URL schemes for avatars and realm icons.""" backend: ZulipUploadBackend = LocalUploadBackend() self.assertEqual(backend.get_avatar_url("hash", False), "/user_avatars/hash.png?x=x") self.assertEqual(backend.get_avatar_url("hash", True), "/use...
[ "def", "test_avatar_url", "(", "self", ")", "->", "None", ":", "backend", ":", "ZulipUploadBackend", "=", "LocalUploadBackend", "(", ")", "self", ".", "assertEqual", "(", "backend", ".", "get_avatar_url", "(", "\"hash\"", ",", "False", ")", ",", "\"/user_avata...
[ 911, 4 ]
[ 947, 13 ]
python
en
['en', 'en', 'en']
True
AvatarTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ self.login("hamlet") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post("/json/users/me/avatar", {"f1": fp1, "...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp2", ":"...
[ 949, 4 ]
[ 956, 77 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("hamlet") result = self.client_post("/json/users/me/avatar") self.assert_json_error(result, "You must upload exactly one avatar.")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/users/me/avatar\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"...
[ 958, 4 ]
[ 965, 77 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_avatar_changes_disabled_failure
(self)
Attempting to upload avatar on a realm with avatar changes disabled should fail.
Attempting to upload avatar on a realm with avatar changes disabled should fail.
def test_avatar_changes_disabled_failure(self) -> None: """ Attempting to upload avatar on a realm with avatar changes disabled should fail. """ self.login("cordelia") do_set_realm_property( self.example_user("cordelia").realm, "avatar_changes_disabled", ...
[ "def", "test_avatar_changes_disabled_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"cordelia\"", ")", "do_set_realm_property", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ".", "realm", ",", "\"avatar_changes_disabled\"",...
[ 967, 4 ]
[ 981, 91 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_valid_avatars
(self)
A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar.
A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar.
def test_valid_avatars(self) -> None: """ A PUT request to /json/users/me/avatar with a valid file should return a URL and actually create an avatar. """ version = 2 for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 b...
[ "def", "test_valid_avatars", "(", "self", ")", "->", "None", ":", "version", "=", "2", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest...
[ 1102, 4 ]
[ 1144, 24 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_invalid_avatars
(self)
A PUT request to /json/users/me/avatar with an invalid file should fail.
A PUT request to /json/users/me/avatar with an invalid file should fail.
def test_invalid_avatars(self) -> None: """ A PUT request to /json/users/me/avatar with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("hamlet") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_avatars", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"hamlet\"", ")", "with", "get_test_image_file", "(", "fname", ")", "as"...
[ 1199, 4 ]
[ 1211, 60 ]
python
en
['en', 'error', 'th']
False
AvatarTest.test_delete_avatar
(self)
A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL
A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL
def test_delete_avatar(self) -> None: """ A DELETE request to /json/users/me/avatar should delete the profile picture and return gravatar URL """ self.login("cordelia") cordelia = self.example_user("cordelia") cordelia.avatar_source = UserProfile.AVATAR_FROM_USER ...
[ "def", "test_delete_avatar", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"cordelia\"", ")", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "cordelia", ".", "avatar_source", "=", "UserProfile", ".", "AVATAR_FROM_US...
[ 1213, 4 ]
[ 1235, 56 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ # Log in as admin self.login("iago") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post("/json/realm/i...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "# Log in as admin", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", ...
[ 1297, 4 ]
[ 1305, 75 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("iago") result = self.client_post("/json/realm/icon") self.assert_json_error(result, "You must upload exactly one icon.")
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/realm/icon\"", ")", "self", ".", "assert_json_error", "(", "result", ",", "\"You mus...
[ 1307, 4 ]
[ 1314, 75 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_valid_icons
(self)
A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon.
A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon.
def test_valid_icons(self) -> None: """ A PUT request to /json/realm/icon with a valid file should return a URL and actually create an realm icon. """ for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 by uncommenting ...
[ "def", "test_valid_icons", "(", "self", ")", "->", "None", ":", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest(fname=fname):", "self", ...
[ 1354, 4 ]
[ 1375, 79 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_invalid_icons
(self)
A PUT request to /json/realm/icon with an invalid file should fail.
A PUT request to /json/realm/icon with an invalid file should fail.
def test_invalid_icons(self) -> None: """ A PUT request to /json/realm/icon with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("iago") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_icons", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "fname", ")", "as", ...
[ 1377, 4 ]
[ 1387, 99 ]
python
en
['en', 'error', 'th']
False
RealmIconTest.test_delete_icon
(self)
A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL
A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL
def test_delete_icon(self) -> None: """ A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL """ self.login("iago") realm = get_realm("zulip") do_change_icon_source(realm, Realm.ICON_UPLOADED, acting_user=None) result = self.c...
[ "def", "test_delete_icon", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "do_change_icon_source", "(", "realm", ",", "Realm", ".", "ICON_UPLOADED", ",", "acting_user", "=", ...
[ 1389, 4 ]
[ 1403, 69 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_multiple_upload_failure
(self)
Attempting to upload two files should fail.
Attempting to upload two files should fail.
def test_multiple_upload_failure(self) -> None: """ Attempting to upload two files should fail. """ # Log in as admin self.login("iago") with get_test_image_file("img.png") as fp1, get_test_image_file("img.png") as fp2: result = self.client_post( ...
[ "def", "test_multiple_upload_failure", "(", "self", ")", "->", "None", ":", "# Log in as admin", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "\"img.png\"", ")", "as", "fp1", ",", "get_test_image_file", "(", "\"img.png\"", ")", ...
[ 1430, 4 ]
[ 1441, 75 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_no_file_upload_failure
(self)
Calling this endpoint with no files should fail.
Calling this endpoint with no files should fail.
def test_no_file_upload_failure(self) -> None: """ Calling this endpoint with no files should fail. """ self.login("iago") result = self.client_post("/json/realm/logo", {"night": orjson.dumps(self.night).decode()}) self.assert_json_error(result, "You must upload exactly ...
[ "def", "test_no_file_upload_failure", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"iago\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/realm/logo\"", ",", "{", "\"night\"", ":", "orjson", ".", "dumps", "(", "self", ...
[ 1443, 4 ]
[ 1450, 75 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_valid_logos
(self)
A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo.
A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo.
def test_valid_logos(self) -> None: """ A PUT request to /json/realm/logo with a valid file should return a URL and actually create an realm logo. """ for fname, rfname in self.correct_files: # TODO: use self.subTest once we're exclusively on python 3 by uncommenting ...
[ "def", "test_valid_logos", "(", "self", ")", "->", "None", ":", "for", "fname", ",", "rfname", "in", "self", ".", "correct_files", ":", "# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.", "# with self.subTest(fname=fname):", "self", ...
[ 1526, 4 ]
[ 1548, 79 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_invalid_logo_upload
(self)
A PUT request to /json/realm/logo with an invalid file should fail.
A PUT request to /json/realm/logo with an invalid file should fail.
def test_invalid_logo_upload(self) -> None: """ A PUT request to /json/realm/logo with an invalid file should fail. """ for fname in self.corrupt_files: # with self.subTest(fname=fname): self.login("iago") with get_test_image_file(fname) as fp: ...
[ "def", "test_invalid_logo_upload", "(", "self", ")", "->", "None", ":", "for", "fname", "in", "self", ".", "corrupt_files", ":", "# with self.subTest(fname=fname):", "self", ".", "login", "(", "\"iago\"", ")", "with", "get_test_image_file", "(", "fname", ")", "a...
[ 1550, 4 ]
[ 1562, 99 ]
python
en
['en', 'error', 'th']
False
RealmLogoTest.test_delete_logo
(self)
A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL
A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL
def test_delete_logo(self) -> None: """ A DELETE request to /json/realm/logo should delete the realm logo and return gravatar URL """ user_profile = self.example_user("iago") self.login_user(user_profile) realm = user_profile.realm do_change_logo_source(realm, Rea...
[ "def", "test_delete_logo", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "realm", "=", "user_profile", ".", "realm", "do_change_logo_source", "(...
[ 1564, 4 ]
[ 1580, 67 ]
python
en
['en', 'error', 'th']
False
S3Test.test_file_upload_authed
(self)
A call to /json/user_uploads should return a uri and actually create an object.
A call to /json/user_uploads should return a uri and actually create an object.
def test_file_upload_authed(self) -> None: """ A call to /json/user_uploads should return a uri and actually create an object. """ bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0] self.login("hamlet") fp = StringIO("zulip!") fp.name = "zulip.txt" ...
[ "def", "test_file_upload_authed", "(", "self", ")", "->", "None", ":", "bucket", "=", "create_s3_buckets", "(", "settings", ".", "S3_AUTH_UPLOADS_BUCKET", ")", "[", "0", "]", "self", ".", "login", "(", "\"hamlet\"", ")", "fp", "=", "StringIO", "(", "\"zulip!...
[ 1797, 4 ]
[ 1838, 86 ]
python
en
['en', 'error', 'th']
False
config_file
(kind="local")
Get the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user"
Get the filename of the distutils, local, global, or per-user config
def config_file(kind="local"): """Get the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user" """ if kind == 'local': return 'setup.cfg' if kind == 'global': return os.path.join( os.path.dirname(distutils.__file...
[ "def", "config_file", "(", "kind", "=", "\"local\"", ")", ":", "if", "kind", "==", "'local'", ":", "return", "'setup.cfg'", "if", "kind", "==", "'global'", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "d...
[ 12, 0 ]
[ 28, 5 ]
python
en
['en', 'en', 'en']
True
edit_config
(filename, settings, dry_run=False)
Edit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to ...
Edit a configuration file to include `settings`
def edit_config(filename, settings, dry_run=False): """Edit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or d...
[ "def", "edit_config", "(", "filename", ",", "settings", ",", "dry_run", "=", "False", ")", ":", "log", ".", "debug", "(", "\"Reading configuration from %s\"", ",", "filename", ")", "opts", "=", "configparser", ".", "RawConfigParser", "(", ")", "opts", ".", "...
[ 31, 0 ]
[ 71, 25 ]
python
en
['en', 'en', 'en']
True
State.set
(self, state)
Set a new state.
Set a new state.
def set(self, state): """ Set a new state. """ self.append(state)
[ "def", "set", "(", "self", ",", "state", ")", ":", "self", ".", "append", "(", "state", ")" ]
[ 21, 4 ]
[ 23, 26 ]
python
en
['en', 'en', 'en']
True
State.reset
(self)
Step back one step in nested state.
Step back one step in nested state.
def reset(self): """ Step back one step in nested state. """ self.pop()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "pop", "(", ")" ]
[ 25, 4 ]
[ 27, 18 ]
python
en
['en', 'en', 'en']
True
State.isstate
(self, state)
Test that top (current) level is of given state.
Test that top (current) level is of given state.
def isstate(self, state): """ Test that top (current) level is of given state. """ if len(self): return self[-1] == state else: return False
[ "def", "isstate", "(", "self", ",", "state", ")", ":", "if", "len", "(", "self", ")", ":", "return", "self", "[", "-", "1", "]", "==", "state", "else", ":", "return", "False" ]
[ 29, 4 ]
[ 34, 24 ]
python
en
['en', 'en', 'en']
True
BlockParser.parseDocument
(self, lines)
Parse a markdown document into an ElementTree. Given a list of lines, an ElementTree object (not just a parent Element) is created and the root element is passed to the parser as the parent. The ElementTree object is returned. This should only be called on an entire d...
Parse a markdown document into an ElementTree. Given a list of lines, an ElementTree object (not just a parent Element) is created and the root element is passed to the parser as the parent. The ElementTree object is returned. This should only be called on an entire d...
def parseDocument(self, lines): """ Parse a markdown document into an ElementTree. Given a list of lines, an ElementTree object (not just a parent Element) is created and the root element is passed to the parser as the parent. The ElementTree object is returned. ...
[ "def", "parseDocument", "(", "self", ",", "lines", ")", ":", "# Create a ElementTree from the lines", "self", ".", "root", "=", "markdown", ".", "etree", ".", "Element", "(", "markdown", ".", "DOC_TAG", ")", "self", ".", "parseChunk", "(", "self", ".", "root...
[ 47, 4 ]
[ 60, 52 ]
python
en
['en', 'en', 'en']
True
BlockParser.parseChunk
(self, parent, text)
Parse a chunk of markdown text and attach to given etree node. While the ``text`` argument is generally assumed to contain multiple blocks which will be split on blank lines, it could contain only one block. Generally, this method would be called by extensions when block parsi...
Parse a chunk of markdown text and attach to given etree node. While the ``text`` argument is generally assumed to contain multiple blocks which will be split on blank lines, it could contain only one block. Generally, this method would be called by extensions when block parsi...
def parseChunk(self, parent, text): """ Parse a chunk of markdown text and attach to given etree node. While the ``text`` argument is generally assumed to contain multiple blocks which will be split on blank lines, it could contain only one block. Generally, this method would b...
[ "def", "parseChunk", "(", "self", ",", "parent", ",", "text", ")", ":", "self", ".", "parseBlocks", "(", "parent", ",", "text", ".", "split", "(", "'\\n\\n'", ")", ")" ]
[ 62, 4 ]
[ 74, 52 ]
python
en
['en', 'en', 'en']
True
BlockParser.parseBlocks
(self, parent, blocks)
Process blocks of markdown text and attach to given etree node. Given a list of ``blocks``, each blockprocessor is stepped through until there are no blocks left. While an extension could potentially call this method directly, it's generally expected to be used internally. Th...
Process blocks of markdown text and attach to given etree node. Given a list of ``blocks``, each blockprocessor is stepped through until there are no blocks left. While an extension could potentially call this method directly, it's generally expected to be used internally.
def parseBlocks(self, parent, blocks): """ Process blocks of markdown text and attach to given etree node. Given a list of ``blocks``, each blockprocessor is stepped through until there are no blocks left. While an extension could potentially call this method directly, it's gen...
[ "def", "parseBlocks", "(", "self", ",", "parent", ",", "blocks", ")", ":", "while", "blocks", ":", "for", "processor", "in", "self", ".", "blockprocessors", ".", "values", "(", ")", ":", "if", "processor", ".", "test", "(", "parent", ",", "blocks", "["...
[ 76, 4 ]
[ 92, 24 ]
python
en
['en', 'en', 'en']
True
test_teardown_issue1649
(testdir)
Are TestCase objects cleaned up? Often unittest TestCase objects set attributes that are large and expensive during setUp. The TestCase will not be cleaned up if the test fails, because it would then exist in the stackframe.
Are TestCase objects cleaned up? Often unittest TestCase objects set attributes that are large and expensive during setUp.
def test_teardown_issue1649(testdir): """ Are TestCase objects cleaned up? Often unittest TestCase objects set attributes that are large and expensive during setUp. The TestCase will not be cleaned up if the test fails, because it would then exist in the stackframe. """ testpath = testdir.m...
[ "def", "test_teardown_issue1649", "(", "testdir", ")", ":", "testpath", "=", "testdir", ".", "makepyfile", "(", "\"\"\"\n import unittest\n class TestCaseObjectsShouldBeCleanedUp(unittest.TestCase):\n def setUp(self):\n self.an_expensive_object = 1\n ...
[ 147, 0 ]
[ 167, 71 ]
python
en
['en', 'error', 'th']
False
makeExtension
(configs=[])
Return an instance of the FootnoteExtension
Return an instance of the FootnoteExtension
def makeExtension(configs=[]): """ Return an instance of the FootnoteExtension """ return FootnoteExtension(configs=configs)
[ "def", "makeExtension", "(", "configs", "=", "[", "]", ")", ":", "return", "FootnoteExtension", "(", "configs", "=", "configs", ")" ]
[ 303, 0 ]
[ 305, 45 ]
python
en
['en', 'en', 'en']
True
FootnoteExtension.__init__
(self, configs)
Setup configs.
Setup configs.
def __init__ (self, configs): """ Setup configs. """ self.config = {'PLACE_MARKER': ["///Footnotes Go Here///", "The text string that marks where the footnotes go"], 'UNIQUE_IDS': [False, ...
[ "def", "__init__", "(", "self", ",", "configs", ")", ":", "self", ".", "config", "=", "{", "'PLACE_MARKER'", ":", "[", "\"///Footnotes Go Here///\"", ",", "\"The text string that marks where the footnotes go\"", "]", ",", "'UNIQUE_IDS'", ":", "[", "False", ",", "\...
[ 36, 4 ]
[ 52, 20 ]
python
en
['en', 'mk', 'en']
False
FootnoteExtension.extendMarkdown
(self, md, md_globals)
Add pieces to Markdown.
Add pieces to Markdown.
def extendMarkdown(self, md, md_globals): """ Add pieces to Markdown. """ md.registerExtension(self) self.parser = md.parser # Insert a preprocessor before ReferencePreprocessor md.preprocessors.add("footnote", FootnotePreprocessor(self), "<reference"...
[ "def", "extendMarkdown", "(", "self", ",", "md", ",", "md_globals", ")", ":", "md", ".", "registerExtension", "(", "self", ")", "self", ".", "parser", "=", "md", ".", "parser", "# Insert a preprocessor before ReferencePreprocessor", "md", ".", "preprocessors", "...
[ 54, 4 ]
[ 72, 52 ]
python
en
['en', 'en', 'en']
True
FootnoteExtension.reset
(self)
Clear the footnotes on reset, and prepare for a distinct document.
Clear the footnotes on reset, and prepare for a distinct document.
def reset(self): """ Clear the footnotes on reset, and prepare for a distinct document. """ self.footnotes = markdown.odict.OrderedDict() self.unique_prefix += 1
[ "def", "reset", "(", "self", ")", ":", "self", ".", "footnotes", "=", "markdown", ".", "odict", ".", "OrderedDict", "(", ")", "self", ".", "unique_prefix", "+=", "1" ]
[ 74, 4 ]
[ 77, 31 ]
python
en
['en', 'en', 'en']
True
FootnoteExtension.findFootnotesPlaceholder
(self, root)
Return ElementTree Element that contains Footnote placeholder.
Return ElementTree Element that contains Footnote placeholder.
def findFootnotesPlaceholder(self, root): """ Return ElementTree Element that contains Footnote placeholder. """ def finder(element): for child in element: if child.text: if child.text.find(self.getConfig("PLACE_MARKER")) > -1: retu...
[ "def", "findFootnotesPlaceholder", "(", "self", ",", "root", ")", ":", "def", "finder", "(", "element", ")", ":", "for", "child", "in", "element", ":", "if", "child", ".", "text", ":", "if", "child", ".", "text", ".", "find", "(", "self", ".", "getCo...
[ 79, 4 ]
[ 93, 18 ]
python
en
['en', 'en', 'en']
True
FootnoteExtension.setFootnote
(self, id, text)
Store a footnote for later retrieval.
Store a footnote for later retrieval.
def setFootnote(self, id, text): """ Store a footnote for later retrieval. """ self.footnotes[id] = text
[ "def", "setFootnote", "(", "self", ",", "id", ",", "text", ")", ":", "self", ".", "footnotes", "[", "id", "]", "=", "text" ]
[ 95, 4 ]
[ 97, 33 ]
python
en
['en', 'en', 'en']
True
FootnoteExtension.makeFootnoteId
(self, id)
Return footnote link id.
Return footnote link id.
def makeFootnoteId(self, id): """ Return footnote link id. """ if self.getConfig("UNIQUE_IDS"): return 'fn:%d-%s' % (self.unique_prefix, id) else: return 'fn:%s' % id
[ "def", "makeFootnoteId", "(", "self", ",", "id", ")", ":", "if", "self", ".", "getConfig", "(", "\"UNIQUE_IDS\"", ")", ":", "return", "'fn:%d-%s'", "%", "(", "self", ".", "unique_prefix", ",", "id", ")", "else", ":", "return", "'fn:%s'", "%", "id" ]
[ 99, 4 ]
[ 104, 31 ]
python
af
['hr', 'af', 'en']
False
FootnoteExtension.makeFootnoteRefId
(self, id)
Return footnote back-link id.
Return footnote back-link id.
def makeFootnoteRefId(self, id): """ Return footnote back-link id. """ if self.getConfig("UNIQUE_IDS"): return 'fnref:%d-%s' % (self.unique_prefix, id) else: return 'fnref:%s' % id
[ "def", "makeFootnoteRefId", "(", "self", ",", "id", ")", ":", "if", "self", ".", "getConfig", "(", "\"UNIQUE_IDS\"", ")", ":", "return", "'fnref:%d-%s'", "%", "(", "self", ".", "unique_prefix", ",", "id", ")", "else", ":", "return", "'fnref:%s'", "%", "i...
[ 106, 4 ]
[ 111, 34 ]
python
en
['en', 'da', 'en']
True
FootnoteExtension.makeFootnotesDiv
(self, root)
Return div of footnotes as et Element.
Return div of footnotes as et Element.
def makeFootnotesDiv(self, root): """ Return div of footnotes as et Element. """ if not self.footnotes.keys(): return None div = etree.Element("div") div.set('class', 'footnote') hr = etree.SubElement(div, "hr") ol = etree.SubElement(div, "ol") for ...
[ "def", "makeFootnotesDiv", "(", "self", ",", "root", ")", ":", "if", "not", "self", ".", "footnotes", ".", "keys", "(", ")", ":", "return", "None", "div", "=", "etree", ".", "Element", "(", "\"div\"", ")", "div", ".", "set", "(", "'class'", ",", "'...
[ 113, 4 ]
[ 143, 18 ]
python
en
['en', 'da', 'en']
True
FootnotePreprocessor._handleFootnoteDefinitions
(self, lines)
Recursively find all footnote definitions in lines. Keywords: * lines: A list of lines of text Return: A list of lines with footnote definitions removed.
Recursively find all footnote definitions in lines.
def _handleFootnoteDefinitions(self, lines): """ Recursively find all footnote definitions in lines. Keywords: * lines: A list of lines of text Return: A list of lines with footnote definitions removed. """ i, id, footnote = self._findFootnoteD...
[ "def", "_handleFootnoteDefinitions", "(", "self", ",", "lines", ")", ":", "i", ",", "id", ",", "footnote", "=", "self", ".", "_findFootnoteDefinition", "(", "lines", ")", "if", "id", ":", "plain", "=", "lines", "[", ":", "i", "]", "detabbed", ",", "the...
[ 157, 4 ]
[ 179, 24 ]
python
en
['en', 'error', 'th']
False
FootnotePreprocessor._findFootnoteDefinition
(self, lines)
Find the parts of a footnote definition. Keywords: * lines: A list of lines of text. Return: A three item tuple containing the index of the first line of a footnote definition, the id of the definition and the body of the definition.
Find the parts of a footnote definition.
def _findFootnoteDefinition(self, lines): """ Find the parts of a footnote definition. Keywords: * lines: A list of lines of text. Return: A three item tuple containing the index of the first line of a footnote definition, the id of the definition and the body of the ...
[ "def", "_findFootnoteDefinition", "(", "self", ",", "lines", ")", ":", "counter", "=", "0", "for", "line", "in", "lines", ":", "m", "=", "DEF_RE", ".", "match", "(", "line", ")", "if", "m", ":", "return", "counter", ",", "m", ".", "group", "(", "2"...
[ 181, 4 ]
[ 200, 34 ]
python
en
['en', 'error', 'th']
False
FootnotePreprocessor.detectTabbed
(self, lines)
Find indented text and remove indent before further proccesing. Keyword arguments: * lines: an array of strings Returns: a list of post processed items and the unused remainder of the original list
Find indented text and remove indent before further proccesing.
def detectTabbed(self, lines): """ Find indented text and remove indent before further proccesing. Keyword arguments: * lines: an array of strings Returns: a list of post processed items and the unused remainder of the original list """ items = [] item...
[ "def", "detectTabbed", "(", "self", ",", "lines", ")", ":", "items", "=", "[", "]", "item", "=", "-", "1", "i", "=", "0", "# to keep track of where we are", "def", "detab", "(", "line", ")", ":", "match", "=", "TABBED_RE", ".", "match", "(", "line", ...
[ 202, 4 ]
[ 251, 31 ]
python
en
['en', 'en', 'en']
True
Request.__init__
(self, url, message=None)
@param url: The url for the request. @type url: str @param message: The (optional) message to be send in the request. @type message: str
def __init__(self, url, message=None): """ @param url: The url for the request. @type url: str @param message: The (optional) message to be send in the request. @type message: str """ self.url = url self.headers = {} self.message = message
[ "def", "__init__", "(", "self", ",", "url", ",", "message", "=", "None", ")", ":", "self", ".", "url", "=", "url", "self", ".", "headers", "=", "{", "}", "self", ".", "message", "=", "message" ]
[ 38, 4 ]
[ 47, 30 ]
python
en
['en', 'error', 'th']
False
Reply.__init__
(self, code, headers, message)
@param code: The http code returned. @type code: int @param headers: The http returned headers. @type headers: dict @param message: The (optional) reply message received. @type message: str
def __init__(self, code, headers, message): """ @param code: The http code returned. @type code: int @param headers: The http returned headers. @type headers: dict @param message: The (optional) reply message received. @type message: str """ self.c...
[ "def", "__init__", "(", "self", ",", "code", ",", "headers", ",", "message", ")", ":", "self", ".", "code", "=", "code", "self", ".", "headers", "=", "headers", "self", ".", "message", "=", "message" ]
[ 69, 4 ]
[ 80, 30 ]
python
en
['en', 'error', 'th']
False
Transport.__init__
(self)
Constructor.
Constructor.
def __init__(self): """ Constructor. """ from suds.transport.options import Options self.options = Options() del Options
[ "def", "__init__", "(", "self", ")", ":", "from", "suds", ".", "transport", ".", "options", "import", "Options", "self", ".", "options", "=", "Options", "(", ")", "del", "Options" ]
[ 96, 4 ]
[ 102, 19 ]
python
en
['en', 'error', 'th']
False
Transport.open
(self, request)
Open the url in the specified request. @param request: A transport request. @type request: L{Request} @return: An input stream. @rtype: stream @raise TransportError: On all transport errors.
Open the url in the specified request.
def open(self, request): """ Open the url in the specified request. @param request: A transport request. @type request: L{Request} @return: An input stream. @rtype: stream @raise TransportError: On all transport errors. """ raise Exception('not-imp...
[ "def", "open", "(", "self", ",", "request", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 104, 4 ]
[ 113, 42 ]
python
en
['en', 'error', 'th']
False
Transport.send
(self, request)
Send soap message. Implementations are expected to handle: - proxies - I{http} headers - cookies - sending message - brokering exceptions into L{TransportError} @param request: A transport request. @type request: L{Request} @r...
Send soap message. Implementations are expected to handle: - proxies - I{http} headers - cookies - sending message - brokering exceptions into L{TransportError}
def send(self, request): """ Send soap message. Implementations are expected to handle: - proxies - I{http} headers - cookies - sending message - brokering exceptions into L{TransportError} @param request: A transport request. ...
[ "def", "send", "(", "self", ",", "request", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 115, 4 ]
[ 129, 42 ]
python
en
['en', 'error', 'th']
False