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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DateQuerySet._setup_query | (self) |
Sets up any special features of the query attribute.
Called by the _clone() method after initializing the rest of the
instance.
|
Sets up any special features of the query attribute. | def _setup_query(self):
"""
Sets up any special features of the query attribute.
Called by the _clone() method after initializing the rest of the
instance.
"""
self.query.clear_deferred_loading()
self.query = self.query.clone(klass=sql.DateQuery, setup=True)
... | [
"def",
"_setup_query",
"(",
"self",
")",
":",
"self",
".",
"query",
".",
"clear_deferred_loading",
"(",
")",
"self",
".",
"query",
"=",
"self",
".",
"query",
".",
"clone",
"(",
"klass",
"=",
"sql",
".",
"DateQuery",
",",
"setup",
"=",
"True",
")",
"s... | [
1248,
4
] | [
1258,
72
] | python | en | ['en', 'error', 'th'] | False |
DateTimeQuerySet._setup_query | (self) |
Sets up any special features of the query attribute.
Called by the _clone() method after initializing the rest of the
instance.
|
Sets up any special features of the query attribute. | def _setup_query(self):
"""
Sets up any special features of the query attribute.
Called by the _clone() method after initializing the rest of the
instance.
"""
self.query.clear_deferred_loading()
self.query = self.query.clone(klass=sql.DateTimeQuery, setup=True, ... | [
"def",
"_setup_query",
"(",
"self",
")",
":",
"self",
".",
"query",
".",
"clear_deferred_loading",
"(",
")",
"self",
".",
"query",
"=",
"self",
".",
"query",
".",
"clone",
"(",
"klass",
"=",
"sql",
".",
"DateTimeQuery",
",",
"setup",
"=",
"True",
",",
... | [
1273,
4
] | [
1283,
72
] | python | en | ['en', 'error', 'th'] | False |
RawQuerySet.resolve_model_init_order | (self) |
Resolve the init field names and value positions
|
Resolve the init field names and value positions
| def resolve_model_init_order(self):
"""
Resolve the init field names and value positions
"""
model_init_names = [f.attname for f in self.model._meta.fields
if f.attname in self.columns]
annotation_fields = [(column, pos) for pos, column in enumerate(se... | [
"def",
"resolve_model_init_order",
"(",
"self",
")",
":",
"model_init_names",
"=",
"[",
"f",
".",
"attname",
"for",
"f",
"in",
"self",
".",
"model",
".",
"_meta",
".",
"fields",
"if",
"f",
".",
"attname",
"in",
"self",
".",
"columns",
"]",
"annotation_fi... | [
1543,
4
] | [
1552,
68
] | python | en | ['en', 'error', 'th'] | False |
RawQuerySet.db | (self) | Return the database that will be used if this query is executed now | Return the database that will be used if this query is executed now | def db(self):
"Return the database that will be used if this query is executed now"
return self._db or router.db_for_read(self.model, **self._hints) | [
"def",
"db",
"(",
"self",
")",
":",
"return",
"self",
".",
"_db",
"or",
"router",
".",
"db_for_read",
"(",
"self",
".",
"model",
",",
"*",
"*",
"self",
".",
"_hints",
")"
] | [
1601,
4
] | [
1603,
72
] | python | en | ['en', 'en', 'en'] | True |
RawQuerySet.using | (self, alias) |
Selects which database this Raw QuerySet should execute its query against.
|
Selects which database this Raw QuerySet should execute its query against.
| def using(self, alias):
"""
Selects which database this Raw QuerySet should execute its query against.
"""
return RawQuerySet(self.raw_query, model=self.model,
query=self.query.clone(using=alias),
params=self.params, translations=self.translations,
... | [
"def",
"using",
"(",
"self",
",",
"alias",
")",
":",
"return",
"RawQuerySet",
"(",
"self",
".",
"raw_query",
",",
"model",
"=",
"self",
".",
"model",
",",
"query",
"=",
"self",
".",
"query",
".",
"clone",
"(",
"using",
"=",
"alias",
")",
",",
"para... | [
1605,
4
] | [
1612,
28
] | python | en | ['en', 'error', 'th'] | False |
RawQuerySet.columns | (self) |
A list of model field names in the order they'll appear in the
query results.
|
A list of model field names in the order they'll appear in the
query results.
| def columns(self):
"""
A list of model field names in the order they'll appear in the
query results.
"""
if not hasattr(self, '_columns'):
self._columns = self.query.get_columns()
# Adjust any column names which don't match field names
for (qu... | [
"def",
"columns",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_columns'",
")",
":",
"self",
".",
"_columns",
"=",
"self",
".",
"query",
".",
"get_columns",
"(",
")",
"# Adjust any column names which don't match field names",
"for",
"(",
... | [
1615,
4
] | [
1632,
28
] | python | en | ['en', 'error', 'th'] | False |
RawQuerySet.model_fields | (self) |
A dict mapping column names to model field names.
|
A dict mapping column names to model field names.
| def model_fields(self):
"""
A dict mapping column names to model field names.
"""
if not hasattr(self, '_model_fields'):
converter = connections[self.db].introspection.table_name_converter
self._model_fields = {}
for field in self.model._meta.fields:
... | [
"def",
"model_fields",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_model_fields'",
")",
":",
"converter",
"=",
"connections",
"[",
"self",
".",
"db",
"]",
".",
"introspection",
".",
"table_name_converter",
"self",
".",
"_model_fields"... | [
1635,
4
] | [
1645,
33
] | python | en | ['en', 'error', 'th'] | False |
TextFile.__init__ | (self, filename=None, file=None, **options) | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | def __init__(self, filename=None, file=None, **options):
"""Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'.... | [
"def",
"__init__",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"file",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"filename",
"is",
"None",
"and",
"file",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"you must supply either or both of... | [
77,
4
] | [
108,
25
] | python | en | ['en', 'en', 'en'] | True |
TextFile.open | (self, filename) | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | def open(self, filename):
"""Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor."""
self.filename = filename
self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0 | [
"def",
"open",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"file",
"=",
"io",
".",
"open",
"(",
"self",
".",
"filename",
",",
"'r'",
",",
"errors",
"=",
"self",
".",
"errors",
")",
"self",
".",
"... | [
110,
4
] | [
115,
29
] | python | en | ['en', 'en', 'en'] | True |
TextFile.close | (self) | Close the current file and forget everything we know about it
(filename, current line number). | Close the current file and forget everything we know about it
(filename, current line number). | def close(self):
"""Close the current file and forget everything we know about it
(filename, current line number)."""
file = self.file
self.file = None
self.filename = None
self.current_line = None
file.close() | [
"def",
"close",
"(",
"self",
")",
":",
"file",
"=",
"self",
".",
"file",
"self",
".",
"file",
"=",
"None",
"self",
".",
"filename",
"=",
"None",
"self",
".",
"current_line",
"=",
"None",
"file",
".",
"close",
"(",
")"
] | [
117,
4
] | [
124,
20
] | python | en | ['en', 'en', 'en'] | True |
TextFile.warn | (self, msg, line=None) | Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it overrides
the current line number;... | Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it overrides
the current line number;... | def warn(self, msg, line=None):
"""Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it ov... | [
"def",
"warn",
"(",
"self",
",",
"msg",
",",
"line",
"=",
"None",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"warning: \"",
"+",
"self",
".",
"gen_error",
"(",
"msg",
",",
"line",
")",
"+",
"\"\\n\"",
")"
] | [
141,
4
] | [
149,
72
] | python | en | ['en', 'en', 'en'] | True |
TextFile.readline | (self) | Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
single string. Updat... | Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
single string. Updat... | def readline(self):
"""Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
... | [
"def",
"readline",
"(",
"self",
")",
":",
"# If any \"unread\" lines waiting in 'linebuf', return the top",
"# one. (We don't actually buffer read-ahead data -- lines only",
"# get put in 'linebuf' if the client explicitly does an",
"# 'unreadline()'.",
"if",
"self",
".",
"linebuf",
":"... | [
151,
4
] | [
269,
23
] | python | en | ['en', 'en', 'en'] | True |
TextFile.readlines | (self) | Read and return the list of all logical lines remaining in the
current file. | Read and return the list of all logical lines remaining in the
current file. | def readlines(self):
"""Read and return the list of all logical lines remaining in the
current file."""
lines = []
while True:
line = self.readline()
if line is None:
return lines
lines.append(line) | [
"def",
"readlines",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"line",
"is",
"None",
":",
"return",
"lines",
"lines",
".",
"append",
"(",
"line",
")"
] | [
271,
4
] | [
279,
30
] | python | en | ['en', 'en', 'en'] | True |
TextFile.unreadline | (self, line) | Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead. | Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead. | def unreadline(self, line):
"""Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead."""
self.linebuf.append(line) | [
"def",
"unreadline",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"linebuf",
".",
"append",
"(",
"line",
")"
] | [
281,
4
] | [
285,
33
] | python | en | ['en', 'en', 'en'] | True |
_execfile | (filename, globals, locals=None) |
Python 3 implementation of execfile.
|
Python 3 implementation of execfile.
| def _execfile(filename, globals, locals=None):
"""
Python 3 implementation of execfile.
"""
mode = 'rb'
with open(filename, mode) as stream:
script = stream.read()
if locals is None:
locals = globals
code = compile(script, filename, 'exec')
exec(code, globals, locals) | [
"def",
"_execfile",
"(",
"filename",
",",
"globals",
",",
"locals",
"=",
"None",
")",
":",
"mode",
"=",
"'rb'",
"with",
"open",
"(",
"filename",
",",
"mode",
")",
"as",
"stream",
":",
"script",
"=",
"stream",
".",
"read",
"(",
")",
"if",
"locals",
... | [
34,
0
] | [
44,
31
] | python | en | ['en', 'error', 'th'] | False |
override_temp | (replacement) |
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
|
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
| def override_temp(replacement):
"""
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
"""
os.makedirs(replacement, exist_ok=True)
saved = tempfile.tempdir
tempfile.tempdir = replacement
try:
yield
finally:
tempfile.tempdir = saved | [
"def",
"override_temp",
"(",
"replacement",
")",
":",
"os",
".",
"makedirs",
"(",
"replacement",
",",
"exist_ok",
"=",
"True",
")",
"saved",
"=",
"tempfile",
".",
"tempdir",
"tempfile",
".",
"tempdir",
"=",
"replacement",
"try",
":",
"yield",
"finally",
":... | [
68,
0
] | [
81,
32
] | python | en | ['en', 'error', 'th'] | False |
save_modules | () |
Context in which imported modules are saved.
Translates exceptions internal to the context into the equivalent exception
outside the context.
|
Context in which imported modules are saved. | def save_modules():
"""
Context in which imported modules are saved.
Translates exceptions internal to the context into the equivalent exception
outside the context.
"""
saved = sys.modules.copy()
with ExceptionSaver() as saved_exc:
yield saved
sys.modules.update(saved)
# r... | [
"def",
"save_modules",
"(",
")",
":",
"saved",
"=",
"sys",
".",
"modules",
".",
"copy",
"(",
")",
"with",
"ExceptionSaver",
"(",
")",
"as",
"saved_exc",
":",
"yield",
"saved",
"sys",
".",
"modules",
".",
"update",
"(",
"saved",
")",
"# remove any modules... | [
144,
0
] | [
165,
22
] | python | en | ['en', 'error', 'th'] | False |
_needs_hiding | (mod_name) |
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
>>> _needs_hiding('Cython')
T... |
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
>>> _needs_hiding('Cython')
T... | def _needs_hiding(mod_name):
"""
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
... | [
"def",
"_needs_hiding",
"(",
"mod_name",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'(setuptools|pkg_resources|distutils|Cython)(\\.|$)'",
")",
"return",
"bool",
"(",
"pattern",
".",
"match",
"(",
"mod_name",
")",
")"
] | [
197,
0
] | [
215,
40
] | python | en | ['en', 'error', 'th'] | False |
hide_setuptools | () |
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
|
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
| def hide_setuptools():
"""
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
... | [
"def",
"hide_setuptools",
"(",
")",
":",
"modules",
"=",
"filter",
"(",
"_needs_hiding",
",",
"sys",
".",
"modules",
")",
"_clear_modules",
"(",
"modules",
")"
] | [
218,
0
] | [
226,
27
] | python | en | ['en', 'error', 'th'] | False |
run_setup | (setup_script, args) | Run a distutils setup script, sandboxed in its directory | Run a distutils setup script, sandboxed in its directory | def run_setup(setup_script, args):
"""Run a distutils setup script, sandboxed in its directory"""
setup_dir = os.path.abspath(os.path.dirname(setup_script))
with setup_context(setup_dir):
try:
sys.argv[:] = [setup_script] + list(args)
sys.path.insert(0, setup_dir)
... | [
"def",
"run_setup",
"(",
"setup_script",
",",
"args",
")",
":",
"setup_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"setup_script",
")",
")",
"with",
"setup_context",
"(",
"setup_dir",
")",
":",
"try",
":",... | [
229,
0
] | [
252,
21
] | python | en | ['en', 'lb', 'en'] | True |
UnpickleableException.dump | (type, exc) |
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
|
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
| def dump(type, exc):
"""
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
"""
try:
return pickle.dumps(type), pickle.dumps(exc)
except Exception:
# get UnpickleableException inside the ... | [
"def",
"dump",
"(",
"type",
",",
"exc",
")",
":",
"try",
":",
"return",
"pickle",
".",
"dumps",
"(",
"type",
")",
",",
"pickle",
".",
"dumps",
"(",
"exc",
")",
"except",
"Exception",
":",
"# get UnpickleableException inside the sandbox",
"from",
"setuptools"... | [
100,
4
] | [
110,
48
] | python | en | ['en', 'error', 'th'] | False |
ExceptionSaver.resume | (self) | restore and re-raise any exception | restore and re-raise any exception | def resume(self):
"restore and re-raise any exception"
if '_saved' not in vars(self):
return
type, exc = map(pickle.loads, self._saved)
six.reraise(type, exc, self._tb) | [
"def",
"resume",
"(",
"self",
")",
":",
"if",
"'_saved'",
"not",
"in",
"vars",
"(",
"self",
")",
":",
"return",
"type",
",",
"exc",
"=",
"map",
"(",
"pickle",
".",
"loads",
",",
"self",
".",
"_saved",
")",
"six",
".",
"reraise",
"(",
"type",
",",... | [
133,
4
] | [
140,
40
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox.run | (self, func) | Run 'func' under os sandboxing | Run 'func' under os sandboxing | def run(self, func):
"""Run 'func' under os sandboxing"""
with self:
return func() | [
"def",
"run",
"(",
"self",
",",
"func",
")",
":",
"with",
"self",
":",
"return",
"func",
"(",
")"
] | [
285,
4
] | [
288,
25
] | python | es | ['es', 'jv', 'pt'] | False |
AbstractSandbox._validate_path | (self, path) | Called to remap or validate any path, whether input or output | Called to remap or validate any path, whether input or output | def _validate_path(self, path):
"""Called to remap or validate any path, whether input or output"""
return path | [
"def",
"_validate_path",
"(",
"self",
",",
"path",
")",
":",
"return",
"path"
] | [
355,
4
] | [
357,
19
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_input | (self, operation, path, *args, **kw) | Called for path inputs | Called for path inputs | def _remap_input(self, operation, path, *args, **kw):
"""Called for path inputs"""
return self._validate_path(path) | [
"def",
"_remap_input",
"(",
"self",
",",
"operation",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"_validate_path",
"(",
"path",
")"
] | [
359,
4
] | [
361,
40
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_output | (self, operation, path) | Called for path outputs | Called for path outputs | def _remap_output(self, operation, path):
"""Called for path outputs"""
return self._validate_path(path) | [
"def",
"_remap_output",
"(",
"self",
",",
"operation",
",",
"path",
")",
":",
"return",
"self",
".",
"_validate_path",
"(",
"path",
")"
] | [
363,
4
] | [
365,
40
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_pair | (self, operation, src, dst, *args, **kw) | Called for path pairs like rename, link, and symlink operations | Called for path pairs like rename, link, and symlink operations | def _remap_pair(self, operation, src, dst, *args, **kw):
"""Called for path pairs like rename, link, and symlink operations"""
return (
self._remap_input(operation + '-from', src, *args, **kw),
self._remap_input(operation + '-to', dst, *args, **kw)
) | [
"def",
"_remap_pair",
"(",
"self",
",",
"operation",
",",
"src",
",",
"dst",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"(",
"self",
".",
"_remap_input",
"(",
"operation",
"+",
"'-from'",
",",
"src",
",",
"*",
"args",
",",
"*",
"*... | [
367,
4
] | [
372,
9
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox._remap_input | (self, operation, path, *args, **kw) | Called for path inputs | Called for path inputs | def _remap_input(self, operation, path, *args, **kw):
"""Called for path inputs"""
if operation in self.write_ops and not self._ok(path):
self._violation(operation, os.path.realpath(path), *args, **kw)
return path | [
"def",
"_remap_input",
"(",
"self",
",",
"operation",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"operation",
"in",
"self",
".",
"write_ops",
"and",
"not",
"self",
".",
"_ok",
"(",
"path",
")",
":",
"self",
".",
"_violation... | [
448,
4
] | [
452,
19
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox._remap_pair | (self, operation, src, dst, *args, **kw) | Called for path pairs like rename, link, and symlink operations | Called for path pairs like rename, link, and symlink operations | def _remap_pair(self, operation, src, dst, *args, **kw):
"""Called for path pairs like rename, link, and symlink operations"""
if not self._ok(src) or not self._ok(dst):
self._violation(operation, src, dst, *args, **kw)
return (src, dst) | [
"def",
"_remap_pair",
"(",
"self",
",",
"operation",
",",
"src",
",",
"dst",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_ok",
"(",
"src",
")",
"or",
"not",
"self",
".",
"_ok",
"(",
"dst",
")",
":",
"self",
"."... | [
454,
4
] | [
458,
25
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox.open | (self, file, flags, mode=0o777, *args, **kw) | Called for low-level os.open() | Called for low-level os.open() | def open(self, file, flags, mode=0o777, *args, **kw):
"""Called for low-level os.open()"""
if flags & WRITE_FLAGS and not self._ok(file):
self._violation("os.open", file, flags, mode, *args, **kw)
return _os.open(file, flags, mode, *args, **kw) | [
"def",
"open",
"(",
"self",
",",
"file",
",",
"flags",
",",
"mode",
"=",
"0o777",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"flags",
"&",
"WRITE_FLAGS",
"and",
"not",
"self",
".",
"_ok",
"(",
"file",
")",
":",
"self",
".",
"_violat... | [
460,
4
] | [
464,
55
] | python | en | ['en', 'en', 'en'] | True |
SecurityMiddlewareTest.test_sts_on | (self) |
With HSTS_SECONDS=3600, the middleware adds
"strict-transport-security: max-age=3600" to the response.
|
With HSTS_SECONDS=3600, the middleware adds
"strict-transport-security: max-age=3600" to the response.
| def test_sts_on(self):
"""
With HSTS_SECONDS=3600, the middleware adds
"strict-transport-security: max-age=3600" to the response.
"""
self.assertEqual(
self.process_response(secure=True)["strict-transport-security"],
"max-age=3600") | [
"def",
"test_sts_on",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
")",
"[",
"\"strict-transport-security\"",
"]",
",",
"\"max-age=3600\"",
")"
] | [
43,
4
] | [
50,
27
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_sts_already_present | (self) |
The middleware will not override a "strict-transport-security" header
already present in the response.
|
The middleware will not override a "strict-transport-security" header
already present in the response.
| def test_sts_already_present(self):
"""
The middleware will not override a "strict-transport-security" header
already present in the response.
"""
response = self.process_response(
secure=True,
headers={"strict-transport-security": "max-age=7200"})
... | [
"def",
"test_sts_already_present",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
",",
"headers",
"=",
"{",
"\"strict-transport-security\"",
":",
"\"max-age=7200\"",
"}",
")",
"self",
".",
"assertEqual",
"(",... | [
53,
4
] | [
61,
79
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_sts_only_if_secure | (self) |
The "strict-transport-security" header is not added to responses going
over an insecure connection.
|
The "strict-transport-security" header is not added to responses going
over an insecure connection.
| def test_sts_only_if_secure(self):
"""
The "strict-transport-security" header is not added to responses going
over an insecure connection.
"""
self.assertNotIn("strict-transport-security", self.process_response(secure=False)) | [
"def",
"test_sts_only_if_secure",
"(",
"self",
")",
":",
"self",
".",
"assertNotIn",
"(",
"\"strict-transport-security\"",
",",
"self",
".",
"process_response",
"(",
"secure",
"=",
"False",
")",
")"
] | [
64,
4
] | [
69,
90
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_sts_off | (self) |
With HSTS_SECONDS of 0, the middleware does not add a
"strict-transport-security" header to the response.
|
With HSTS_SECONDS of 0, the middleware does not add a
"strict-transport-security" header to the response.
| def test_sts_off(self):
"""
With HSTS_SECONDS of 0, the middleware does not add a
"strict-transport-security" header to the response.
"""
self.assertNotIn("strict-transport-security", self.process_response(secure=True)) | [
"def",
"test_sts_off",
"(",
"self",
")",
":",
"self",
".",
"assertNotIn",
"(",
"\"strict-transport-security\"",
",",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
")",
")"
] | [
72,
4
] | [
77,
89
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_sts_include_subdomains | (self) |
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
True, the middleware adds a "strict-transport-security" header with the
"includeSubDomains" tag to the response.
|
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
True, the middleware adds a "strict-transport-security" header with the
"includeSubDomains" tag to the response.
| def test_sts_include_subdomains(self):
"""
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
True, the middleware adds a "strict-transport-security" header with the
"includeSubDomains" tag to the response.
"""
response = self.process_response(secure=True)
sel... | [
"def",
"test_sts_include_subdomains",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
")",
"self",
".",
"assertEqual",
"(",
"response",
"[",
"\"strict-transport-security\"",
"]",
",",
"\"max-age=600; includeSubDom... | [
81,
4
] | [
91,
13
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_sts_no_include_subdomains | (self) |
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
False, the middleware adds a "strict-transport-security" header without
the "includeSubDomains" tag to the response.
|
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
False, the middleware adds a "strict-transport-security" header without
the "includeSubDomains" tag to the response.
| def test_sts_no_include_subdomains(self):
"""
With HSTS_SECONDS non-zero and HSTS_INCLUDE_SUBDOMAINS
False, the middleware adds a "strict-transport-security" header without
the "includeSubDomains" tag to the response.
"""
response = self.process_response(secure=True)
... | [
"def",
"test_sts_no_include_subdomains",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
")",
"self",
".",
"assertEqual",
"(",
"response",
"[",
"\"strict-transport-security\"",
"]",
",",
"\"max-age=600\"",
")"
] | [
95,
4
] | [
102,
78
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_content_type_on | (self) |
With CONTENT_TYPE_NOSNIFF set to True, the middleware adds
"x-content-type-options: nosniff" header to the response.
|
With CONTENT_TYPE_NOSNIFF set to True, the middleware adds
"x-content-type-options: nosniff" header to the response.
| def test_content_type_on(self):
"""
With CONTENT_TYPE_NOSNIFF set to True, the middleware adds
"x-content-type-options: nosniff" header to the response.
"""
self.assertEqual(self.process_response()["x-content-type-options"], "nosniff") | [
"def",
"test_content_type_on",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"self",
".",
"process_response",
"(",
")",
"[",
"\"x-content-type-options\"",
"]",
",",
"\"nosniff\"",
")"
] | [
105,
4
] | [
110,
86
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_content_type_already_present | (self) |
The middleware will not override an "x-content-type-options" header
already present in the response.
|
The middleware will not override an "x-content-type-options" header
already present in the response.
| def test_content_type_already_present(self):
"""
The middleware will not override an "x-content-type-options" header
already present in the response.
"""
response = self.process_response(secure=True, headers={"x-content-type-options": "foo"})
self.assertEqual(response["x-... | [
"def",
"test_content_type_already_present",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
",",
"headers",
"=",
"{",
"\"x-content-type-options\"",
":",
"\"foo\"",
"}",
")",
"self",
".",
"assertEqual",
"(",
... | [
113,
4
] | [
119,
67
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_content_type_off | (self) |
With CONTENT_TYPE_NOSNIFF False, the middleware does not add an
"x-content-type-options" header to the response.
|
With CONTENT_TYPE_NOSNIFF False, the middleware does not add an
"x-content-type-options" header to the response.
| def test_content_type_off(self):
"""
With CONTENT_TYPE_NOSNIFF False, the middleware does not add an
"x-content-type-options" header to the response.
"""
self.assertNotIn("x-content-type-options", self.process_response()) | [
"def",
"test_content_type_off",
"(",
"self",
")",
":",
"self",
".",
"assertNotIn",
"(",
"\"x-content-type-options\"",
",",
"self",
".",
"process_response",
"(",
")",
")"
] | [
122,
4
] | [
127,
75
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_xss_filter_on | (self) |
With BROWSER_XSS_FILTER set to True, the middleware adds
"s-xss-protection: 1; mode=block" header to the response.
|
With BROWSER_XSS_FILTER set to True, the middleware adds
"s-xss-protection: 1; mode=block" header to the response.
| def test_xss_filter_on(self):
"""
With BROWSER_XSS_FILTER set to True, the middleware adds
"s-xss-protection: 1; mode=block" header to the response.
"""
self.assertEqual(
self.process_response()["x-xss-protection"],
"1; mode=block") | [
"def",
"test_xss_filter_on",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"self",
".",
"process_response",
"(",
")",
"[",
"\"x-xss-protection\"",
"]",
",",
"\"1; mode=block\"",
")"
] | [
130,
4
] | [
137,
28
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_xss_filter_already_present | (self) |
The middleware will not override an "x-xss-protection" header
already present in the response.
|
The middleware will not override an "x-xss-protection" header
already present in the response.
| def test_xss_filter_already_present(self):
"""
The middleware will not override an "x-xss-protection" header
already present in the response.
"""
response = self.process_response(secure=True, headers={"x-xss-protection": "foo"})
self.assertEqual(response["x-xss-protection... | [
"def",
"test_xss_filter_already_present",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"process_response",
"(",
"secure",
"=",
"True",
",",
"headers",
"=",
"{",
"\"x-xss-protection\"",
":",
"\"foo\"",
"}",
")",
"self",
".",
"assertEqual",
"(",
"respons... | [
140,
4
] | [
146,
61
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_xss_filter_off | (self) |
With BROWSER_XSS_FILTER set to False, the middleware does not add an
"x-xss-protection" header to the response.
|
With BROWSER_XSS_FILTER set to False, the middleware does not add an
"x-xss-protection" header to the response.
| def test_xss_filter_off(self):
"""
With BROWSER_XSS_FILTER set to False, the middleware does not add an
"x-xss-protection" header to the response.
"""
self.assertFalse("x-xss-protection" in self.process_response()) | [
"def",
"test_xss_filter_off",
"(",
"self",
")",
":",
"self",
".",
"assertFalse",
"(",
"\"x-xss-protection\"",
"in",
"self",
".",
"process_response",
"(",
")",
")"
] | [
149,
4
] | [
154,
71
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_ssl_redirect_on | (self) |
With SSL_REDIRECT True, the middleware redirects any non-secure
requests to the https:// version of the same URL.
|
With SSL_REDIRECT True, the middleware redirects any non-secure
requests to the https:// version of the same URL.
| def test_ssl_redirect_on(self):
"""
With SSL_REDIRECT True, the middleware redirects any non-secure
requests to the https:// version of the same URL.
"""
ret = self.process_request("get", "/some/url?query=string")
self.assertEqual(ret.status_code, 301)
self.assert... | [
"def",
"test_ssl_redirect_on",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"process_request",
"(",
"\"get\"",
",",
"\"/some/url?query=string\"",
")",
"self",
".",
"assertEqual",
"(",
"ret",
".",
"status_code",
",",
"301",
")",
"self",
".",
"assertEqual",
... | [
157,
4
] | [
165,
72
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_no_redirect_ssl | (self) |
The middleware does not redirect secure requests.
|
The middleware does not redirect secure requests.
| def test_no_redirect_ssl(self):
"""
The middleware does not redirect secure requests.
"""
ret = self.process_request("get", "/some/url", secure=True)
self.assertEqual(ret, None) | [
"def",
"test_no_redirect_ssl",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"process_request",
"(",
"\"get\"",
",",
"\"/some/url\"",
",",
"secure",
"=",
"True",
")",
"self",
".",
"assertEqual",
"(",
"ret",
",",
"None",
")"
] | [
168,
4
] | [
173,
35
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_redirect_exempt | (self) |
The middleware does not redirect requests with URL path matching an
exempt pattern.
|
The middleware does not redirect requests with URL path matching an
exempt pattern.
| def test_redirect_exempt(self):
"""
The middleware does not redirect requests with URL path matching an
exempt pattern.
"""
ret = self.process_request("get", "/insecure/page")
self.assertEqual(ret, None) | [
"def",
"test_redirect_exempt",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"process_request",
"(",
"\"get\"",
",",
"\"/insecure/page\"",
")",
"self",
".",
"assertEqual",
"(",
"ret",
",",
"None",
")"
] | [
177,
4
] | [
183,
35
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_redirect_ssl_host | (self) |
The middleware redirects to SSL_HOST if given.
|
The middleware redirects to SSL_HOST if given.
| def test_redirect_ssl_host(self):
"""
The middleware redirects to SSL_HOST if given.
"""
ret = self.process_request("get", "/some/url")
self.assertEqual(ret.status_code, 301)
self.assertEqual(ret["Location"], "https://secure.example.com/some/url") | [
"def",
"test_redirect_ssl_host",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"process_request",
"(",
"\"get\"",
",",
"\"/some/url\"",
")",
"self",
".",
"assertEqual",
"(",
"ret",
".",
"status_code",
",",
"301",
")",
"self",
".",
"assertEqual",
"(",
"re... | [
187,
4
] | [
193,
80
] | python | en | ['en', 'error', 'th'] | False |
SecurityMiddlewareTest.test_ssl_redirect_off | (self) |
With SSL_REDIRECT False, the middleware does no redirect.
|
With SSL_REDIRECT False, the middleware does no redirect.
| def test_ssl_redirect_off(self):
"""
With SSL_REDIRECT False, the middleware does no redirect.
"""
ret = self.process_request("get", "/some/url")
self.assertEqual(ret, None) | [
"def",
"test_ssl_redirect_off",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"process_request",
"(",
"\"get\"",
",",
"\"/some/url\"",
")",
"self",
".",
"assertEqual",
"(",
"ret",
",",
"None",
")"
] | [
196,
4
] | [
201,
35
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_lookup_allowed_allows_nonexistent_lookup | (self) |
Ensure that a lookup_allowed allows a parameter
whose field lookup doesn't exist.
Refs #21129.
|
Ensure that a lookup_allowed allows a parameter
whose field lookup doesn't exist.
Refs #21129.
| def test_lookup_allowed_allows_nonexistent_lookup(self):
"""
Ensure that a lookup_allowed allows a parameter
whose field lookup doesn't exist.
Refs #21129.
"""
class BandAdmin(ModelAdmin):
fields = ['name']
ma = BandAdmin(Band, self.site)
self... | [
"def",
"test_lookup_allowed_allows_nonexistent_lookup",
"(",
"self",
")",
":",
"class",
"BandAdmin",
"(",
"ModelAdmin",
")",
":",
"fields",
"=",
"[",
"'name'",
"]",
"ma",
"=",
"BandAdmin",
"(",
"Band",
",",
"self",
".",
"site",
")",
"self",
".",
"assertTrue"... | [
98,
4
] | [
108,
77
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_custom_form_meta_exclude_with_readonly | (self) |
Ensure that the custom ModelForm's `Meta.exclude` is respected when
used in conjunction with `ModelAdmin.readonly_fields` and when no
`ModelAdmin.exclude` is defined.
Refs #14496.
|
Ensure that the custom ModelForm's `Meta.exclude` is respected when
used in conjunction with `ModelAdmin.readonly_fields` and when no
`ModelAdmin.exclude` is defined.
Refs #14496.
| def test_custom_form_meta_exclude_with_readonly(self):
"""
Ensure that the custom ModelForm's `Meta.exclude` is respected when
used in conjunction with `ModelAdmin.readonly_fields` and when no
`ModelAdmin.exclude` is defined.
Refs #14496.
"""
# First, with `ModelA... | [
"def",
"test_custom_form_meta_exclude_with_readonly",
"(",
"self",
")",
":",
"# First, with `ModelAdmin` -----------------------",
"class",
"AdminBandForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"Band",
"exclude",
"=",
"[",
"'bi... | [
178,
4
] | [
223,
58
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_custom_form_meta_exclude | (self) |
Ensure that the custom ModelForm's `Meta.exclude` is overridden if
`ModelAdmin.exclude` or `InlineModelAdmin.exclude` are defined.
Refs #14496.
|
Ensure that the custom ModelForm's `Meta.exclude` is overridden if
`ModelAdmin.exclude` or `InlineModelAdmin.exclude` are defined.
Refs #14496.
| def test_custom_form_meta_exclude(self):
"""
Ensure that the custom ModelForm's `Meta.exclude` is overridden if
`ModelAdmin.exclude` or `InlineModelAdmin.exclude` are defined.
Refs #14496.
"""
# First, with `ModelAdmin` -----------------------
class AdminBandForm... | [
"def",
"test_custom_form_meta_exclude",
"(",
"self",
")",
":",
"# First, with `ModelAdmin` -----------------------",
"class",
"AdminBandForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"Band",
"exclude",
"=",
"[",
"'bio'",
"]",
... | [
225,
4
] | [
269,
65
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_form_exclude_kwarg_override | (self) |
Ensure that the `exclude` kwarg passed to `ModelAdmin.get_form()`
overrides all other declarations. Refs #8999.
|
Ensure that the `exclude` kwarg passed to `ModelAdmin.get_form()`
overrides all other declarations. Refs #8999.
| def test_form_exclude_kwarg_override(self):
"""
Ensure that the `exclude` kwarg passed to `ModelAdmin.get_form()`
overrides all other declarations. Refs #8999.
"""
class AdminBandForm(forms.ModelForm):
class Meta:
model = Band
exclude... | [
"def",
"test_form_exclude_kwarg_override",
"(",
"self",
")",
":",
"class",
"AdminBandForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"Band",
"exclude",
"=",
"[",
"'name'",
"]",
"class",
"BandAdmin",
"(",
"ModelAdmin",
")"... | [
289,
4
] | [
311,
34
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_formset_exclude_kwarg_override | (self) |
Ensure that the `exclude` kwarg passed to `InlineModelAdmin.get_formset()`
overrides all other declarations. Refs #8999.
|
Ensure that the `exclude` kwarg passed to `InlineModelAdmin.get_formset()`
overrides all other declarations. Refs #8999.
| def test_formset_exclude_kwarg_override(self):
"""
Ensure that the `exclude` kwarg passed to `InlineModelAdmin.get_formset()`
overrides all other declarations. Refs #8999.
"""
class AdminConcertForm(forms.ModelForm):
class Meta:
model = Concert
... | [
"def",
"test_formset_exclude_kwarg_override",
"(",
"self",
")",
":",
"class",
"AdminConcertForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"Concert",
"exclude",
"=",
"[",
"'day'",
"]",
"class",
"ConcertInline",
"(",
"Tabula... | [
313,
4
] | [
343,
62
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminTests.test_regression_for_ticket_15820 | (self) |
Ensure that `obj` is passed from `InlineModelAdmin.get_fieldsets()` to
`InlineModelAdmin.get_formset()`.
|
Ensure that `obj` is passed from `InlineModelAdmin.get_fieldsets()` to
`InlineModelAdmin.get_formset()`.
| def test_regression_for_ticket_15820(self):
"""
Ensure that `obj` is passed from `InlineModelAdmin.get_fieldsets()` to
`InlineModelAdmin.get_formset()`.
"""
class CustomConcertForm(forms.ModelForm):
class Meta:
model = Concert
fields =... | [
"def",
"test_regression_for_ticket_15820",
"(",
"self",
")",
":",
"class",
"CustomConcertForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"Concert",
"fields",
"=",
"[",
"'day'",
"]",
"class",
"ConcertInline",
"(",
"TabularIn... | [
383,
4
] | [
414,
60
] | python | en | ['en', 'error', 'th'] | False |
CheckTestCase.assertIsInvalidRegexp | (self, model_admin, model, msg,
id=None, hint=None, invalid_obj=None) |
Same as assertIsInvalid but treats the given msg as a regexp.
|
Same as assertIsInvalid but treats the given msg as a regexp.
| def assertIsInvalidRegexp(self, model_admin, model, msg,
id=None, hint=None, invalid_obj=None):
"""
Same as assertIsInvalid but treats the given msg as a regexp.
"""
invalid_obj = invalid_obj or model_admin
errors = model_admin.check(model=model)
self.assertEq... | [
"def",
"assertIsInvalidRegexp",
"(",
"self",
",",
"model_admin",
",",
"model",
",",
"msg",
",",
"id",
"=",
"None",
",",
"hint",
"=",
"None",
",",
"invalid_obj",
"=",
"None",
")",
":",
"invalid_obj",
"=",
"invalid_obj",
"or",
"model_admin",
"errors",
"=",
... | [
556,
4
] | [
568,
45
] | python | en | ['en', 'error', 'th'] | False |
InlinesCheckTests.test_invalid_model_type | (self) | Test if `model` attribute on inline model admin is a models.Model.
| Test if `model` attribute on inline model admin is a models.Model.
| def test_invalid_model_type(self):
""" Test if `model` attribute on inline model admin is a models.Model.
"""
class SomethingBad(object):
pass
class ValidationTestInline(TabularInline):
model = SomethingBad
class ValidationTestModelAdmin(ModelAdmin):
... | [
"def",
"test_invalid_model_type",
"(",
"self",
")",
":",
"class",
"SomethingBad",
"(",
"object",
")",
":",
"pass",
"class",
"ValidationTestInline",
"(",
"TabularInline",
")",
":",
"model",
"=",
"SomethingBad",
"class",
"ValidationTestModelAdmin",
"(",
"ModelAdmin",
... | [
1337,
4
] | [
1353,
25
] | python | en | ['en', 'fy', 'en'] | True |
CustomModelAdminTests.test_deprecation | (self) | Deprecated Custom Validator definitions still work with the check framework. | Deprecated Custom Validator definitions still work with the check framework. | def test_deprecation(self):
"Deprecated Custom Validator definitions still work with the check framework."
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RemovedInDjango19Warning)
class CustomValidator(ModelAdminValidator):
def validate_... | [
"def",
"test_deprecation",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
",",
"category",
"=",
"RemovedInDjango19Warning",
")",
"class",
"CustomValidator",
"(",
"ModelAdminValid... | [
1507,
4
] | [
1519,
81
] | python | en | ['en', 'en', 'en'] | True |
ListDisplayEditableTests.test_list_display_links_is_none | (self) |
list_display and list_editable can contain the same values
when list_display_links is None
|
list_display and list_editable can contain the same values
when list_display_links is None
| def test_list_display_links_is_none(self):
"""
list_display and list_editable can contain the same values
when list_display_links is None
"""
class ProductAdmin(ModelAdmin):
list_display = ['name', 'slug', 'pub_date']
list_editable = list_display
... | [
"def",
"test_list_display_links_is_none",
"(",
"self",
")",
":",
"class",
"ProductAdmin",
"(",
"ModelAdmin",
")",
":",
"list_display",
"=",
"[",
"'name'",
",",
"'slug'",
",",
"'pub_date'",
"]",
"list_editable",
"=",
"list_display",
"list_display_links",
"=",
"None... | [
1523,
4
] | [
1532,
61
] | python | en | ['en', 'error', 'th'] | False |
ListDisplayEditableTests.test_list_display_same_as_list_editable | (self) |
The first item in list_display can be the same as the first
in list_editable
|
The first item in list_display can be the same as the first
in list_editable
| def test_list_display_same_as_list_editable(self):
"""
The first item in list_display can be the same as the first
in list_editable
"""
class ProductAdmin(ModelAdmin):
list_display = ['name', 'slug', 'pub_date']
list_editable = ['name', 'slug']
... | [
"def",
"test_list_display_same_as_list_editable",
"(",
"self",
")",
":",
"class",
"ProductAdmin",
"(",
"ModelAdmin",
")",
":",
"list_display",
"=",
"[",
"'name'",
",",
"'slug'",
",",
"'pub_date'",
"]",
"list_editable",
"=",
"[",
"'name'",
",",
"'slug'",
"]",
"... | [
1534,
4
] | [
1543,
61
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminPermissionTests.test_has_add_permission | (self) |
Ensure that has_add_permission returns True for users who can add
objects and False for users who can't.
|
Ensure that has_add_permission returns True for users who can add
objects and False for users who can't.
| def test_has_add_permission(self):
"""
Ensure that has_add_permission returns True for users who can add
objects and False for users who can't.
"""
ma = ModelAdmin(Band, AdminSite())
request = MockRequest()
request.user = self.MockAddUser()
self.assertTrue... | [
"def",
"test_has_add_permission",
"(",
"self",
")",
":",
"ma",
"=",
"ModelAdmin",
"(",
"Band",
",",
"AdminSite",
"(",
")",
")",
"request",
"=",
"MockRequest",
"(",
")",
"request",
".",
"user",
"=",
"self",
".",
"MockAddUser",
"(",
")",
"self",
".",
"as... | [
1572,
4
] | [
1584,
56
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminPermissionTests.test_has_change_permission | (self) |
Ensure that has_change_permission returns True for users who can edit
objects and False for users who can't.
|
Ensure that has_change_permission returns True for users who can edit
objects and False for users who can't.
| def test_has_change_permission(self):
"""
Ensure that has_change_permission returns True for users who can edit
objects and False for users who can't.
"""
ma = ModelAdmin(Band, AdminSite())
request = MockRequest()
request.user = self.MockAddUser()
self.ass... | [
"def",
"test_has_change_permission",
"(",
"self",
")",
":",
"ma",
"=",
"ModelAdmin",
"(",
"Band",
",",
"AdminSite",
"(",
")",
")",
"request",
"=",
"MockRequest",
"(",
")",
"request",
".",
"user",
"=",
"self",
".",
"MockAddUser",
"(",
")",
"self",
".",
... | [
1586,
4
] | [
1598,
59
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminPermissionTests.test_has_delete_permission | (self) |
Ensure that has_delete_permission returns True for users who can delete
objects and False for users who can't.
|
Ensure that has_delete_permission returns True for users who can delete
objects and False for users who can't.
| def test_has_delete_permission(self):
"""
Ensure that has_delete_permission returns True for users who can delete
objects and False for users who can't.
"""
ma = ModelAdmin(Band, AdminSite())
request = MockRequest()
request.user = self.MockAddUser()
self.a... | [
"def",
"test_has_delete_permission",
"(",
"self",
")",
":",
"ma",
"=",
"ModelAdmin",
"(",
"Band",
",",
"AdminSite",
"(",
")",
")",
"request",
"=",
"MockRequest",
"(",
")",
"request",
".",
"user",
"=",
"self",
".",
"MockAddUser",
"(",
")",
"self",
".",
... | [
1600,
4
] | [
1612,
58
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminPermissionTests.test_has_module_permission | (self) |
Ensure that has_module_permission returns True for users who have any
permission for the module and False for users who don't.
|
Ensure that has_module_permission returns True for users who have any
permission for the module and False for users who don't.
| def test_has_module_permission(self):
"""
Ensure that has_module_permission returns True for users who have any
permission for the module and False for users who don't.
"""
ma = ModelAdmin(Band, AdminSite())
request = MockRequest()
request.user = self.MockAddUser(... | [
"def",
"test_has_module_permission",
"(",
"self",
")",
":",
"ma",
"=",
"ModelAdmin",
"(",
"Band",
",",
"AdminSite",
"(",
")",
")",
"request",
"=",
"MockRequest",
"(",
")",
"request",
".",
"user",
"=",
"self",
".",
"MockAddUser",
"(",
")",
"self",
".",
... | [
1614,
4
] | [
1633,
59
] | python | en | ['en', 'error', 'th'] | False |
set_session_data | (storage, messages) |
Sets the messages into the backend request's session and remove the
backend's loaded data cache.
|
Sets the messages into the backend request's session and remove the
backend's loaded data cache.
| def set_session_data(storage, messages):
"""
Sets the messages into the backend request's session and remove the
backend's loaded data cache.
"""
storage.request.session[storage.session_key] = storage.serialize_messages(messages)
if hasattr(storage, '_loaded_data'):
del storage._loaded_d... | [
"def",
"set_session_data",
"(",
"storage",
",",
"messages",
")",
":",
"storage",
".",
"request",
".",
"session",
"[",
"storage",
".",
"session_key",
"]",
"=",
"storage",
".",
"serialize_messages",
"(",
"messages",
")",
"if",
"hasattr",
"(",
"storage",
",",
... | [
8,
0
] | [
15,
32
] | python | en | ['en', 'error', 'th'] | False |
SessionTest.test_safedata | (self) |
Tests that a message containing SafeData is keeping its safe status when
retrieved from the message storage.
|
Tests that a message containing SafeData is keeping its safe status when
retrieved from the message storage.
| def test_safedata(self):
"""
Tests that a message containing SafeData is keeping its safe status when
retrieved from the message storage.
"""
storage = self.get_storage()
message = Message(constants.DEBUG, mark_safe("<b>Hello Django!</b>"))
set_session_data(stora... | [
"def",
"test_safedata",
"(",
"self",
")",
":",
"storage",
"=",
"self",
".",
"get_storage",
"(",
")",
"message",
"=",
"Message",
"(",
"constants",
".",
"DEBUG",
",",
"mark_safe",
"(",
"\"<b>Hello Django!</b>\"",
")",
")",
"set_session_data",
"(",
"storage",
"... | [
43,
4
] | [
52,
65
] | python | en | ['en', 'error', 'th'] | False |
MiddlewareTest.test_request | (self) | Makes sure that the request has correct `site` attribute. | Makes sure that the request has correct `site` attribute. | def test_request(self):
""" Makes sure that the request has correct `site` attribute. """
middleware = CurrentSiteMiddleware()
request = HttpRequest()
middleware.process_request(request)
self.assertEqual(request.site.id, settings.SITE_ID) | [
"def",
"test_request",
"(",
"self",
")",
":",
"middleware",
"=",
"CurrentSiteMiddleware",
"(",
")",
"request",
"=",
"HttpRequest",
"(",
")",
"middleware",
".",
"process_request",
"(",
"request",
")",
"self",
".",
"assertEqual",
"(",
"request",
".",
"site",
"... | [
123,
4
] | [
128,
59
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testInit | (self) | Testing initialization from valid units | Testing initialization from valid units | def testInit(self):
"Testing initialization from valid units"
d = Distance(m=100)
self.assertEqual(d.m, 100)
d1, d2, d3 = D(m=100), D(meter=100), D(metre=100)
for d in (d1, d2, d3):
self.assertEqual(d.m, 100)
d = D(nm=100)
self.assertEqual(d.m, 18520... | [
"def",
"testInit",
"(",
"self",
")",
":",
"d",
"=",
"Distance",
"(",
"m",
"=",
"100",
")",
"self",
".",
"assertEqual",
"(",
"d",
".",
"m",
",",
"100",
")",
"d1",
",",
"d2",
",",
"d3",
"=",
"D",
"(",
"m",
"=",
"100",
")",
",",
"D",
"(",
"m... | [
13,
4
] | [
32,
42
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testInitInvalid | (self) | Testing initialization from invalid units | Testing initialization from invalid units | def testInitInvalid(self):
"Testing initialization from invalid units"
self.assertRaises(AttributeError, D, banana=100) | [
"def",
"testInitInvalid",
"(",
"self",
")",
":",
"self",
".",
"assertRaises",
"(",
"AttributeError",
",",
"D",
",",
"banana",
"=",
"100",
")"
] | [
34,
4
] | [
36,
56
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testAccess | (self) | Testing access in different units | Testing access in different units | def testAccess(self):
"Testing access in different units"
d = D(m=100)
self.assertEqual(d.km, 0.1)
self.assertAlmostEqual(d.ft, 328.084, 3) | [
"def",
"testAccess",
"(",
"self",
")",
":",
"d",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"self",
".",
"assertEqual",
"(",
"d",
".",
"km",
",",
"0.1",
")",
"self",
".",
"assertAlmostEqual",
"(",
"d",
".",
"ft",
",",
"328.084",
",",
"3",
")"
] | [
38,
4
] | [
42,
48
] | python | en | ['de', 'en', 'en'] | True |
DistanceTest.testAccessInvalid | (self) | Testing access in invalid units | Testing access in invalid units | def testAccessInvalid(self):
"Testing access in invalid units"
d = D(m=100)
self.assertFalse(hasattr(d, 'banana')) | [
"def",
"testAccessInvalid",
"(",
"self",
")",
":",
"d",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"self",
".",
"assertFalse",
"(",
"hasattr",
"(",
"d",
",",
"'banana'",
")",
")"
] | [
44,
4
] | [
47,
46
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testAddition | (self) | Test addition & subtraction | Test addition & subtraction | def testAddition(self):
"Test addition & subtraction"
d1 = D(m=100)
d2 = D(m=200)
d3 = d1 + d2
self.assertEqual(d3.m, 300)
d3 += d1
self.assertEqual(d3.m, 400)
d4 = d1 - d2
self.assertEqual(d4.m, -100)
d4 -= d1
self.assertEqual(d4... | [
"def",
"testAddition",
"(",
"self",
")",
":",
"d1",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"d2",
"=",
"D",
"(",
"m",
"=",
"200",
")",
"d3",
"=",
"d1",
"+",
"d2",
"self",
".",
"assertEqual",
"(",
"d3",
".",
"m",
",",
"300",
")",
"d3",
"+=",
... | [
49,
4
] | [
74,
19
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testMultiplication | (self) | Test multiplication & division | Test multiplication & division | def testMultiplication(self):
"Test multiplication & division"
d1 = D(m=100)
d3 = d1 * 2
self.assertEqual(d3.m, 200)
d3 = 2 * d1
self.assertEqual(d3.m, 200)
d3 *= 5
self.assertEqual(d3.m, 1000)
d4 = d1 / 2
self.assertEqual(d4.m, 50)
... | [
"def",
"testMultiplication",
"(",
"self",
")",
":",
"d1",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"d3",
"=",
"d1",
"*",
"2",
"self",
".",
"assertEqual",
"(",
"d3",
".",
"m",
",",
"200",
")",
"d3",
"=",
"2",
"*",
"d1",
"self",
".",
"assertEqual",
... | [
76,
4
] | [
102,
24
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testUnitConversions | (self) | Testing default units during maths | Testing default units during maths | def testUnitConversions(self):
"Testing default units during maths"
d1 = D(m=100)
d2 = D(km=1)
d3 = d1 + d2
self.assertEqual(d3._default_unit, 'm')
d4 = d2 + d1
self.assertEqual(d4._default_unit, 'km')
d5 = d1 * 2
self.assertEqual(d5._default_unit... | [
"def",
"testUnitConversions",
"(",
"self",
")",
":",
"d1",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"d2",
"=",
"D",
"(",
"km",
"=",
"1",
")",
"d3",
"=",
"d1",
"+",
"d2",
"self",
".",
"assertEqual",
"(",
"d3",
".",
"_default_unit",
",",
"'m'",
")",
... | [
104,
4
] | [
116,
47
] | python | en | ['de', 'en', 'en'] | True |
DistanceTest.testComparisons | (self) | Testing comparisons | Testing comparisons | def testComparisons(self):
"Testing comparisons"
d1 = D(m=100)
d2 = D(km=1)
d3 = D(km=0)
self.assertTrue(d2 > d1)
self.assertTrue(d1 == d1)
self.assertTrue(d1 < d2)
self.assertFalse(d3) | [
"def",
"testComparisons",
"(",
"self",
")",
":",
"d1",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"d2",
"=",
"D",
"(",
"km",
"=",
"1",
")",
"d3",
"=",
"D",
"(",
"km",
"=",
"0",
")",
"self",
".",
"assertTrue",
"(",
"d2",
">",
"d1",
")",
"self",
... | [
118,
4
] | [
127,
28
] | python | en | ['en', 'bg', 'en'] | False |
DistanceTest.testUnitsStr | (self) | Testing conversion to strings | Testing conversion to strings | def testUnitsStr(self):
"Testing conversion to strings"
d1 = D(m=100)
d2 = D(km=3.5)
self.assertEqual(str(d1), '100.0 m')
self.assertEqual(str(d2), '3.5 km')
self.assertEqual(repr(d1), 'Distance(m=100.0)')
self.assertEqual(repr(d2), 'Distance(km=3.5)') | [
"def",
"testUnitsStr",
"(",
"self",
")",
":",
"d1",
"=",
"D",
"(",
"m",
"=",
"100",
")",
"d2",
"=",
"D",
"(",
"km",
"=",
"3.5",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"d1",
")",
",",
"'100.0 m'",
")",
"self",
".",
"assertEqual",
"(",... | [
129,
4
] | [
137,
54
] | python | en | ['en', 'en', 'en'] | True |
DistanceTest.testUnitAttName | (self) | Testing the `unit_attname` class method | Testing the `unit_attname` class method | def testUnitAttName(self):
"Testing the `unit_attname` class method"
unit_tuple = [('Yard', 'yd'), ('Nautical Mile', 'nm'), ('German legal metre', 'german_m'),
('Indian yard', 'indian_yd'), ('Chain (Sears)', 'chain_sears'), ('Chain', 'chain')]
for nm, att in unit_tuple:
... | [
"def",
"testUnitAttName",
"(",
"self",
")",
":",
"unit_tuple",
"=",
"[",
"(",
"'Yard'",
",",
"'yd'",
")",
",",
"(",
"'Nautical Mile'",
",",
"'nm'",
")",
",",
"(",
"'German legal metre'",
",",
"'german_m'",
")",
",",
"(",
"'Indian yard'",
",",
"'indian_yd'"... | [
139,
4
] | [
144,
53
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testInit | (self) | Testing initialization from valid units | Testing initialization from valid units | def testInit(self):
"Testing initialization from valid units"
a = Area(sq_m=100)
self.assertEqual(a.sq_m, 100)
a = A(sq_m=100)
self.assertEqual(a.sq_m, 100)
a = A(sq_mi=100)
self.assertEqual(a.sq_m, 258998811.0336) | [
"def",
"testInit",
"(",
"self",
")",
":",
"a",
"=",
"Area",
"(",
"sq_m",
"=",
"100",
")",
"self",
".",
"assertEqual",
"(",
"a",
".",
"sq_m",
",",
"100",
")",
"a",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"self",
".",
"assertEqual",
"(",
"a",
"... | [
150,
4
] | [
159,
48
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testInitInvaliA | (self) | Testing initialization from invalid units | Testing initialization from invalid units | def testInitInvaliA(self):
"Testing initialization from invalid units"
self.assertRaises(AttributeError, A, banana=100) | [
"def",
"testInitInvaliA",
"(",
"self",
")",
":",
"self",
".",
"assertRaises",
"(",
"AttributeError",
",",
"A",
",",
"banana",
"=",
"100",
")"
] | [
161,
4
] | [
163,
56
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testAccess | (self) | Testing access in different units | Testing access in different units | def testAccess(self):
"Testing access in different units"
a = A(sq_m=100)
self.assertEqual(a.sq_km, 0.0001)
self.assertAlmostEqual(a.sq_ft, 1076.391, 3) | [
"def",
"testAccess",
"(",
"self",
")",
":",
"a",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"self",
".",
"assertEqual",
"(",
"a",
".",
"sq_km",
",",
"0.0001",
")",
"self",
".",
"assertAlmostEqual",
"(",
"a",
".",
"sq_ft",
",",
"1076.391",
",",
"3",
... | [
165,
4
] | [
169,
52
] | python | en | ['de', 'en', 'en'] | True |
AreaTest.testAccessInvaliA | (self) | Testing access in invalid units | Testing access in invalid units | def testAccessInvaliA(self):
"Testing access in invalid units"
a = A(sq_m=100)
self.assertFalse(hasattr(a, 'banana')) | [
"def",
"testAccessInvaliA",
"(",
"self",
")",
":",
"a",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"self",
".",
"assertFalse",
"(",
"hasattr",
"(",
"a",
",",
"'banana'",
")",
")"
] | [
171,
4
] | [
174,
46
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testAddition | (self) | Test addition & subtraction | Test addition & subtraction | def testAddition(self):
"Test addition & subtraction"
a1 = A(sq_m=100)
a2 = A(sq_m=200)
a3 = a1 + a2
self.assertEqual(a3.sq_m, 300)
a3 += a1
self.assertEqual(a3.sq_m, 400)
a4 = a1 - a2
self.assertEqual(a4.sq_m, -100)
a4 -= a1
self... | [
"def",
"testAddition",
"(",
"self",
")",
":",
"a1",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"a2",
"=",
"A",
"(",
"sq_m",
"=",
"200",
")",
"a3",
"=",
"a1",
"+",
"a2",
"self",
".",
"assertEqual",
"(",
"a3",
".",
"sq_m",
",",
"300",
")",
"a3",
... | [
176,
4
] | [
201,
19
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testMultiplication | (self) | Test multiplication & division | Test multiplication & division | def testMultiplication(self):
"Test multiplication & division"
a1 = A(sq_m=100)
a3 = a1 * 2
self.assertEqual(a3.sq_m, 200)
a3 = 2 * a1
self.assertEqual(a3.sq_m, 200)
a3 *= 5
self.assertEqual(a3.sq_m, 1000)
a4 = a1 / 2
self.assertEqual(a4.... | [
"def",
"testMultiplication",
"(",
"self",
")",
":",
"a1",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"a3",
"=",
"a1",
"*",
"2",
"self",
".",
"assertEqual",
"(",
"a3",
".",
"sq_m",
",",
"200",
")",
"a3",
"=",
"2",
"*",
"a1",
"self",
".",
"assertEqu... | [
203,
4
] | [
229,
27
] | python | en | ['en', 'en', 'en'] | True |
AreaTest.testUnitConversions | (self) | Testing default units during maths | Testing default units during maths | def testUnitConversions(self):
"Testing default units during maths"
a1 = A(sq_m=100)
a2 = A(sq_km=1)
a3 = a1 + a2
self.assertEqual(a3._default_unit, 'sq_m')
a4 = a2 + a1
self.assertEqual(a4._default_unit, 'sq_km')
a5 = a1 * 2
self.assertEqual(a5._... | [
"def",
"testUnitConversions",
"(",
"self",
")",
":",
"a1",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"a2",
"=",
"A",
"(",
"sq_km",
"=",
"1",
")",
"a3",
"=",
"a1",
"+",
"a2",
"self",
".",
"assertEqual",
"(",
"a3",
".",
"_default_unit",
",",
"'sq_m'"... | [
231,
4
] | [
243,
50
] | python | en | ['de', 'en', 'en'] | True |
AreaTest.testComparisons | (self) | Testing comparisons | Testing comparisons | def testComparisons(self):
"Testing comparisons"
a1 = A(sq_m=100)
a2 = A(sq_km=1)
a3 = A(sq_km=0)
self.assertTrue(a2 > a1)
self.assertTrue(a1 == a1)
self.assertTrue(a1 < a2)
self.assertFalse(a3) | [
"def",
"testComparisons",
"(",
"self",
")",
":",
"a1",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"a2",
"=",
"A",
"(",
"sq_km",
"=",
"1",
")",
"a3",
"=",
"A",
"(",
"sq_km",
"=",
"0",
")",
"self",
".",
"assertTrue",
"(",
"a2",
">",
"a1",
")",
"... | [
245,
4
] | [
254,
28
] | python | en | ['en', 'bg', 'en'] | False |
AreaTest.testUnitsStr | (self) | Testing conversion to strings | Testing conversion to strings | def testUnitsStr(self):
"Testing conversion to strings"
a1 = A(sq_m=100)
a2 = A(sq_km=3.5)
self.assertEqual(str(a1), '100.0 sq_m')
self.assertEqual(str(a2), '3.5 sq_km')
self.assertEqual(repr(a1), 'Area(sq_m=100.0)')
self.assertEqual(repr(a2), 'Area(sq_km=3.5)') | [
"def",
"testUnitsStr",
"(",
"self",
")",
":",
"a1",
"=",
"A",
"(",
"sq_m",
"=",
"100",
")",
"a2",
"=",
"A",
"(",
"sq_km",
"=",
"3.5",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"a1",
")",
",",
"'100.0 sq_m'",
")",
"self",
".",
"assertEqual... | [
256,
4
] | [
264,
53
] | python | en | ['en', 'en', 'en'] | True |
do_uni_form | (parser, token) |
You need to pass in at least the form/formset object, and can also pass in the
optional `crispy_forms.helpers.FormHelper` object.
helper (optional): A `crispy_forms.helper.FormHelper` object.
Usage::
{% load crispy_tags %}
{% crispy form form.helper %}
You can also pr... |
You need to pass in at least the form/formset object, and can also pass in the
optional `crispy_forms.helpers.FormHelper` object.
helper (optional): A `crispy_forms.helper.FormHelper` object.
Usage::
{% load crispy_tags %}
{% crispy form form.helper %}
You can also pr... | def do_uni_form(parser, token):
"""
You need to pass in at least the form/formset object, and can also pass in the
optional `crispy_forms.helpers.FormHelper` object.
helper (optional): A `crispy_forms.helper.FormHelper` object.
Usage::
{% load crispy_tags %}
{% crispy fo... | [
"def",
"do_uni_form",
"(",
"parser",
",",
"token",
")",
":",
"token",
"=",
"token",
".",
"split_contents",
"(",
")",
"form",
"=",
"token",
".",
"pop",
"(",
"1",
")",
"helper",
"=",
"None",
"template_pack",
"=",
"\"'%s'\"",
"%",
"get_template_pack",
"(",
... | [
216,
0
] | [
270,
68
] | python | en | ['en', 'ja', 'th'] | False |
ForLoopSimulator.iterate | (self) |
Updates values as if we had iterated over the for
|
Updates values as if we had iterated over the for
| def iterate(self):
"""
Updates values as if we had iterated over the for
"""
self.counter += 1
self.counter0 += 1
self.revcounter -= 1
self.revcounter0 -= 1
self.first = False
self.last = self.revcounter0 == self.len_values - 1 | [
"def",
"iterate",
"(",
"self",
")",
":",
"self",
".",
"counter",
"+=",
"1",
"self",
".",
"counter0",
"+=",
"1",
"self",
".",
"revcounter",
"-=",
"1",
"self",
".",
"revcounter0",
"-=",
"1",
"self",
".",
"first",
"=",
"False",
"self",
".",
"last",
"=... | [
41,
4
] | [
50,
59
] | python | en | ['en', 'ja', 'th'] | False |
BasicNode.get_render | (self, context) |
Returns a `Context` object with all the necessary stuff for rendering the form
:param context: `django.template.Context` variable holding the context for the node
`self.form` and `self.helper` are resolved into real Python objects resolving them
from the `context`. The `actual_f... |
Returns a `Context` object with all the necessary stuff for rendering the form
:param context: `django.template.Context` variable holding the context for the node
`self.form` and `self.helper` are resolved into real Python objects resolving them
from the `context`. The `actual_f... | def get_render(self, context):
"""
Returns a `Context` object with all the necessary stuff for rendering the form
:param context: `django.template.Context` variable holding the context for the node
`self.form` and `self.helper` are resolved into real Python objects resolving them... | [
"def",
"get_render",
"(",
"self",
",",
"context",
")",
":",
"# Nodes are not thread safe in multithreaded environments\r",
"# https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#thread-safety-considerations\r",
"if",
"self",
"not",
"in",
"context",
".",
"render_context"... | [
70,
4
] | [
135,
28
] | python | en | ['en', 'ja', 'th'] | False |
BasicNode.get_response_dict | (self, helper, context, is_formset) |
Returns a dictionary with all the parameters necessary to render the form/formset in a template.
:param context: `django.template.Context` for the node
:param is_formset: Boolean value. If set to True, indicates we are working with a formset.
|
Returns a dictionary with all the parameters necessary to render the form/formset in a template.
:param context: `django.template.Context` for the node
:param is_formset: Boolean value. If set to True, indicates we are working with a formset.
| def get_response_dict(self, helper, context, is_formset):
"""
Returns a dictionary with all the parameters necessary to render the form/formset in a template.
:param context: `django.template.Context` for the node
:param is_formset: Boolean value. If set to True, indicates we are w... | [
"def",
"get_response_dict",
"(",
"self",
",",
"helper",
",",
"context",
",",
"is_formset",
")",
":",
"if",
"not",
"isinstance",
"(",
"helper",
",",
"FormHelper",
")",
":",
"raise",
"TypeError",
"(",
"\"helper object provided to {% crispy %} tag must be a crispy.helper... | [
137,
4
] | [
187,
28
] | python | en | ['en', 'ja', 'th'] | False |
BaseSpecifier.__str__ | (self) |
Returns the str representation of this Specifier like object. This
should be representative of the Specifier itself.
|
Returns the str representation of this Specifier like object. This
should be representative of the Specifier itself.
| def __str__(self):
# type: () -> str
"""
Returns the str representation of this Specifier like object. This
should be representative of the Specifier itself.
""" | [
"def",
"__str__",
"(",
"self",
")",
":",
"# type: () -> str"
] | [
40,
4
] | [
45,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.__hash__ | (self) |
Returns a hash value for this Specifier like object.
|
Returns a hash value for this Specifier like object.
| def __hash__(self):
# type: () -> int
"""
Returns a hash value for this Specifier like object.
""" | [
"def",
"__hash__",
"(",
"self",
")",
":",
"# type: () -> int"
] | [
48,
4
] | [
52,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.__eq__ | (self, other) |
Returns a boolean representing whether or not the two Specifier like
objects are equal.
|
Returns a boolean representing whether or not the two Specifier like
objects are equal.
| def __eq__(self, other):
# type: (object) -> bool
"""
Returns a boolean representing whether or not the two Specifier like
objects are equal.
""" | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"# type: (object) -> bool"
] | [
55,
4
] | [
60,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.__ne__ | (self, other) |
Returns a boolean representing whether or not the two Specifier like
objects are not equal.
|
Returns a boolean representing whether or not the two Specifier like
objects are not equal.
| def __ne__(self, other):
# type: (object) -> bool
"""
Returns a boolean representing whether or not the two Specifier like
objects are not equal.
""" | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"# type: (object) -> bool"
] | [
63,
4
] | [
68,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.prereleases | (self) |
Returns whether or not pre-releases as a whole are allowed by this
specifier.
|
Returns whether or not pre-releases as a whole are allowed by this
specifier.
| def prereleases(self):
# type: () -> Optional[bool]
"""
Returns whether or not pre-releases as a whole are allowed by this
specifier.
""" | [
"def",
"prereleases",
"(",
"self",
")",
":",
"# type: () -> Optional[bool]"
] | [
71,
4
] | [
76,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.prereleases | (self, value) |
Sets whether or not pre-releases as a whole are allowed by this
specifier.
|
Sets whether or not pre-releases as a whole are allowed by this
specifier.
| def prereleases(self, value):
# type: (bool) -> None
"""
Sets whether or not pre-releases as a whole are allowed by this
specifier.
""" | [
"def",
"prereleases",
"(",
"self",
",",
"value",
")",
":",
"# type: (bool) -> None"
] | [
79,
4
] | [
84,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.contains | (self, item, prereleases=None) |
Determines if the given item is contained within this specifier.
|
Determines if the given item is contained within this specifier.
| def contains(self, item, prereleases=None):
# type: (str, Optional[bool]) -> bool
"""
Determines if the given item is contained within this specifier.
""" | [
"def",
"contains",
"(",
"self",
",",
"item",
",",
"prereleases",
"=",
"None",
")",
":",
"# type: (str, Optional[bool]) -> bool"
] | [
87,
4
] | [
91,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseSpecifier.filter | (self, iterable, prereleases=None) |
Takes an iterable of items and filters them so that only items which
are contained within this specifier are allowed in it.
|
Takes an iterable of items and filters them so that only items which
are contained within this specifier are allowed in it.
| def filter(self, iterable, prereleases=None):
# type: (Iterable[UnparsedVersion], Optional[bool]) -> Iterable[UnparsedVersion]
"""
Takes an iterable of items and filters them so that only items which
are contained within this specifier are allowed in it.
""" | [
"def",
"filter",
"(",
"self",
",",
"iterable",
",",
"prereleases",
"=",
"None",
")",
":",
"# type: (Iterable[UnparsedVersion], Optional[bool]) -> Iterable[UnparsedVersion]"
] | [
94,
4
] | [
99,
11
] | python | en | ['en', 'error', 'th'] | False |
escape | (text) |
Return the given text with ampersands, quotes and angle brackets encoded
for use in HTML.
Always escape input, even if it's already escaped and marked as such.
This may result in double-escaping. If this is a concern, use
conditional_escape() instead.
|
Return the given text with ampersands, quotes and angle brackets encoded
for use in HTML. | def escape(text):
"""
Return the given text with ampersands, quotes and angle brackets encoded
for use in HTML.
Always escape input, even if it's already escaped and marked as such.
This may result in double-escaping. If this is a concern, use
conditional_escape() instead.
"""
return ma... | [
"def",
"escape",
"(",
"text",
")",
":",
"return",
"mark_safe",
"(",
"html",
".",
"escape",
"(",
"str",
"(",
"text",
")",
")",
")"
] | [
30,
0
] | [
39,
44
] | python | en | ['en', 'error', 'th'] | False |
escapejs | (value) | Hex encode characters for use in JavaScript strings. | Hex encode characters for use in JavaScript strings. | def escapejs(value):
"""Hex encode characters for use in JavaScript strings."""
return mark_safe(str(value).translate(_js_escapes)) | [
"def",
"escapejs",
"(",
"value",
")",
":",
"return",
"mark_safe",
"(",
"str",
"(",
"value",
")",
".",
"translate",
"(",
"_js_escapes",
")",
")"
] | [
62,
0
] | [
64,
55
] | python | en | ['en', 'en', 'en'] | True |
json_script | (value, element_id) |
Escape all the HTML/XML special characters with their unicode escapes, so
value is safe to be output anywhere except for inside a tag attribute. Wrap
the escaped JSON in a script tag.
|
Escape all the HTML/XML special characters with their unicode escapes, so
value is safe to be output anywhere except for inside a tag attribute. Wrap
the escaped JSON in a script tag.
| def json_script(value, element_id):
"""
Escape all the HTML/XML special characters with their unicode escapes, so
value is safe to be output anywhere except for inside a tag attribute. Wrap
the escaped JSON in a script tag.
"""
from django.core.serializers.json import DjangoJSONEncoder
json_... | [
"def",
"json_script",
"(",
"value",
",",
"element_id",
")",
":",
"from",
"django",
".",
"core",
".",
"serializers",
".",
"json",
"import",
"DjangoJSONEncoder",
"json_str",
"=",
"json",
".",
"dumps",
"(",
"value",
",",
"cls",
"=",
"DjangoJSONEncoder",
")",
... | [
74,
0
] | [
85,
5
] | python | en | ['en', 'error', 'th'] | False |
conditional_escape | (text) |
Similar to escape(), except that it doesn't operate on pre-escaped strings.
This function relies on the __html__ convention used both by Django's
SafeData class and by third-party libraries like markupsafe.
|
Similar to escape(), except that it doesn't operate on pre-escaped strings. | def conditional_escape(text):
"""
Similar to escape(), except that it doesn't operate on pre-escaped strings.
This function relies on the __html__ convention used both by Django's
SafeData class and by third-party libraries like markupsafe.
"""
if isinstance(text, Promise):
text = str(t... | [
"def",
"conditional_escape",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"Promise",
")",
":",
"text",
"=",
"str",
"(",
"text",
")",
"if",
"hasattr",
"(",
"text",
",",
"'__html__'",
")",
":",
"return",
"text",
".",
"__html__",
"(",
")... | [
88,
0
] | [
100,
27
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.