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
ZipProvider._is_current
(self, file_path, zip_path)
Return True if the file_path is current for this zip_path
Return True if the file_path is current for this zip_path
def _is_current(self, file_path, zip_path): """ Return True if the file_path is current for this zip_path """ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not os.path.isfile(file_path): return False stat = os.stat(file_path) if ...
[ "def", "_is_current", "(", "self", ",", "file_path", ",", "zip_path", ")", ":", "timestamp", ",", "size", "=", "self", ".", "_get_date_and_size", "(", "self", ".", "zipinfo", "[", "zip_path", "]", ")", "if", "not", "os", ".", "path", ".", "isfile", "("...
[ 1809, 4 ]
[ 1823, 44 ]
python
en
['en', 'error', 'th']
False
EggMetadata.__init__
(self, importer)
Create a metadata provider from a zipimporter
Create a metadata provider from a zipimporter
def __init__(self, importer): """Create a metadata provider from a zipimporter""" self.zip_pre = importer.archive + os.sep self.loader = importer if importer.prefix: self.module_path = os.path.join(importer.archive, importer.prefix) else: self.module_path...
[ "def", "__init__", "(", "self", ",", "importer", ")", ":", "self", ".", "zip_pre", "=", "importer", ".", "archive", "+", "os", ".", "sep", "self", ".", "loader", "=", "importer", "if", "importer", ".", "prefix", ":", "self", ".", "module_path", "=", ...
[ 1941, 4 ]
[ 1950, 28 ]
python
en
['en', 'en', 'en']
True
EntryPoint.load
(self, require=True, *args, **kwargs)
Require packages for this EntryPoint, then resolve it.
Require packages for this EntryPoint, then resolve it.
def load(self, require=True, *args, **kwargs): """ Require packages for this EntryPoint, then resolve it. """ if not require or args or kwargs: warnings.warn( "Parameters to load are deprecated. Call .resolve and " ".require separately.", ...
[ "def", "load", "(", "self", ",", "require", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "require", "or", "args", "or", "kwargs", ":", "warnings", ".", "warn", "(", "\"Parameters to load are deprecated. Call .resolve and \"...
[ 2429, 4 ]
[ 2442, 29 ]
python
en
['en', 'error', 'th']
False
EntryPoint.resolve
(self)
Resolve the entry point from its module and attrs.
Resolve the entry point from its module and attrs.
def resolve(self): """ Resolve the entry point from its module and attrs. """ module = __import__(self.module_name, fromlist=['__name__'], level=0) try: return functools.reduce(getattr, self.attrs, module) except AttributeError as exc: raise Import...
[ "def", "resolve", "(", "self", ")", ":", "module", "=", "__import__", "(", "self", ".", "module_name", ",", "fromlist", "=", "[", "'__name__'", "]", ",", "level", "=", "0", ")", "try", ":", "return", "functools", ".", "reduce", "(", "getattr", ",", "...
[ 2444, 4 ]
[ 2452, 39 ]
python
en
['en', 'error', 'th']
False
EntryPoint.parse
(cls, src, dist=None)
Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional
Parse a single entry point from string `src`
def parse(cls, src, dist=None): """Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional "...
[ "def", "parse", "(", "cls", ",", "src", ",", "dist", "=", "None", ")", ":", "m", "=", "cls", ".", "pattern", ".", "match", "(", "src", ")", "if", "not", "m", ":", "msg", "=", "\"EntryPoint must be in 'name=module:attrs [extras]' format\"", "raise", "ValueE...
[ 2477, 4 ]
[ 2494, 67 ]
python
en
['en', 'en', 'en']
True
EntryPoint.parse_group
(cls, group, lines, dist=None)
Parse an entry point group
Parse an entry point group
def parse_group(cls, group, lines, dist=None): """Parse an entry point group""" if not MODULE(group): raise ValueError("Invalid group name", group) this = {} for line in yield_lines(lines): ep = cls.parse(line, dist) if ep.name in this: ...
[ "def", "parse_group", "(", "cls", ",", "group", ",", "lines", ",", "dist", "=", "None", ")", ":", "if", "not", "MODULE", "(", "group", ")", ":", "raise", "ValueError", "(", "\"Invalid group name\"", ",", "group", ")", "this", "=", "{", "}", "for", "l...
[ 2506, 4 ]
[ 2516, 19 ]
python
en
['en', 'en', 'en']
True
EntryPoint.parse_map
(cls, data, dist=None)
Parse a map of entry point groups
Parse a map of entry point groups
def parse_map(cls, data, dist=None): """Parse a map of entry point groups""" if isinstance(data, dict): data = data.items() else: data = split_sections(data) maps = {} for group, lines in data: if group is None: if not lines: ...
[ "def", "parse_map", "(", "cls", ",", "data", ",", "dist", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "data", "=", "data", ".", "items", "(", ")", "else", ":", "data", "=", "split_sections", "(", "data", ")", "m...
[ 2519, 4 ]
[ 2535, 19 ]
python
en
['en', 'en', 'en']
True
Distribution._dep_map
(self)
A map of extra to its list of (direct) requirements for this distribution, including the null extra.
A map of extra to its list of (direct) requirements for this distribution, including the null extra.
def _dep_map(self): """ A map of extra to its list of (direct) requirements for this distribution, including the null extra. """ try: return self.__dep_map except AttributeError: self.__dep_map = self._filter_extras(self._build_dep_map()) r...
[ "def", "_dep_map", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dep_map", "except", "AttributeError", ":", "self", ".", "__dep_map", "=", "self", ".", "_filter_extras", "(", "self", ".", "_build_dep_map", "(", ")", ")", "return", "self", ...
[ 2693, 4 ]
[ 2702, 29 ]
python
en
['en', 'error', 'th']
False
Distribution._filter_extras
(dm)
Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers.
Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers.
def _filter_extras(dm): """ Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers. """ for extra in list(filter(None, dm)): new_extra = extra reqs = dm.pop(extra) ...
[ "def", "_filter_extras", "(", "dm", ")", ":", "for", "extra", "in", "list", "(", "filter", "(", "None", ",", "dm", ")", ")", ":", "new_extra", "=", "extra", "reqs", "=", "dm", ".", "pop", "(", "extra", ")", "new_extra", ",", "_", ",", "marker", "...
[ 2705, 4 ]
[ 2724, 17 ]
python
en
['en', 'error', 'th']
False
Distribution.requires
(self, extras=())
List of Requirements needed for this distro if `extras` are used
List of Requirements needed for this distro if `extras` are used
def requires(self, extras=()): """List of Requirements needed for this distro if `extras` are used""" dm = self._dep_map deps = [] deps.extend(dm.get(None, ())) for ext in extras: try: deps.extend(dm[safe_extra(ext)]) except KeyError: ...
[ "def", "requires", "(", "self", ",", "extras", "=", "(", ")", ")", ":", "dm", "=", "self", ".", "_dep_map", "deps", "=", "[", "]", "deps", ".", "extend", "(", "dm", ".", "get", "(", "None", ",", "(", ")", ")", ")", "for", "ext", "in", "extras...
[ 2733, 4 ]
[ 2745, 19 ]
python
en
['en', 'en', 'en']
True
Distribution._get_metadata_path_for_display
(self, name)
Return the path to the given metadata file, if available.
Return the path to the given metadata file, if available.
def _get_metadata_path_for_display(self, name): """ Return the path to the given metadata file, if available. """ try: # We need to access _get_metadata_path() on the provider object # directly rather than through this class's __getattr__() # since _ge...
[ "def", "_get_metadata_path_for_display", "(", "self", ",", "name", ")", ":", "try", ":", "# We need to access _get_metadata_path() on the provider object", "# directly rather than through this class's __getattr__()", "# since _get_metadata_path() is marked private.", "path", "=", "self...
[ 2747, 4 ]
[ 2762, 19 ]
python
en
['en', 'error', 'th']
False
Distribution.activate
(self, path=None, replace=False)
Ensure distribution is importable on `path` (default=sys.path)
Ensure distribution is importable on `path` (default=sys.path)
def activate(self, path=None, replace=False): """Ensure distribution is importable on `path` (default=sys.path)""" if path is None: path = sys.path self.insert_on(path, replace=replace) if path is sys.path: fixup_namespace_packages(self.location) for p...
[ "def", "activate", "(", "self", ",", "path", "=", "None", ",", "replace", "=", "False", ")", ":", "if", "path", "is", "None", ":", "path", "=", "sys", ".", "path", "self", ".", "insert_on", "(", "path", ",", "replace", "=", "replace", ")", "if", ...
[ 2775, 4 ]
[ 2784, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.egg_name
(self)
Return what this distribution's standard .egg filename should be
Return what this distribution's standard .egg filename should be
def egg_name(self): """Return what this distribution's standard .egg filename should be""" filename = "%s-%s-py%s" % ( to_filename(self.project_name), to_filename(self.version), self.py_version or PY_MAJOR ) if self.platform: filename += '-' + self.pl...
[ "def", "egg_name", "(", "self", ")", ":", "filename", "=", "\"%s-%s-py%s\"", "%", "(", "to_filename", "(", "self", ".", "project_name", ")", ",", "to_filename", "(", "self", ".", "version", ")", ",", "self", ".", "py_version", "or", "PY_MAJOR", ")", "if"...
[ 2786, 4 ]
[ 2795, 23 ]
python
en
['en', 'en', 'en']
True
Distribution.__getattr__
(self, attr)
Delegate all unrecognized public attributes to .metadata provider
Delegate all unrecognized public attributes to .metadata provider
def __getattr__(self, attr): """Delegate all unrecognized public attributes to .metadata provider""" if attr.startswith('_'): raise AttributeError(attr) return getattr(self._provider, attr)
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "if", "attr", ".", "startswith", "(", "'_'", ")", ":", "raise", "AttributeError", "(", "attr", ")", "return", "getattr", "(", "self", ".", "_provider", ",", "attr", ")" ]
[ 2811, 4 ]
[ 2815, 44 ]
python
en
['en', 'it', 'en']
True
Distribution.as_requirement
(self)
Return a ``Requirement`` that matches this distribution exactly
Return a ``Requirement`` that matches this distribution exactly
def as_requirement(self): """Return a ``Requirement`` that matches this distribution exactly""" if isinstance(self.parsed_version, packaging.version.Version): spec = "%s==%s" % (self.project_name, self.parsed_version) else: spec = "%s===%s" % (self.project_name, self.pars...
[ "def", "as_requirement", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "parsed_version", ",", "packaging", ".", "version", ".", "Version", ")", ":", "spec", "=", "\"%s==%s\"", "%", "(", "self", ".", "project_name", ",", "self", ".", "parse...
[ 2837, 4 ]
[ 2844, 38 ]
python
en
['en', 'en', 'en']
True
Distribution.load_entry_point
(self, group, name)
Return the `name` entry point of `group` or raise ImportError
Return the `name` entry point of `group` or raise ImportError
def load_entry_point(self, group, name): """Return the `name` entry point of `group` or raise ImportError""" ep = self.get_entry_info(group, name) if ep is None: raise ImportError("Entry point %r not found" % ((group, name),)) return ep.load()
[ "def", "load_entry_point", "(", "self", ",", "group", ",", "name", ")", ":", "ep", "=", "self", ".", "get_entry_info", "(", "group", ",", "name", ")", "if", "ep", "is", "None", ":", "raise", "ImportError", "(", "\"Entry point %r not found\"", "%", "(", "...
[ 2846, 4 ]
[ 2851, 24 ]
python
en
['en', 'en', 'en']
True
Distribution.get_entry_map
(self, group=None)
Return the entry point map for `group`, or the full entry map
Return the entry point map for `group`, or the full entry map
def get_entry_map(self, group=None): """Return the entry point map for `group`, or the full entry map""" try: ep_map = self._ep_map except AttributeError: ep_map = self._ep_map = EntryPoint.parse_map( self._get_metadata('entry_points.txt'), self ...
[ "def", "get_entry_map", "(", "self", ",", "group", "=", "None", ")", ":", "try", ":", "ep_map", "=", "self", ".", "_ep_map", "except", "AttributeError", ":", "ep_map", "=", "self", ".", "_ep_map", "=", "EntryPoint", ".", "parse_map", "(", "self", ".", ...
[ 2853, 4 ]
[ 2863, 21 ]
python
en
['en', 'en', 'en']
True
Distribution.get_entry_info
(self, group, name)
Return the EntryPoint object for `group`+`name`, or ``None``
Return the EntryPoint object for `group`+`name`, or ``None``
def get_entry_info(self, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return self.get_entry_map(group).get(name)
[ "def", "get_entry_info", "(", "self", ",", "group", ",", "name", ")", ":", "return", "self", ".", "get_entry_map", "(", "group", ")", ".", "get", "(", "name", ")" ]
[ 2865, 4 ]
[ 2867, 50 ]
python
en
['en', 'en', 'en']
True
Distribution.insert_on
(self, path, loc=None, replace=False)
Ensure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent. - Else: add to the end of path. ...
Ensure self.location is on path
def insert_on(self, path, loc=None, replace=False): """Ensure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead...
[ "def", "insert_on", "(", "self", ",", "path", ",", "loc", "=", "None", ",", "replace", "=", "False", ")", ":", "loc", "=", "loc", "or", "self", ".", "location", "if", "not", "loc", ":", "return", "nloc", "=", "_normalize_cached", "(", "loc", ")", "...
[ 2869, 4 ]
[ 2935, 14 ]
python
en
['en', 'en', 'en']
True
Distribution.clone
(self, **kw)
Copy this distribution, substituting in any changed keyword args
Copy this distribution, substituting in any changed keyword args
def clone(self, **kw): """Copy this distribution, substituting in any changed keyword args""" names = 'project_name version py_version platform location precedence' for attr in names.split(): kw.setdefault(attr, getattr(self, attr, None)) kw.setdefault('metadata', self._provi...
[ "def", "clone", "(", "self", ",", "*", "*", "kw", ")", ":", "names", "=", "'project_name version py_version platform location precedence'", "for", "attr", "in", "names", ".", "split", "(", ")", ":", "kw", ".", "setdefault", "(", "attr", ",", "getattr", "(", ...
[ 2967, 4 ]
[ 2973, 35 ]
python
en
['en', 'en', 'en']
True
EggInfoDistribution._reload_version
(self)
Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly dow...
Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly dow...
def _reload_version(self): """ Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not ...
[ "def", "_reload_version", "(", "self", ")", ":", "md_version", "=", "self", ".", "_get_version", "(", ")", "if", "md_version", ":", "self", ".", "_version", "=", "md_version", "return", "self" ]
[ 2981, 4 ]
[ 2996, 19 ]
python
en
['en', 'error', 'th']
False
AsyncToSync._run_event_loop
(self, loop, coro)
Runs the given event loop (designed to be called in a thread).
Runs the given event loop (designed to be called in a thread).
def _run_event_loop(self, loop, coro): """ Runs the given event loop (designed to be called in a thread). """ asyncio.set_event_loop(loop) try: loop.run_until_complete(coro) finally: try: # mimic asyncio.run() behavior ...
[ "def", "_run_event_loop", "(", "self", ",", "loop", ",", "coro", ")", ":", "asyncio", ".", "set_event_loop", "(", "loop", ")", "try", ":", "loop", ".", "run_until_complete", "(", "coro", ")", "finally", ":", "try", ":", "# mimic asyncio.run() behavior", "# c...
[ 140, 4 ]
[ 173, 60 ]
python
en
['en', 'error', 'th']
False
AsyncToSync.__get__
(self, parent, objtype)
Include self for methods
Include self for methods
def __get__(self, parent, objtype): """ Include self for methods """ func = functools.partial(self.__call__, parent) return functools.update_wrapper(func, self.awaitable)
[ "def", "__get__", "(", "self", ",", "parent", ",", "objtype", ")", ":", "func", "=", "functools", ".", "partial", "(", "self", ".", "__call__", ",", "parent", ")", "return", "functools", ".", "update_wrapper", "(", "func", ",", "self", ".", "awaitable", ...
[ 175, 4 ]
[ 180, 61 ]
python
en
['en', 'error', 'th']
False
AsyncToSync.main_wrap
( self, args, kwargs, call_result, source_thread, exc_info, context )
Wraps the awaitable with something that puts the result into the result/exception future.
Wraps the awaitable with something that puts the result into the result/exception future.
async def main_wrap( self, args, kwargs, call_result, source_thread, exc_info, context ): """ Wraps the awaitable with something that puts the result into the result/exception future. """ if context is not None: _restore_context(context[0]) curren...
[ "async", "def", "main_wrap", "(", "self", ",", "args", ",", "kwargs", ",", "call_result", ",", "source_thread", ",", "exc_info", ",", "context", ")", ":", "if", "context", "is", "not", "None", ":", "_restore_context", "(", "context", "[", "0", "]", ")", ...
[ 182, 4 ]
[ 212, 55 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.__get__
(self, parent, objtype)
Include self for methods
Include self for methods
def __get__(self, parent, objtype): """ Include self for methods """ return functools.partial(self.__call__, parent)
[ "def", "__get__", "(", "self", ",", "parent", ",", "objtype", ")", ":", "return", "functools", ".", "partial", "(", "self", ".", "__call__", ",", "parent", ")" ]
[ 302, 4 ]
[ 306, 55 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.thread_handler
(self, loop, source_task, exc_info, func, *args, **kwargs)
Wraps the sync application with exception handling.
Wraps the sync application with exception handling.
def thread_handler(self, loop, source_task, exc_info, func, *args, **kwargs): """ Wraps the sync application with exception handling. """ # Set the threadlocal for AsyncToSync self.threadlocal.main_event_loop = loop # Set the task mapping (used for the locals module) ...
[ "def", "thread_handler", "(", "self", ",", "loop", ",", "source_task", ",", "exc_info", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Set the threadlocal for AsyncToSync", "self", ".", "threadlocal", ".", "main_event_loop", "=", "loop", ...
[ 308, 4 ]
[ 338, 51 ]
python
en
['en', 'error', 'th']
False
SyncToAsync.get_current_task
()
Cross-version implementation of asyncio.current_task() Returns None if there is no task.
Cross-version implementation of asyncio.current_task()
def get_current_task(): """ Cross-version implementation of asyncio.current_task() Returns None if there is no task. """ try: if hasattr(asyncio, "current_task"): # Python 3.7 and up return asyncio.current_task() else: ...
[ "def", "get_current_task", "(", ")", ":", "try", ":", "if", "hasattr", "(", "asyncio", ",", "\"current_task\"", ")", ":", "# Python 3.7 and up", "return", "asyncio", ".", "current_task", "(", ")", "else", ":", "# Python 3.6", "return", "asyncio", ".", "Task", ...
[ 341, 4 ]
[ 355, 23 ]
python
en
['en', 'error', 'th']
False
PickleabilityTestCase.test_model_pickle
(self)
Test that a model not defined on module level is pickleable.
Test that a model not defined on module level is pickleable.
def test_model_pickle(self): """ Test that a model not defined on module level is pickleable. """ original = Container.SomeModel(pk=1) dumped = pickle.dumps(original) reloaded = pickle.loads(dumped) self.assertEqual(original, reloaded) # Also, deferred dyn...
[ "def", "test_model_pickle", "(", "self", ")", ":", "original", "=", "Container", ".", "SomeModel", "(", "pk", "=", "1", ")", "dumped", "=", "pickle", ".", "dumps", "(", "original", ")", "reloaded", "=", "pickle", ".", "loads", "(", "dumped", ")", "self...
[ 58, 4 ]
[ 72, 64 ]
python
en
['en', 'error', 'th']
False
PickleabilityTestCase.test_model_pickle_m2m
(self)
Test intentionally the automatically created through model.
Test intentionally the automatically created through model.
def test_model_pickle_m2m(self): """ Test intentionally the automatically created through model. """ m1 = M2MModel.objects.create() g1 = Group.objects.create(name='foof') m1.groups.add(g1) m2m_through = M2MModel._meta.get_field_by_name('groups')[0].rel.through ...
[ "def", "test_model_pickle_m2m", "(", "self", ")", ":", "m1", "=", "M2MModel", ".", "objects", ".", "create", "(", ")", "g1", "=", "Group", ".", "objects", ".", "create", "(", "name", "=", "'foof'", ")", "m1", ".", "groups", ".", "add", "(", "g1", "...
[ 74, 4 ]
[ 85, 44 ]
python
en
['en', 'error', 'th']
False
PickleabilityTestCase.test_missing_django_version_unpickling
(self)
#21430 -- Verifies a warning is raised for querysets that are unpickled without a Django version
#21430 -- Verifies a warning is raised for querysets that are unpickled without a Django version
def test_missing_django_version_unpickling(self): """ #21430 -- Verifies a warning is raised for querysets that are unpickled without a Django version """ qs = Group.missing_django_version_objects.all() with warnings.catch_warnings(record=True) as recorded: pi...
[ "def", "test_missing_django_version_unpickling", "(", "self", ")", ":", "qs", "=", "Group", ".", "missing_django_version_objects", ".", "all", "(", ")", "with", "warnings", ".", "catch_warnings", "(", "record", "=", "True", ")", "as", "recorded", ":", "pickle", ...
[ 114, 4 ]
[ 124, 79 ]
python
en
['en', 'error', 'th']
False
PickleabilityTestCase.test_unsupported_unpickle
(self)
#21430 -- Verifies a warning is raised for querysets that are unpickled with a different Django version than the current
#21430 -- Verifies a warning is raised for querysets that are unpickled with a different Django version than the current
def test_unsupported_unpickle(self): """ #21430 -- Verifies a warning is raised for querysets that are unpickled with a different Django version than the current """ qs = Group.previous_django_version_objects.all() with warnings.catch_warnings(record=True) as recorded: ...
[ "def", "test_unsupported_unpickle", "(", "self", ")", ":", "qs", "=", "Group", ".", "previous_django_version_objects", ".", "all", "(", ")", "with", "warnings", ".", "catch_warnings", "(", "record", "=", "True", ")", "as", "recorded", ":", "pickle", ".", "lo...
[ 126, 4 ]
[ 138, 73 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_missing_emoji
(self)
Sending reaction without emoji fails
Sending reaction without emoji fails
def test_missing_emoji(self) -> None: """ Sending reaction without emoji fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_info) self.as...
[ "def", "test_missing_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"\"", ",", "}", "result", "=", "self", ".", "api_post", "(", "sender",...
[ 17, 4 ]
[ 27, 49 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_add_invalid_emoji
(self)
Sending invalid emoji fails
Sending invalid emoji fails
def test_add_invalid_emoji(self) -> None: """ Sending invalid emoji fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "foo", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_info) self.asse...
[ "def", "test_add_invalid_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"foo\"", ",", "}", "result", "=", "self", ".", "api_post", "(", "s...
[ 29, 4 ]
[ 39, 68 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_add_deactivated_realm_emoji
(self)
Sending deactivated realm emoji fails.
Sending deactivated realm emoji fails.
def test_add_deactivated_realm_emoji(self) -> None: """ Sending deactivated realm emoji fails. """ emoji = RealmEmoji.objects.get(name="green_tick") emoji.deactivated = True emoji.save(update_fields=["deactivated"]) sender = self.example_user("hamlet") rea...
[ "def", "test_add_deactivated_realm_emoji", "(", "self", ")", "->", "None", ":", "emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\"", ")", "emoji", ".", "deactivated", "=", "True", "emoji", ".", "save", "(", "update_fiel...
[ 41, 4 ]
[ 55, 75 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_emoji
(self)
Reacting with valid emoji succeeds
Reacting with valid emoji succeeds
def test_valid_emoji(self) -> None: """ Reacting with valid emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } base_query = Reaction.objects.filter( user_profile=sender, message=M...
[ "def", "test_valid_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "base_query", "=", "Reaction", ".", "objects", ".", ...
[ 57, 4 ]
[ 79, 91 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_cached_reaction_data
(self)
Formatted reactions data is saved in cache.
Formatted reactions data is saved in cache.
def test_cached_reaction_data(self) -> None: """ Formatted reactions data is saved in cache. """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_inf...
[ "def", "test_cached_reaction_data", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(",...
[ 81, 4 ]
[ 109, 70 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_zulip_emoji
(self)
Reacting with zulip emoji succeeds
Reacting with zulip emoji succeeds
def test_zulip_emoji(self) -> None: """ Reacting with zulip emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "zulip", "reaction_type": "zulip_extra_emoji", } base_query = Reaction.objects.filter( ...
[ "def", "test_zulip_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"zulip\"", ",", "\"reaction_type\"", ":", "\"zulip_extra_emoji\"", ",", "}", ...
[ 111, 4 ]
[ 133, 86 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_emoji_react_historical
(self)
Reacting with valid emoji on a historical message succeeds
Reacting with valid emoji on a historical message succeeds
def test_valid_emoji_react_historical(self) -> None: """ Reacting with valid emoji on a historical message succeeds """ stream_name = "Saxony" self.subscribe(self.example_user("cordelia"), stream_name) message_id = self.send_stream_message(self.example_user("cordelia"), s...
[ "def", "test_valid_emoji_react_historical", "(", "self", ")", "->", "None", ":", "stream_name", "=", "\"Saxony\"", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ",", "stream_name", ")", "message_id", "=", "self", ".", "s...
[ 135, 4 ]
[ 163, 52 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_realm_emoji
(self)
Reacting with valid realm emoji succeeds
Reacting with valid realm emoji succeeds
def test_valid_realm_emoji(self) -> None: """ Reacting with valid realm emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "green_tick", "reaction_type": "realm_emoji", } result = self.api_post(sender,...
[ "def", "test_valid_realm_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"green_tick\"", ",", "\"reaction_type\"", ":", "\"realm_emoji\"", ",", "...
[ 165, 4 ]
[ 177, 40 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_emoji_name_to_emoji_code
(self)
An emoji name is mapped canonically to emoji code.
An emoji name is mapped canonically to emoji code.
def test_emoji_name_to_emoji_code(self) -> None: """ An emoji name is mapped canonically to emoji code. """ realm = get_realm("zulip") realm_emoji = RealmEmoji.objects.get(name="green_tick") # Test active realm emoji. emoji_code, reaction_type = emoji_name_to_emo...
[ "def", "test_emoji_name_to_emoji_code", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "realm_emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\"", ")", "# Test active realm emoji.", "e...
[ 179, 4 ]
[ 232, 84 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_missing_message_id
(self)
Reacting without a message_id fails
Reacting without a message_id fails
def test_missing_message_id(self) -> None: """ Reacting without a message_id fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages//reactions", reaction_info) ...
[ "def", "test_missing_message_id", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(", ...
[ 236, 4 ]
[ 246, 49 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_invalid_message_id
(self)
Reacting to an invalid message id fails
Reacting to an invalid message id fails
def test_invalid_message_id(self) -> None: """ Reacting to an invalid message id fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages/-1/reactions", reaction_info) ...
[ "def", "test_invalid_message_id", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(", ...
[ 248, 4 ]
[ 258, 49 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_inaccessible_message_id
(self)
Reacting to a inaccessible (for instance, private) message fails
Reacting to a inaccessible (for instance, private) message fails
def test_inaccessible_message_id(self) -> None: """ Reacting to a inaccessible (for instance, private) message fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = self.example_user("iago") result = self....
[ "def", "test_inaccessible_message_id", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "self", ".", "...
[ 260, 4 ]
[ 282, 60 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_add_existing_reaction
(self)
Creating the same reaction twice fails
Creating the same reaction twice fails
def test_add_existing_reaction(self) -> None: """ Creating the same reaction twice fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm = self.api_post( pm_sender, ...
[ "def", "test_add_existing_reaction", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "p...
[ 286, 4 ]
[ 314, 66 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_nonexisting_reaction
(self)
Removing a reaction twice fails
Removing a reaction twice fails
def test_remove_nonexisting_reaction(self) -> None: """ Removing a reaction twice fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm = self.api_post( pm_sender, "...
[ "def", "test_remove_nonexisting_reaction", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient"...
[ 316, 4 ]
[ 348, 65 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_existing_reaction_with_renamed_emoji
(self)
Removes an old existing reaction but the name of emoji got changed during various emoji infra changes.
Removes an old existing reaction but the name of emoji got changed during various emoji infra changes.
def test_remove_existing_reaction_with_renamed_emoji(self) -> None: """ Removes an old existing reaction but the name of emoji got changed during various emoji infra changes. """ realm = get_realm("zulip") sender = self.example_user("hamlet") emoji_code, reaction_...
[ "def", "test_remove_existing_reaction_with_renamed_emoji", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "emoji_code", ",", "reaction_type", "=", "emoji_na...
[ 350, 4 ]
[ 369, 44 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_existing_reaction_with_deactivated_realm_emoji
(self)
Removes an old existing reaction but the realm emoji used there has been deactivated.
Removes an old existing reaction but the realm emoji used there has been deactivated.
def test_remove_existing_reaction_with_deactivated_realm_emoji(self) -> None: """ Removes an old existing reaction but the realm emoji used there has been deactivated. """ sender = self.example_user("hamlet") emoji = RealmEmoji.objects.get(name="green_tick") reaction_in...
[ "def", "test_remove_existing_reaction_with_deactivated_realm_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\""...
[ 371, 4 ]
[ 392, 40 ]
python
en
['en', 'error', 'th']
False
ReactionEventTest.test_add_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_add_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient result = sel...
[ "def", "test_add_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "result", "=...
[ 396, 4 ]
[ 435, 52 ]
python
en
['en', 'error', 'th']
False
ReactionEventTest.test_remove_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_remove_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient result = ...
[ "def", "test_remove_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "result", ...
[ 437, 4 ]
[ 480, 52 ]
python
en
['en', 'error', 'th']
False
DefaultEmojiReactionTests.test_react_historical
(self)
Reacting with valid emoji on a historical message succeeds.
Reacting with valid emoji on a historical message succeeds.
def test_react_historical(self) -> None: """ Reacting with valid emoji on a historical message succeeds. """ stream_name = "Saxony" self.subscribe(self.example_user("cordelia"), stream_name) message_id = self.send_stream_message(self.example_user("cordelia"), stream_name)...
[ "def", "test_react_historical", "(", "self", ")", "->", "None", ":", "stream_name", "=", "\"Saxony\"", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ",", "stream_name", ")", "message_id", "=", "self", ".", "send_stream_m...
[ 848, 4 ]
[ 879, 52 ]
python
en
['en', 'error', 'th']
False
ReactionAPIEventTest.test_add_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_add_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm_id = self....
[ "def", "test_add_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "pm_id", "="...
[ 1021, 4 ]
[ 1054, 80 ]
python
en
['en', 'error', 'th']
False
ReactionAPIEventTest.test_remove_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_remove_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm_id = se...
[ "def", "test_remove_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "pm_id", ...
[ 1056, 4 ]
[ 1101, 80 ]
python
en
['en', 'error', 'th']
False
Query.__str__
(self)
Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string). Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time.
Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string).
def __str__(self): """ Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string). Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time. ...
[ "def", "__str__", "(", "self", ")", ":", "sql", ",", "params", "=", "self", ".", "sql_with_params", "(", ")", "return", "sql", "%", "params" ]
[ 255, 4 ]
[ 264, 27 ]
python
en
['en', 'error', 'th']
False
Query.sql_with_params
(self)
Return the query as an SQL string and the parameters that will be substituted into the query.
Return the query as an SQL string and the parameters that will be substituted into the query.
def sql_with_params(self): """ Return the query as an SQL string and the parameters that will be substituted into the query. """ return self.get_compiler(DEFAULT_DB_ALIAS).as_sql()
[ "def", "sql_with_params", "(", "self", ")", ":", "return", "self", ".", "get_compiler", "(", "DEFAULT_DB_ALIAS", ")", ".", "as_sql", "(", ")" ]
[ 266, 4 ]
[ 271, 59 ]
python
en
['en', 'error', 'th']
False
Query.__deepcopy__
(self, memo)
Limit the amount of work when a Query is deepcopied.
Limit the amount of work when a Query is deepcopied.
def __deepcopy__(self, memo): """Limit the amount of work when a Query is deepcopied.""" result = self.clone() memo[id(self)] = result return result
[ "def", "__deepcopy__", "(", "self", ",", "memo", ")", ":", "result", "=", "self", ".", "clone", "(", ")", "memo", "[", "id", "(", "self", ")", "]", "=", "result", "return", "result" ]
[ 273, 4 ]
[ 277, 21 ]
python
en
['en', 'en', 'en']
True
Query.get_meta
(self)
Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
def get_meta(self): """ Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses. """ return self.model._meta
[ "def", "get_meta", "(", "self", ")", ":", "return", "self", ".", "model", ".", "_meta" ]
[ 286, 4 ]
[ 292, 31 ]
python
en
['en', 'error', 'th']
False
Query.clone
(self)
Return a copy of the current Query. A lightweight alternative to to deepcopy().
Return a copy of the current Query. A lightweight alternative to to deepcopy().
def clone(self): """ Return a copy of the current Query. A lightweight alternative to to deepcopy(). """ obj = Empty() obj.__class__ = self.__class__ # Copy references to everything. obj.__dict__ = self.__dict__.copy() # Clone attributes that can't...
[ "def", "clone", "(", "self", ")", ":", "obj", "=", "Empty", "(", ")", "obj", ".", "__class__", "=", "self", ".", "__class__", "# Copy references to everything.", "obj", ".", "__dict__", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "# Clone attribut...
[ 294, 4 ]
[ 342, 18 ]
python
en
['en', 'error', 'th']
False
Query.chain
(self, klass=None)
Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery.
Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery.
def chain(self, klass=None): """ Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery. """ obj = self.clone() if klass and obj.__class__ != klass: obj.__class__ = klass ...
[ "def", "chain", "(", "self", ",", "klass", "=", "None", ")", ":", "obj", "=", "self", ".", "clone", "(", ")", "if", "klass", "and", "obj", ".", "__class__", "!=", "klass", ":", "obj", ".", "__class__", "=", "klass", "if", "not", "obj", ".", "filt...
[ 344, 4 ]
[ 357, 18 ]
python
en
['en', 'error', 'th']
False
Query.get_aggregation
(self, using, added_aggregate_names)
Return the dictionary with the values of the existing aggregations.
Return the dictionary with the values of the existing aggregations.
def get_aggregation(self, using, added_aggregate_names): """ Return the dictionary with the values of the existing aggregations. """ if not self.annotation_select: return {} existing_annotations = [ annotation for alias, annotation in self.anno...
[ "def", "get_aggregation", "(", "self", ",", "using", ",", "added_aggregate_names", ")", ":", "if", "not", "self", ".", "annotation_select", ":", "return", "{", "}", "existing_annotations", "=", "[", "annotation", "for", "alias", ",", "annotation", "in", "self"...
[ 416, 4 ]
[ 509, 63 ]
python
en
['en', 'error', 'th']
False
Query.get_count
(self, using)
Perform a COUNT() query using the current filter constraints.
Perform a COUNT() query using the current filter constraints.
def get_count(self, using): """ Perform a COUNT() query using the current filter constraints. """ obj = self.clone() obj.add_annotation(Count('*'), alias='__count', is_summary=True) number = obj.get_aggregation(using, ['__count'])['__count'] if number is None: ...
[ "def", "get_count", "(", "self", ",", "using", ")", ":", "obj", "=", "self", ".", "clone", "(", ")", "obj", ".", "add_annotation", "(", "Count", "(", "'*'", ")", ",", "alias", "=", "'__count'", ",", "is_summary", "=", "True", ")", "number", "=", "o...
[ 511, 4 ]
[ 520, 21 ]
python
en
['en', 'error', 'th']
False
Query.combine
(self, rhs, connector)
Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function. The 'connector' parameter describes how to connect filters from the 'rhs' q...
Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function.
def combine(self, rhs, connector): """ Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function. The 'connector' parameter describes h...
[ "def", "combine", "(", "self", ",", "rhs", ",", "connector", ")", ":", "assert", "self", ".", "model", "==", "rhs", ".", "model", ",", "\"Cannot combine queries on two different base models.\"", "assert", "not", "self", ".", "is_sliced", ",", "\"Cannot combine que...
[ 547, 4 ]
[ 646, 71 ]
python
en
['en', 'error', 'th']
False
Query.deferred_to_data
(self, target, callback)
Convert the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each mode...
Convert the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each mode...
def deferred_to_data(self, target, callback): """ Convert the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work ou...
[ "def", "deferred_to_data", "(", "self", ",", "target", ",", "callback", ")", ":", "field_names", ",", "defer", "=", "self", ".", "deferred_loading", "if", "not", "field_names", ":", "return", "orig_opts", "=", "self", ".", "get_meta", "(", ")", "seen", "="...
[ 648, 4 ]
[ 732, 47 ]
python
en
['en', 'error', 'th']
False
Query.table_alias
(self, table_name, create=False, filtered_relation=None)
Return a table alias for the given table_name and whether this is a new alias or not. If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused.
Return a table alias for the given table_name and whether this is a new alias or not.
def table_alias(self, table_name, create=False, filtered_relation=None): """ Return a table alias for the given table_name and whether this is a new alias or not. If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one...
[ "def", "table_alias", "(", "self", ",", "table_name", ",", "create", "=", "False", ",", "filtered_relation", "=", "None", ")", ":", "alias_list", "=", "self", ".", "table_map", ".", "get", "(", "table_name", ")", "if", "not", "create", "and", "alias_list",...
[ 734, 4 ]
[ 757, 26 ]
python
en
['en', 'error', 'th']
False
Query.ref_alias
(self, alias)
Increases the reference count for this alias.
Increases the reference count for this alias.
def ref_alias(self, alias): """Increases the reference count for this alias.""" self.alias_refcount[alias] += 1
[ "def", "ref_alias", "(", "self", ",", "alias", ")", ":", "self", ".", "alias_refcount", "[", "alias", "]", "+=", "1" ]
[ 759, 4 ]
[ 761, 39 ]
python
en
['en', 'en', 'en']
True
Query.unref_alias
(self, alias, amount=1)
Decreases the reference count for this alias.
Decreases the reference count for this alias.
def unref_alias(self, alias, amount=1): """Decreases the reference count for this alias.""" self.alias_refcount[alias] -= amount
[ "def", "unref_alias", "(", "self", ",", "alias", ",", "amount", "=", "1", ")", ":", "self", ".", "alias_refcount", "[", "alias", "]", "-=", "amount" ]
[ 763, 4 ]
[ 765, 44 ]
python
en
['en', 'en', 'en']
True
Query.promote_joins
(self, aliases)
Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join. The children promotion is done to avoid join chains that contain a LOUTER b INNER c. S...
Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join.
def promote_joins(self, aliases): """ Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join. The children promotion is done to avoid join chai...
[ "def", "promote_joins", "(", "self", ",", "aliases", ")", ":", "aliases", "=", "list", "(", "aliases", ")", "while", "aliases", ":", "alias", "=", "aliases", ".", "pop", "(", "0", ")", "if", "self", ".", "alias_map", "[", "alias", "]", ".", "join_typ...
[ 767, 4 ]
[ 799, 17 ]
python
en
['en', 'error', 'th']
False
Query.demote_joins
(self, aliases)
Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b LOUTER c then we must demote a->b a...
Change join type from LOUTER to INNER for all joins in aliases.
def demote_joins(self, aliases): """ Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b...
[ "def", "demote_joins", "(", "self", ",", "aliases", ")", ":", "aliases", "=", "list", "(", "aliases", ")", "while", "aliases", ":", "alias", "=", "aliases", ".", "pop", "(", "0", ")", "if", "self", ".", "alias_map", "[", "alias", "]", ".", "join_type...
[ 801, 4 ]
[ 818, 48 ]
python
en
['en', 'error', 'th']
False
Query.reset_refcounts
(self, to_counts)
Reset reference counts for aliases so that they match the value passed in `to_counts`.
Reset reference counts for aliases so that they match the value passed in `to_counts`.
def reset_refcounts(self, to_counts): """ Reset reference counts for aliases so that they match the value passed in `to_counts`. """ for alias, cur_refcount in self.alias_refcount.copy().items(): unref_amount = cur_refcount - to_counts.get(alias, 0) self.u...
[ "def", "reset_refcounts", "(", "self", ",", "to_counts", ")", ":", "for", "alias", ",", "cur_refcount", "in", "self", ".", "alias_refcount", ".", "copy", "(", ")", ".", "items", "(", ")", ":", "unref_amount", "=", "cur_refcount", "-", "to_counts", ".", "...
[ 820, 4 ]
[ 827, 49 ]
python
en
['en', 'error', 'th']
False
Query.change_aliases
(self, change_map)
Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
def change_aliases(self, change_map): """ Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause. """ assert set(change_map).isdisjoint(change_map.values()) # 1. Update refer...
[ "def", "change_aliases", "(", "self", ",", "change_map", ")", ":", "assert", "set", "(", "change_map", ")", ".", "isdisjoint", "(", "change_map", ".", "values", "(", ")", ")", "# 1. Update references in \"select\" (normal columns plus aliases),", "# \"group by\" and \"w...
[ 829, 4 ]
[ 866, 9 ]
python
en
['en', 'error', 'th']
False
Query.bump_prefix
(self, outer_query)
Change the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call.
Change the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call.
def bump_prefix(self, outer_query): """ Change the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call. """ d...
[ "def", "bump_prefix", "(", "self", ",", "outer_query", ")", ":", "def", "prefix_gen", "(", ")", ":", "\"\"\"\n Generate a sequence of characters in alphabetical order:\n -> 'A', 'B', 'C', ...\n\n When the alphabet is finished, the sequence will continue...
[ 868, 4 ]
[ 915, 10 ]
python
en
['en', 'error', 'th']
False
Query.get_initial_alias
(self)
Return the first alias for this query, after increasing its reference count.
Return the first alias for this query, after increasing its reference count.
def get_initial_alias(self): """ Return the first alias for this query, after increasing its reference count. """ if self.alias_map: alias = self.base_table self.ref_alias(alias) else: alias = self.join(BaseTable(self.get_meta().db_tabl...
[ "def", "get_initial_alias", "(", "self", ")", ":", "if", "self", ".", "alias_map", ":", "alias", "=", "self", ".", "base_table", "self", ".", "ref_alias", "(", "alias", ")", "else", ":", "alias", "=", "self", ".", "join", "(", "BaseTable", "(", "self",...
[ 917, 4 ]
[ 927, 20 ]
python
en
['en', 'error', 'th']
False
Query.count_active_tables
(self)
Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
def count_active_tables(self): """ Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method. """ return len([1 for count in self.alias_refcount....
[ "def", "count_active_tables", "(", "self", ")", ":", "return", "len", "(", "[", "1", "for", "count", "in", "self", ".", "alias_refcount", ".", "values", "(", ")", "if", "count", "]", ")" ]
[ 929, 4 ]
[ 935, 74 ]
python
en
['en', 'error', 'th']
False
Query.join
(self, join, reuse=None, reuse_with_filtered_relation=False)
Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join. The 'reuse' parameter can be either None which means all joins are reusable, or it can be a set containing the aliases ...
Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join.
def join(self, join, reuse=None, reuse_with_filtered_relation=False): """ Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join. The 'reuse' parameter can be either None which...
[ "def", "join", "(", "self", ",", "join", ",", "reuse", "=", "None", ",", "reuse_with_filtered_relation", "=", "False", ")", ":", "if", "reuse_with_filtered_relation", "and", "reuse", ":", "reuse_aliases", "=", "[", "a", "for", "a", ",", "j", "in", "self", ...
[ 937, 4 ]
[ 983, 20 ]
python
en
['en', 'error', 'th']
False
Query.join_parent_model
(self, opts, model, alias, seen)
Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op. The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of existing joins. It must also contain a mapping of None -> ...
Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op.
def join_parent_model(self, opts, model, alias, seen): """ Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op. The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of ...
[ "def", "join_parent_model", "(", "self", ",", "opts", ",", "model", ",", "alias", ",", "seen", ")", ":", "if", "model", "in", "seen", ":", "return", "seen", "[", "model", "]", "chain", "=", "opts", ".", "get_base_chain", "(", "model", ")", "if", "not...
[ 985, 4 ]
[ 1016, 34 ]
python
en
['en', 'error', 'th']
False
Query.add_annotation
(self, annotation, alias, is_summary=False)
Add a single annotation expression to the Query.
Add a single annotation expression to the Query.
def add_annotation(self, annotation, alias, is_summary=False): """Add a single annotation expression to the Query.""" annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None, summarize=is_summary) self.append_annotation_mas...
[ "def", "add_annotation", "(", "self", ",", "annotation", ",", "alias", ",", "is_summary", "=", "False", ")", ":", "annotation", "=", "annotation", ".", "resolve_expression", "(", "self", ",", "allow_joins", "=", "True", ",", "reuse", "=", "None", ",", "sum...
[ 1018, 4 ]
[ 1023, 44 ]
python
en
['en', 'en', 'en']
True
Query.solve_lookup_type
(self, lookup)
Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
def solve_lookup_type(self, lookup): """ Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains'). """ lookup_splitted = lookup.split(LOOKUP_SEP) if self.annotations: expression, expression_lookups = refs_expression(lookup_splitted, self.annotations) ...
[ "def", "solve_lookup_type", "(", "self", ",", "lookup", ")", ":", "lookup_splitted", "=", "lookup", ".", "split", "(", "LOOKUP_SEP", ")", "if", "self", ".", "annotations", ":", "expression", ",", "expression_lookups", "=", "refs_expression", "(", "lookup_splitte...
[ 1078, 4 ]
[ 1094, 47 ]
python
en
['en', 'error', 'th']
False
Query.check_query_object_type
(self, value, opts, field)
Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object.
Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object.
def check_query_object_type(self, value, opts, field): """ Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object. """ if hasattr(value, '_meta'): if not check_rel_lookup_compatibility(value._meta....
[ "def", "check_query_object_type", "(", "self", ",", "value", ",", "opts", ",", "field", ")", ":", "if", "hasattr", "(", "value", ",", "'_meta'", ")", ":", "if", "not", "check_rel_lookup_compatibility", "(", "value", ".", "_meta", ".", "model", ",", "opts",...
[ 1096, 4 ]
[ 1105, 46 ]
python
en
['en', 'error', 'th']
False
Query.check_related_objects
(self, field, value, opts)
Check the type of object passed to query relations.
Check the type of object passed to query relations.
def check_related_objects(self, field, value, opts): """Check the type of object passed to query relations.""" if field.is_relation: # Check that the field and the queryset use the same model in a # query like .filter(author=Author.objects.all()). For example, the # o...
[ "def", "check_related_objects", "(", "self", ",", "field", ",", "value", ",", "opts", ")", ":", "if", "field", ".", "is_relation", ":", "# Check that the field and the queryset use the same model in a", "# query like .filter(author=Author.objects.all()). For example, the", "# o...
[ 1107, 4 ]
[ 1125, 64 ]
python
en
['en', 'en', 'en']
True
Query.check_filterable
(self, expression)
Raise an error if expression cannot be used in a WHERE clause.
Raise an error if expression cannot be used in a WHERE clause.
def check_filterable(self, expression): """Raise an error if expression cannot be used in a WHERE clause.""" if ( hasattr(expression, 'resolve_expression') and not getattr(expression, 'filterable', True) ): raise NotSupportedError( expression._...
[ "def", "check_filterable", "(", "self", ",", "expression", ")", ":", "if", "(", "hasattr", "(", "expression", ",", "'resolve_expression'", ")", "and", "not", "getattr", "(", "expression", ",", "'filterable'", ",", "True", ")", ")", ":", "raise", "NotSupporte...
[ 1127, 4 ]
[ 1139, 43 ]
python
en
['en', 'en', 'en']
True
Query.build_lookup
(self, lookups, lhs, rhs)
Try to extract transforms and lookup from given lhs. The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_lookup() and get_transform().
Try to extract transforms and lookup from given lhs.
def build_lookup(self, lookups, lhs, rhs): """ Try to extract transforms and lookup from given lhs. The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_lookup(...
[ "def", "build_lookup", "(", "self", ",", "lookups", ",", "lhs", ",", "rhs", ")", ":", "# __exact is the default lookup if one isn't given.", "*", "transforms", ",", "lookup_name", "=", "lookups", "or", "[", "'exact'", "]", "for", "name", "in", "transforms", ":",...
[ 1141, 4 ]
[ 1184, 21 ]
python
en
['en', 'error', 'th']
False
Query.try_transform
(self, lhs, name)
Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs.
Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs.
def try_transform(self, lhs, name): """ Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs. """ transform_class = lhs.get_transform(name) if transform_class: return transform_class(lhs) else: ...
[ "def", "try_transform", "(", "self", ",", "lhs", ",", "name", ")", ":", "transform_class", "=", "lhs", ".", "get_transform", "(", "name", ")", "if", "transform_class", ":", "return", "transform_class", "(", "lhs", ")", "else", ":", "output_field", "=", "lh...
[ 1186, 4 ]
[ 1204, 13 ]
python
en
['en', 'error', 'th']
False
Query.build_filter
(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, allow_joins=True, split_subq=True, reuse_with_filtered_relation=False, simple_col=False, check_filterable=True)
Build a WhereNode for a single filter clause but don't add it to this Query. Query.add_q() will then add this filter to the where Node. The 'branch_negated' tells us if the current branch contains any negations. This will be used to determine if subqueries are needed. ...
Build a WhereNode for a single filter clause but don't add it to this Query. Query.add_q() will then add this filter to the where Node.
def build_filter(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, allow_joins=True, split_subq=True, reuse_with_filtered_relation=False, simple_col=False, check_filterable=True): """ Build a WhereNode for a sin...
[ "def", "build_filter", "(", "self", ",", "filter_expr", ",", "branch_negated", "=", "False", ",", "current_negated", "=", "False", ",", "can_reuse", "=", "None", ",", "allow_joins", "=", "True", ",", "split_subq", "=", "True", ",", "reuse_with_filtered_relation"...
[ 1206, 4 ]
[ 1336, 62 ]
python
en
['en', 'error', 'th']
False
Query.add_q
(self, q_object)
A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
def add_q(self, q_object): """ A preprocessor for the internal _add_q(). Responsible for doing final join promotion. """ # For join promotion this case is doing an AND for the added q_object # and existing conditions. So, any existing inner join forces the join # ...
[ "def", "add_q", "(", "self", ",", "q_object", ")", ":", "# For join promotion this case is doing an AND for the added q_object", "# and existing conditions. So, any existing inner join forces the join", "# type to remain inner. Existing outer joins can however be demoted.", "# (Consider case w...
[ 1341, 4 ]
[ 1356, 41 ]
python
en
['en', 'error', 'th']
False
Query._add_q
(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True, simple_col=False, check_filterable=True)
Add a Q-object to the current filter.
Add a Q-object to the current filter.
def _add_q(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True, simple_col=False, check_filterable=True): """Add a Q-object to the current filter.""" connector = q_object.connector current_negated = current_ne...
[ "def", "_add_q", "(", "self", ",", "q_object", ",", "used_aliases", ",", "branch_negated", "=", "False", ",", "current_negated", "=", "False", ",", "allow_joins", "=", "True", ",", "split_subq", "=", "True", ",", "simple_col", "=", "False", ",", "check_filte...
[ 1361, 4 ]
[ 1390, 42 ]
python
en
['en', 'en', 'en']
True
Query.build_filtered_relation_q
(self, q_object, reuse, branch_negated=False, current_negated=False)
Add a FilteredRelation object to the current filter.
Add a FilteredRelation object to the current filter.
def build_filtered_relation_q(self, q_object, reuse, branch_negated=False, current_negated=False): """Add a FilteredRelation object to the current filter.""" connector = q_object.connector current_negated ^= q_object.negated branch_negated = branch_negated or q_object.negated tar...
[ "def", "build_filtered_relation_q", "(", "self", ",", "q_object", ",", "reuse", ",", "branch_negated", "=", "False", ",", "current_negated", "=", "False", ")", ":", "connector", "=", "q_object", ".", "connector", "current_negated", "^=", "q_object", ".", "negate...
[ 1392, 4 ]
[ 1412, 28 ]
python
en
['en', 'en', 'en']
True
Query.names_to_path
(self, names, opts, allow_many=True, fail_on_missing=False)
Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example). 'names' is the path of names to travel, 'opts' is the model Options we start the name resolving from, 'allow_many' is as for setup_joins(). I...
Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example).
def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False): """ Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example). 'names' is the path of names to travel, 'opts' is the model Options ...
[ "def", "names_to_path", "(", "self", ",", "names", ",", "opts", ",", "allow_many", "=", "True", ",", "fail_on_missing", "=", "False", ")", ":", "path", ",", "names_with_path", "=", "[", "]", ",", "[", "]", "for", "pos", ",", "name", "in", "enumerate", ...
[ 1427, 4 ]
[ 1521, 58 ]
python
en
['en', 'error', 'th']
False
Query.setup_joins
(self, names, opts, alias, can_reuse=None, allow_many=True, reuse_with_filtered_relation=False)
Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from. The 'can_reuse' defines the rever...
Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from.
def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True, reuse_with_filtered_relation=False): """ Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives th...
[ "def", "setup_joins", "(", "self", ",", "names", ",", "opts", ",", "alias", ",", "can_reuse", "=", "None", ",", "allow_many", "=", "True", ",", "reuse_with_filtered_relation", "=", "False", ")", ":", "joins", "=", "[", "alias", "]", "# The transform can't be...
[ 1523, 4 ]
[ 1623, 83 ]
python
en
['en', 'error', 'th']
False
Query.trim_joins
(self, targets, joins, path)
The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins. Return the final target field and table alias and the new active joins. Always trim any direct join if the ta...
The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins.
def trim_joins(self, targets, joins, path): """ The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins. Return the final target field and table alias and the new active ...
[ "def", "trim_joins", "(", "self", ",", "targets", ",", "joins", ",", "path", ")", ":", "joins", "=", "joins", "[", ":", "]", "for", "pos", ",", "info", "in", "enumerate", "(", "reversed", "(", "path", ")", ")", ":", "if", "len", "(", "joins", ")"...
[ 1625, 4 ]
[ 1651, 40 ]
python
en
['en', 'error', 'th']
False
Query.split_exclude
(self, filter_expr, can_reuse, names_with_path)
When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field. For example, if the origin filter is ~Q(ch...
When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field.
def split_exclude(self, filter_expr, can_reuse, names_with_path): """ When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first ...
[ "def", "split_exclude", "(", "self", ",", "filter_expr", ",", "can_reuse", ",", "names_with_path", ")", ":", "filter_lhs", ",", "filter_rhs", "=", "filter_expr", "if", "isinstance", "(", "filter_rhs", ",", "OuterRef", ")", ":", "filter_expr", "=", "(", "filter...
[ 1702, 4 ]
[ 1773, 38 ]
python
en
['en', 'error', 'th']
False
Query.set_limits
(self, low=None, high=None)
Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values. Apply any limits passed in here to the existing constraints. Add low to th...
Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values.
def set_limits(self, low=None, high=None): """ Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values. Apply any limits passed in h...
[ "def", "set_limits", "(", "self", ",", "low", "=", "None", ",", "high", "=", "None", ")", ":", "if", "high", "is", "not", "None", ":", "if", "self", ".", "high_mark", "is", "not", "None", ":", "self", ".", "high_mark", "=", "min", "(", "self", "....
[ 1781, 4 ]
[ 1802, 28 ]
python
en
['en', 'error', 'th']
False
Query.clear_limits
(self)
Clear any existing limits.
Clear any existing limits.
def clear_limits(self): """Clear any existing limits.""" self.low_mark, self.high_mark = 0, None
[ "def", "clear_limits", "(", "self", ")", ":", "self", ".", "low_mark", ",", "self", ".", "high_mark", "=", "0", ",", "None" ]
[ 1804, 4 ]
[ 1806, 47 ]
python
en
['en', 'en', 'en']
True
Query.can_filter
(self)
Return True if adding filters to this instance is still possible. Typically, this means no limits or offsets have been put on the results.
Return True if adding filters to this instance is still possible.
def can_filter(self): """ Return True if adding filters to this instance is still possible. Typically, this means no limits or offsets have been put on the results. """ return not self.is_sliced
[ "def", "can_filter", "(", "self", ")", ":", "return", "not", "self", ".", "is_sliced" ]
[ 1815, 4 ]
[ 1821, 33 ]
python
en
['en', 'error', 'th']
False
Query.clear_select_clause
(self)
Remove all fields from SELECT clause.
Remove all fields from SELECT clause.
def clear_select_clause(self): """Remove all fields from SELECT clause.""" self.select = () self.default_cols = False self.select_related = False self.set_extra_mask(()) self.set_annotation_mask(())
[ "def", "clear_select_clause", "(", "self", ")", ":", "self", ".", "select", "=", "(", ")", "self", ".", "default_cols", "=", "False", "self", ".", "select_related", "=", "False", "self", ".", "set_extra_mask", "(", "(", ")", ")", "self", ".", "set_annota...
[ 1823, 4 ]
[ 1829, 36 ]
python
en
['en', 'en', 'en']
True
Query.clear_select_fields
(self)
Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
def clear_select_fields(self): """ Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns. """ self.select = () self.values_select = ()
[ "def", "clear_select_fields", "(", "self", ")", ":", "self", ".", "select", "=", "(", ")", "self", ".", "values_select", "=", "(", ")" ]
[ 1831, 4 ]
[ 1838, 31 ]
python
en
['en', 'error', 'th']
False
Query.add_distinct_fields
(self, *field_names)
Add and resolve the given fields to the query's "distinct on" clause.
Add and resolve the given fields to the query's "distinct on" clause.
def add_distinct_fields(self, *field_names): """ Add and resolve the given fields to the query's "distinct on" clause. """ self.distinct_fields = field_names self.distinct = True
[ "def", "add_distinct_fields", "(", "self", ",", "*", "field_names", ")", ":", "self", ".", "distinct_fields", "=", "field_names", "self", ".", "distinct", "=", "True" ]
[ 1848, 4 ]
[ 1853, 28 ]
python
en
['en', 'error', 'th']
False
Query.add_fields
(self, field_names, allow_m2m=True)
Add the given (model) fields to the select set. Add the field names in the order specified.
Add the given (model) fields to the select set. Add the field names in the order specified.
def add_fields(self, field_names, allow_m2m=True): """ Add the given (model) fields to the select set. Add the field names in the order specified. """ alias = self.get_initial_alias() opts = self.get_meta() try: cols = [] for name in field...
[ "def", "add_fields", "(", "self", ",", "field_names", ",", "allow_m2m", "=", "True", ")", ":", "alias", "=", "self", ".", "get_initial_alias", "(", ")", "opts", "=", "self", ".", "get_meta", "(", ")", "try", ":", "cols", "=", "[", "]", "for", "name",...
[ 1855, 4 ]
[ 1891, 78 ]
python
en
['en', 'error', 'th']
False
Query.add_ordering
(self, *ordering)
Add items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions. If 'ordering' is empty, clear all ordering from the query.
Add items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions.
def add_ordering(self, *ordering): """ Add items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions. If 'ordering' is empty, clear...
[ "def", "add_ordering", "(", "self", ",", "*", "ordering", ")", ":", "errors", "=", "[", "]", "for", "item", "in", "ordering", ":", "if", "not", "hasattr", "(", "item", ",", "'resolve_expression'", ")", "and", "not", "ORDER_PATTERN", ".", "match", "(", ...
[ 1893, 4 ]
[ 1916, 41 ]
python
en
['en', 'error', 'th']
False
Query.clear_ordering
(self, force_empty)
Remove any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default).
Remove any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default).
def clear_ordering(self, force_empty): """ Remove any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default). """ self.order_by = () self.extra_order_by = () if force_empty: self.def...
[ "def", "clear_ordering", "(", "self", ",", "force_empty", ")", ":", "self", ".", "order_by", "=", "(", ")", "self", ".", "extra_order_by", "=", "(", ")", "if", "force_empty", ":", "self", ".", "default_ordering", "=", "False" ]
[ 1918, 4 ]
[ 1926, 41 ]
python
en
['en', 'error', 'th']
False
Query.set_group_by
(self, allow_aliases=True)
Expand the GROUP BY clause required by the query. This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the optimization will be made automatically.
Expand the GROUP BY clause required by the query.
def set_group_by(self, allow_aliases=True): """ Expand the GROUP BY clause required by the query. This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the opt...
[ "def", "set_group_by", "(", "self", ",", "allow_aliases", "=", "True", ")", ":", "# Column names from JOINs to check collisions with aliases.", "if", "allow_aliases", ":", "column_names", "=", "set", "(", ")", "seen_models", "=", "set", "(", ")", "for", "join", "i...
[ 1928, 4 ]
[ 1968, 39 ]
python
en
['en', 'error', 'th']
False
Query.add_select_related
(self, fields)
Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
def add_select_related(self, fields): """ Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True). """ if isinstance(self.select_related, bool): field_dict = {} el...
[ "def", "add_select_related", "(", "self", ",", "fields", ")", ":", "if", "isinstance", "(", "self", ".", "select_related", ",", "bool", ")", ":", "field_dict", "=", "{", "}", "else", ":", "field_dict", "=", "self", ".", "select_related", "for", "field", ...
[ 1970, 4 ]
[ 1984, 40 ]
python
en
['en', 'error', 'th']
False