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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Polygon.__iter__ | (self) | Iterates over each ring in the polygon. | Iterates over each ring in the polygon. | def __iter__(self):
"Iterates over each ring in the polygon."
for i in xrange(len(self)):
yield self[i] | [
"def",
"__iter__",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"self",
")",
")",
":",
"yield",
"self",
"[",
"i",
"]"
] | [
49,
4
] | [
52,
25
] | python | en | ['en', 'en', 'en'] | True |
Polygon.__len__ | (self) | Returns the number of rings in this Polygon. | Returns the number of rings in this Polygon. | def __len__(self):
"Returns the number of rings in this Polygon."
return self.num_interior_rings + 1 | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_interior_rings",
"+",
"1"
] | [
54,
4
] | [
56,
42
] | python | en | ['en', 'en', 'en'] | True |
Polygon.from_bbox | (cls, bbox) | Constructs a Polygon from a bounding box (4-tuple). | Constructs a Polygon from a bounding box (4-tuple). | def from_bbox(cls, bbox):
"Constructs a Polygon from a bounding box (4-tuple)."
x0, y0, x1, y1 = bbox
for z in bbox:
if not isinstance(z, six.integer_types + (float,)):
return GEOSGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' %
... | [
"def",
"from_bbox",
"(",
"cls",
",",
"bbox",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"bbox",
"for",
"z",
"in",
"bbox",
":",
"if",
"not",
"isinstance",
"(",
"z",
",",
"six",
".",
"integer_types",
"+",
"(",
"float",
",",
")",
")",
... | [
59,
4
] | [
66,
74
] | python | en | ['en', 'en', 'en'] | True |
Polygon._construct_ring | (self, param, msg=(
'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings')) | Helper routine for trying to construct a ring from the given parameter. | Helper routine for trying to construct a ring from the given parameter. | def _construct_ring(self, param, msg=(
'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings')):
"Helper routine for trying to construct a ring from the given parameter."
if isinstance(param, LinearRing):
return param
try:
... | [
"def",
"_construct_ring",
"(",
"self",
",",
"param",
",",
"msg",
"=",
"(",
"'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings'",
")",
")",
":",
"if",
"isinstance",
"(",
"param",
",",
"LinearRing",
")",
":",
"return",
"param",
"... | [
100,
4
] | [
109,
32
] | python | en | ['en', 'en', 'en'] | True |
Polygon._get_single_internal | (self, index) |
Returns the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring, respectively).
CAREFUL: Internal/Externa... |
Returns the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring, respectively). | def _get_single_internal(self, index):
"""
Returns the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring,... | [
"def",
"_get_single_internal",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"capi",
".",
"get_extring",
"(",
"self",
".",
"ptr",
")",
"else",
":",
"# Getting the interior ring, have to subtract 1 from the index.",
"return",
"capi",... | [
121,
4
] | [
137,
56
] | python | en | ['en', 'error', 'th'] | False |
Polygon.num_interior_rings | (self) | Returns the number of interior rings. | Returns the number of interior rings. | def num_interior_rings(self):
"Returns the number of interior rings."
# Getting the number of rings
return capi.get_nrings(self.ptr) | [
"def",
"num_interior_rings",
"(",
"self",
")",
":",
"# Getting the number of rings",
"return",
"capi",
".",
"get_nrings",
"(",
"self",
".",
"ptr",
")"
] | [
147,
4
] | [
150,
40
] | python | en | ['en', 'en', 'en'] | True |
Polygon._get_ext_ring | (self) | Gets the exterior ring of the Polygon. | Gets the exterior ring of the Polygon. | def _get_ext_ring(self):
"Gets the exterior ring of the Polygon."
return self[0] | [
"def",
"_get_ext_ring",
"(",
"self",
")",
":",
"return",
"self",
"[",
"0",
"]"
] | [
152,
4
] | [
154,
22
] | python | en | ['en', 'en', 'en'] | True |
Polygon._set_ext_ring | (self, ring) | Sets the exterior ring of the Polygon. | Sets the exterior ring of the Polygon. | def _set_ext_ring(self, ring):
"Sets the exterior ring of the Polygon."
self[0] = ring | [
"def",
"_set_ext_ring",
"(",
"self",
",",
"ring",
")",
":",
"self",
"[",
"0",
"]",
"=",
"ring"
] | [
156,
4
] | [
158,
22
] | python | en | ['en', 'en', 'en'] | True |
Polygon.tuple | (self) | Gets the tuple for each ring in this Polygon. | Gets the tuple for each ring in this Polygon. | def tuple(self):
"Gets the tuple for each ring in this Polygon."
return tuple(self[i].tuple for i in xrange(len(self))) | [
"def",
"tuple",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"self",
"[",
"i",
"]",
".",
"tuple",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"self",
")",
")",
")"
] | [
165,
4
] | [
167,
62
] | python | en | ['en', 'en', 'en'] | True |
Polygon.kml | (self) | Returns the KML representation of this Polygon. | Returns the KML representation of this Polygon. | def kml(self):
"Returns the KML representation of this Polygon."
inner_kml = ''.join("<innerBoundaryIs>%s</innerBoundaryIs>" % self[i + 1].kml
for i in xrange(self.num_interior_rings))
return "<Polygon><outerBoundaryIs>%s</outerBoundaryIs>%s</Polygon>" % (self[0].kml, inner_kml) | [
"def",
"kml",
"(",
"self",
")",
":",
"inner_kml",
"=",
"''",
".",
"join",
"(",
"\"<innerBoundaryIs>%s</innerBoundaryIs>\"",
"%",
"self",
"[",
"i",
"+",
"1",
"]",
".",
"kml",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"num_interior_rings",
")",
")",
... | [
171,
4
] | [
175,
102
] | python | en | ['en', 'en', 'en'] | True |
module_to_dict | (module, omittable=lambda k: k.startswith('_')) | Converts a module namespace to a Python dictionary. | Converts a module namespace to a Python dictionary. | def module_to_dict(module, omittable=lambda k: k.startswith('_')):
"""Converts a module namespace to a Python dictionary."""
return dict((k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)) | [
"def",
"module_to_dict",
"(",
"module",
",",
"omittable",
"=",
"lambda",
"k",
":",
"k",
".",
"startswith",
"(",
"'_'",
")",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"repr",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"module",
".",
"... | [
3,
0
] | [
5,
85
] | python | en | ['en', 'en', 'en'] | True |
get_exception_info | (exception) |
Format exception information for display on the debug page using the
structure described in the template API documentation.
|
Format exception information for display on the debug page using the
structure described in the template API documentation.
| def get_exception_info(exception):
"""
Format exception information for display on the debug page using the
structure described in the template API documentation.
"""
context_lines = 10
lineno = exception.lineno
lines = list(enumerate(exception.source.strip().split("\n"), start=1))
durin... | [
"def",
"get_exception_info",
"(",
"exception",
")",
":",
"context_lines",
"=",
"10",
"lineno",
"=",
"exception",
".",
"lineno",
"lines",
"=",
"list",
"(",
"enumerate",
"(",
"exception",
".",
"source",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
... | [
83,
0
] | [
107,
5
] | python | en | ['en', 'error', 'th'] | False |
test_unfinished_attack_configs | () |
Test that tracking of which attack configs are unfinished is correct
|
Test that tracking of which attack configs are unfinished is correct
| def test_unfinished_attack_configs():
"""
Test that tracking of which attack configs are unfinished is correct
"""
new_work_goal = {}
work_before = {}
run_counts = {}
expected_unfinished = []
expected_finished = []
easy_finished = AttackConfig(None, None)
new_work_goal[easy_fi... | [
"def",
"test_unfinished_attack_configs",
"(",
")",
":",
"new_work_goal",
"=",
"{",
"}",
"work_before",
"=",
"{",
"}",
"run_counts",
"=",
"{",
"}",
"expected_unfinished",
"=",
"[",
"]",
"expected_finished",
"=",
"[",
"]",
"easy_finished",
"=",
"AttackConfig",
"... | [
9,
0
] | [
50,
69
] | python | en | ['en', 'error', 'th'] | False |
test_misclassify_request_examples | () |
Test Misclassify.request_examples
|
Test Misclassify.request_examples
| def test_misclassify_request_examples():
"""
Test Misclassify.request_examples
"""
cfg = AttackConfig(None, None)
goal = Misclassify(new_work_goal={cfg: 1})
correctness = np.array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1], dtype=np.bool)
run_counts = np.array([1, 1, 1, 0, 0, 0, 1, 1, 1, 0], dtype=np.in... | [
"def",
"test_misclassify_request_examples",
"(",
")",
":",
"cfg",
"=",
"AttackConfig",
"(",
"None",
",",
"None",
")",
"goal",
"=",
"Misclassify",
"(",
"new_work_goal",
"=",
"{",
"cfg",
":",
"1",
"}",
")",
"correctness",
"=",
"np",
".",
"array",
"(",
"[",... | [
53,
0
] | [
71,
29
] | python | en | ['en', 'error', 'th'] | False |
get_topic_from_message_info | (message_info: Dict[str, Any]) |
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots.
We prefer 'topic' to 'subject' here. We expect at least one field
to be present (or the caller must know how to handle KeyError).
|
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots. | def get_topic_from_message_info(message_info: Dict[str, Any]) -> str:
"""
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots.
We prefer 'topic' to 'subject' here. We expect at least one field
to be... | [
"def",
"get_topic_from_message_info",
"(",
"message_info",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"if",
"\"topic\"",
"in",
"message_info",
":",
"return",
"message_info",
"[",
"\"topic\"",
"]",
"return",
"message_info",
"[",
"\"subject... | [
34,
0
] | [
46,
34
] | python | en | ['en', 'error', 'th'] | False |
ReindentFilter._flatten_up_to_token | (self, token) | Yields all tokens up to token but excluding current. | Yields all tokens up to token but excluding current. | def _flatten_up_to_token(self, token):
"""Yields all tokens up to token but excluding current."""
if token.is_group:
token = next(token.flatten())
for t in self._curr_stmt.flatten():
if t == token:
break
yield t | [
"def",
"_flatten_up_to_token",
"(",
"self",
",",
"token",
")",
":",
"if",
"token",
".",
"is_group",
":",
"token",
"=",
"next",
"(",
"token",
".",
"flatten",
"(",
")",
")",
"for",
"t",
"in",
"self",
".",
"_curr_stmt",
".",
"flatten",
"(",
")",
":",
... | [
29,
4
] | [
37,
19
] | python | en | ['en', 'en', 'en'] | True |
FencedCodeExtension.extendMarkdown | (self, md: Markdown) | Add FencedBlockPreprocessor to the Markdown instance. | Add FencedBlockPreprocessor to the Markdown instance. | def extendMarkdown(self, md: Markdown) -> None:
""" Add FencedBlockPreprocessor to the Markdown instance. """
md.registerExtension(self)
processor = FencedBlockPreprocessor(
md, run_content_validators=self.config["run_content_validators"][0]
)
md.preprocessors.registe... | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
":",
"Markdown",
")",
"->",
"None",
":",
"md",
".",
"registerExtension",
"(",
"self",
")",
"processor",
"=",
"FencedBlockPreprocessor",
"(",
"md",
",",
"run_content_validators",
"=",
"self",
".",
"config",
"["... | [
158,
4
] | [
164,
69
] | python | en | ['en', 'it', 'en'] | True |
FencedBlockPreprocessor.run | (self, lines: Iterable[str]) | Match and store Fenced Code Blocks in the HtmlStash. | Match and store Fenced Code Blocks in the HtmlStash. | def run(self, lines: Iterable[str]) -> List[str]:
""" Match and store Fenced Code Blocks in the HtmlStash. """
output: List[str] = []
processor = self
self.handlers: List[BaseHandler] = []
default_language = None
try:
default_language = self.md.zulip_realm.... | [
"def",
"run",
"(",
"self",
",",
"lines",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"output",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"processor",
"=",
"self",
"self",
".",
"handlers",
":",
"List",
"[",
"Bas... | [
380,
4
] | [
407,
21
] | python | en | ['en', 'en', 'en'] | True |
FencedBlockPreprocessor._escape | (self, txt: str) | basic html escaping | basic html escaping | def _escape(self, txt: str) -> str:
""" basic html escaping """
txt = txt.replace("&", "&")
txt = txt.replace("<", "<")
txt = txt.replace(">", ">")
txt = txt.replace('"', """)
return txt | [
"def",
"_escape",
"(",
"self",
",",
"txt",
":",
"str",
")",
"->",
"str",
":",
"txt",
"=",
"txt",
".",
"replace",
"(",
"\"&\"",
",",
"\"&\"",
")",
"txt",
"=",
"txt",
".",
"replace",
"(",
"\"<\"",
",",
"\"<\"",
")",
"txt",
"=",
"txt",
".",
... | [
503,
4
] | [
509,
18
] | python | en | ['es', 'en', 'en'] | True |
mark_safe | (s) |
Explicitly mark a string as safe for (HTML) output purposes. The returned
object can be used everywhere a string or unicode object is appropriate.
Can be called multiple times on a single string.
|
Explicitly mark a string as safe for (HTML) output purposes. The returned
object can be used everywhere a string or unicode object is appropriate. | def mark_safe(s):
"""
Explicitly mark a string as safe for (HTML) output purposes. The returned
object can be used everywhere a string or unicode object is appropriate.
Can be called multiple times on a single string.
"""
if isinstance(s, SafeData):
return s
if isinstance(s, bytes) ... | [
"def",
"mark_safe",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"SafeData",
")",
":",
"return",
"s",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
"or",
"(",
"isinstance",
"(",
"s",
",",
"Promise",
")",
"and",
"s",
".",
"_delegate_byt... | [
116,
0
] | [
129,
29
] | python | en | ['en', 'error', 'th'] | False |
mark_for_escaping | (s) |
Explicitly mark a string as requiring HTML escaping upon output. Has no
effect on SafeData subclasses.
Can be called multiple times on a single string (the resulting escaping is
only applied once).
|
Explicitly mark a string as requiring HTML escaping upon output. Has no
effect on SafeData subclasses. | def mark_for_escaping(s):
"""
Explicitly mark a string as requiring HTML escaping upon output. Has no
effect on SafeData subclasses.
Can be called multiple times on a single string (the resulting escaping is
only applied once).
"""
if isinstance(s, (SafeData, EscapeData)):
return s
... | [
"def",
"mark_for_escaping",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"(",
"SafeData",
",",
"EscapeData",
")",
")",
":",
"return",
"s",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
"or",
"(",
"isinstance",
"(",
"s",
",",
"Promise",
... | [
132,
0
] | [
146,
32
] | python | en | ['en', 'error', 'th'] | False |
SafeData.__html__ | (self) |
Returns the html representation of a string.
Allows interoperability with other template engines.
|
Returns the html representation of a string. | def __html__(self):
"""
Returns the html representation of a string.
Allows interoperability with other template engines.
"""
return self | [
"def",
"__html__",
"(",
"self",
")",
":",
"return",
"self"
] | [
36,
4
] | [
42,
19
] | python | en | ['en', 'error', 'th'] | False |
SafeBytes.__add__ | (self, rhs) |
Concatenating a safe byte string with another safe byte string or safe
unicode string is safe. Otherwise, the result is no longer safe.
|
Concatenating a safe byte string with another safe byte string or safe
unicode string is safe. Otherwise, the result is no longer safe.
| def __add__(self, rhs):
"""
Concatenating a safe byte string with another safe byte string or safe
unicode string is safe. Otherwise, the result is no longer safe.
"""
t = super(SafeBytes, self).__add__(rhs)
if isinstance(rhs, SafeText):
return SafeText(t)
... | [
"def",
"__add__",
"(",
"self",
",",
"rhs",
")",
":",
"t",
"=",
"super",
"(",
"SafeBytes",
",",
"self",
")",
".",
"__add__",
"(",
"rhs",
")",
"if",
"isinstance",
"(",
"rhs",
",",
"SafeText",
")",
":",
"return",
"SafeText",
"(",
"t",
")",
"elif",
"... | [
50,
4
] | [
60,
16
] | python | en | ['en', 'error', 'th'] | False |
SafeBytes._proxy_method | (self, *args, **kwargs) |
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
|
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
| def _proxy_method(self, *args, **kwargs):
"""
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
"""
method = kwargs.pop('method')
data = method(self, *args, **kwargs)
... | [
"def",
"_proxy_method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method",
"=",
"kwargs",
".",
"pop",
"(",
"'method'",
")",
"data",
"=",
"method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinst... | [
62,
4
] | [
73,
33
] | python | en | ['en', 'error', 'th'] | False |
SafeText.__add__ | (self, rhs) |
Concatenating a safe unicode string with another safe byte string or
safe unicode string is safe. Otherwise, the result is no longer safe.
|
Concatenating a safe unicode string with another safe byte string or
safe unicode string is safe. Otherwise, the result is no longer safe.
| def __add__(self, rhs):
"""
Concatenating a safe unicode string with another safe byte string or
safe unicode string is safe. Otherwise, the result is no longer safe.
"""
t = super(SafeText, self).__add__(rhs)
if isinstance(rhs, SafeData):
return SafeText(t)
... | [
"def",
"__add__",
"(",
"self",
",",
"rhs",
")",
":",
"t",
"=",
"super",
"(",
"SafeText",
",",
"self",
")",
".",
"__add__",
"(",
"rhs",
")",
"if",
"isinstance",
"(",
"rhs",
",",
"SafeData",
")",
":",
"return",
"SafeText",
"(",
"t",
")",
"return",
... | [
83,
4
] | [
91,
16
] | python | en | ['en', 'error', 'th'] | False |
SafeText._proxy_method | (self, *args, **kwargs) |
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
|
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
| def _proxy_method(self, *args, **kwargs):
"""
Wrap a call to a normal unicode method up so that we return safe
results. The method that is being wrapped is passed in the 'method'
argument.
"""
method = kwargs.pop('method')
data = method(self, *args, **kwargs)
... | [
"def",
"_proxy_method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method",
"=",
"kwargs",
".",
"pop",
"(",
"'method'",
")",
"data",
"=",
"method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinst... | [
93,
4
] | [
104,
33
] | python | en | ['en', 'error', 'th'] | False |
OperationTestBase.make_test_state | (self, app_label, operation, **kwargs) |
Makes a test state using set_up_test_model and returns the
original state and the state after the migration is applied.
|
Makes a test state using set_up_test_model and returns the
original state and the state after the migration is applied.
| def make_test_state(self, app_label, operation, **kwargs):
"""
Makes a test state using set_up_test_model and returns the
original state and the state after the migration is applied.
"""
project_state = self.set_up_test_model(app_label, **kwargs)
new_state = project_state... | [
"def",
"make_test_state",
"(",
"self",
",",
"app_label",
",",
"operation",
",",
"*",
"*",
"kwargs",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"app_label",
",",
"*",
"*",
"kwargs",
")",
"new_state",
"=",
"project_state",
".",
"c... | [
38,
4
] | [
46,
39
] | python | en | ['en', 'error', 'th'] | False |
OperationTestBase.set_up_test_model | (self, app_label, second_model=False, third_model=False, related_model=False, mti_model=False, proxy_model=False, unique_together=False, options=False) |
Creates a test model state and database table.
|
Creates a test model state and database table.
| def set_up_test_model(self, app_label, second_model=False, third_model=False, related_model=False, mti_model=False, proxy_model=False, unique_together=False, options=False):
"""
Creates a test model state and database table.
"""
# Delete the tables if they already exist
with conn... | [
"def",
"set_up_test_model",
"(",
"self",
",",
"app_label",
",",
"second_model",
"=",
"False",
",",
"third_model",
"=",
"False",
",",
"related_model",
"=",
"False",
",",
"mti_model",
"=",
"False",
",",
"proxy_model",
"=",
"False",
",",
"unique_together",
"=",
... | [
48,
4
] | [
139,
75
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_model | (self) |
Tests the CreateModel operation.
Most other tests use this operation as part of setup, so check failures here first.
|
Tests the CreateModel operation.
Most other tests use this operation as part of setup, so check failures here first.
| def test_create_model(self):
"""
Tests the CreateModel operation.
Most other tests use this operation as part of setup, so check failures here first.
"""
operation = migrations.CreateModel(
"Pony",
[
("id", models.AutoField(primary_key=True... | [
"def",
"test_create_model",
"(",
"self",
")",
":",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"Pony\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"pink\"",
",",
"model... | [
149,
4
] | [
182,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_model_with_unique_after | (self) |
Tests the CreateModel operation directly followed by an
AlterUniqueTogether (bug #22844 - sqlite remake issues)
|
Tests the CreateModel operation directly followed by an
AlterUniqueTogether (bug #22844 - sqlite remake issues)
| def test_create_model_with_unique_after(self):
"""
Tests the CreateModel operation directly followed by an
AlterUniqueTogether (bug #22844 - sqlite remake issues)
"""
operation1 = migrations.CreateModel(
"Pony",
[
("id", models.AutoField(pr... | [
"def",
"test_create_model_with_unique_after",
"(",
"self",
")",
":",
"operation1",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"Pony\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"pink\... | [
184,
4
] | [
225,
51
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_model_m2m | (self) |
Test the creation of a model with a ManyToMany field and the
auto-created "through" model.
|
Test the creation of a model with a ManyToMany field and the
auto-created "through" model.
| def test_create_model_m2m(self):
"""
Test the creation of a model with a ManyToMany field and the
auto-created "through" model.
"""
project_state = self.set_up_test_model("test_crmomm")
operation = migrations.CreateModel(
"Stable",
[
... | [
"def",
"test_create_model_m2m",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_crmomm\"",
")",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"Stable\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"Aut... | [
227,
4
] | [
265,
62
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_model_inheritance | (self) |
Tests the CreateModel operation on a multi-table inheritance setup.
|
Tests the CreateModel operation on a multi-table inheritance setup.
| def test_create_model_inheritance(self):
"""
Tests the CreateModel operation on a multi-table inheritance setup.
"""
project_state = self.set_up_test_model("test_crmoih")
# Test the state alteration
operation = migrations.CreateModel(
"ShetlandPony",
... | [
"def",
"test_create_model_inheritance",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_crmoih\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"ShetlandPony\"",
",",
"[",
"(... | [
267,
4
] | [
297,
61
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_proxy_model | (self) |
Tests that CreateModel ignores proxy models.
|
Tests that CreateModel ignores proxy models.
| def test_create_proxy_model(self):
"""
Tests that CreateModel ignores proxy models.
"""
project_state = self.set_up_test_model("test_crprmo")
# Test the state alteration
operation = migrations.CreateModel(
"ProxyPony",
[],
options={"pro... | [
"def",
"test_create_proxy_model",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_crprmo\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"ProxyPony\"",
",",
"[",
"]",
",",... | [
299,
4
] | [
326,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_create_unmanaged_model | (self) |
Tests that CreateModel ignores unmanaged models.
|
Tests that CreateModel ignores unmanaged models.
| def test_create_unmanaged_model(self):
"""
Tests that CreateModel ignores unmanaged models.
"""
project_state = self.set_up_test_model("test_crummo")
# Test the state alteration
operation = migrations.CreateModel(
"UnmanagedPony",
[],
o... | [
"def",
"test_create_unmanaged_model",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_crummo\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"UnmanagedPony\"",
",",
"[",
"]"... | [
328,
4
] | [
355,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_delete_model | (self) |
Tests the DeleteModel operation.
|
Tests the DeleteModel operation.
| def test_delete_model(self):
"""
Tests the DeleteModel operation.
"""
project_state = self.set_up_test_model("test_dlmo")
# Test the state alteration
operation = migrations.DeleteModel("Pony")
self.assertEqual(operation.describe(), "Delete model Pony")
new... | [
"def",
"test_delete_model",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_dlmo\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"DeleteModel",
"(",
"\"Pony\"",
")",
"self",
".",
"assertEqual",... | [
357,
4
] | [
376,
48
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_delete_proxy_model | (self) |
Tests the DeleteModel operation ignores proxy models.
|
Tests the DeleteModel operation ignores proxy models.
| def test_delete_proxy_model(self):
"""
Tests the DeleteModel operation ignores proxy models.
"""
project_state = self.set_up_test_model("test_dlprmo", proxy_model=True)
# Test the state alteration
operation = migrations.DeleteModel("ProxyPony")
new_state = project... | [
"def",
"test_delete_proxy_model",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_dlprmo\"",
",",
"proxy_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"DeleteModel",
"(",
"\"... | [
378,
4
] | [
400,
58
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_rename_model | (self) |
Tests the RenameModel operation.
|
Tests the RenameModel operation.
| def test_rename_model(self):
"""
Tests the RenameModel operation.
"""
project_state = self.set_up_test_model("test_rnmo", related_model=True)
# Test the state alteration
operation = migrations.RenameModel("Pony", "Horse")
self.assertEqual(operation.describe(), "Re... | [
"def",
"test_rename_model",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_rnmo\"",
",",
"related_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"RenameModel",
"(",
"\"Pony\"... | [
402,
4
] | [
436,
93
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_rename_model_with_self_referential_fk | (self) |
Tests the RenameModel operation on model with self referential FK.
|
Tests the RenameModel operation on model with self referential FK.
| def test_rename_model_with_self_referential_fk(self):
"""
Tests the RenameModel operation on model with self referential FK.
"""
project_state = self.set_up_test_model("test_rmwsrf", related_model=True)
# Test the state alteration
operation = migrations.RenameModel("Rider... | [
"def",
"test_rename_model_with_self_referential_fk",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_rmwsrf\"",
",",
"related_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"Renam... | [
438,
4
] | [
472,
104
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_field | (self) |
Tests the AddField operation.
|
Tests the AddField operation.
| def test_add_field(self):
"""
Tests the AddField operation.
"""
# Test the state alteration
operation = migrations.AddField(
"Pony",
"height",
models.FloatField(null=True, default=5),
)
self.assertEqual(operation.describe(), "Ad... | [
"def",
"test_add_field",
"(",
"self",
")",
":",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AddField",
"(",
"\"Pony\"",
",",
"\"height\"",
",",
"models",
".",
"FloatField",
"(",
"null",
"=",
"True",
",",
"default",
"=",
"5",
")",
","... | [
490,
4
] | [
516,
62
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_charfield | (self) |
Tests the AddField operation on TextField.
|
Tests the AddField operation on TextField.
| def test_add_charfield(self):
"""
Tests the AddField operation on TextField.
"""
project_state = self.set_up_test_model("test_adchfl")
new_apps = project_state.render()
Pony = new_apps.get_model("test_adchfl", "Pony")
pony = Pony.objects.create(weight=42)
... | [
"def",
"test_add_charfield",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_adchfl\"",
")",
"new_apps",
"=",
"project_state",
".",
"render",
"(",
")",
"Pony",
"=",
"new_apps",
".",
"get_model",
"(",
"\"test_adchfl\"",... | [
518,
4
] | [
559,
45
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_textfield | (self) |
Tests the AddField operation on TextField.
|
Tests the AddField operation on TextField.
| def test_add_textfield(self):
"""
Tests the AddField operation on TextField.
"""
project_state = self.set_up_test_model("test_adtxtfl")
new_apps = project_state.render()
Pony = new_apps.get_model("test_adtxtfl", "Pony")
pony = Pony.objects.create(weight=42)
... | [
"def",
"test_add_textfield",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_adtxtfl\"",
")",
"new_apps",
"=",
"project_state",
".",
"render",
"(",
")",
"Pony",
"=",
"new_apps",
".",
"get_model",
"(",
"\"test_adtxtfl\"... | [
561,
4
] | [
602,
45
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_binaryfield | (self) |
Tests the AddField operation on TextField/BinaryField.
|
Tests the AddField operation on TextField/BinaryField.
| def test_add_binaryfield(self):
"""
Tests the AddField operation on TextField/BinaryField.
"""
project_state = self.set_up_test_model("test_adbinfl")
new_apps = project_state.render()
Pony = new_apps.get_model("test_adbinfl", "Pony")
pony = Pony.objects.create(we... | [
"def",
"test_add_binaryfield",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_adbinfl\"",
")",
"new_apps",
"=",
"project_state",
".",
"render",
"(",
")",
"Pony",
"=",
"new_apps",
".",
"get_model",
"(",
"\"test_adbinfl... | [
605,
4
] | [
647,
53
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_column_name_quoting | (self) |
Column names that are SQL keywords shouldn't cause problems when used
in migrations (#22168).
|
Column names that are SQL keywords shouldn't cause problems when used
in migrations (#22168).
| def test_column_name_quoting(self):
"""
Column names that are SQL keywords shouldn't cause problems when used
in migrations (#22168).
"""
project_state = self.set_up_test_model("test_regr22168")
operation = migrations.AddField(
"Pony",
"order",
... | [
"def",
"test_column_name_quoting",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_regr22168\"",
")",
"operation",
"=",
"migrations",
".",
"AddField",
"(",
"\"Pony\"",
",",
"\"order\"",
",",
"models",
".",
"IntegerField"... | [
649,
4
] | [
664,
63
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_field_preserve_default | (self) |
Tests the AddField operation's state alteration
when preserve_default = False.
|
Tests the AddField operation's state alteration
when preserve_default = False.
| def test_add_field_preserve_default(self):
"""
Tests the AddField operation's state alteration
when preserve_default = False.
"""
project_state = self.set_up_test_model("test_adflpd")
# Test the state alteration
operation = migrations.AddField(
"Pony",... | [
"def",
"test_add_field_preserve_default",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_adflpd\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AddField",
"(",
"\"Pony\"",
",",
"\"height\"",
",... | [
666,
4
] | [
694,
61
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_add_field_m2m | (self) |
Tests the AddField operation with a ManyToManyField.
|
Tests the AddField operation with a ManyToManyField.
| def test_add_field_m2m(self):
"""
Tests the AddField operation with a ManyToManyField.
"""
project_state = self.set_up_test_model("test_adflmm", second_model=True)
# Test the state alteration
operation = migrations.AddField("Pony", "stables", models.ManyToManyField("Stabl... | [
"def",
"test_add_field_m2m",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_adflmm\"",
",",
"second_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AddField",
"(",
"\"Pony\""... | [
696,
4
] | [
723,
61
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_remove_field | (self) |
Tests the RemoveField operation.
|
Tests the RemoveField operation.
| def test_remove_field(self):
"""
Tests the RemoveField operation.
"""
project_state = self.set_up_test_model("test_rmfl")
# Test the state alteration
operation = migrations.RemoveField("Pony", "pink")
self.assertEqual(operation.describe(), "Remove field pink from ... | [
"def",
"test_remove_field",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_rmfl\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"RemoveField",
"(",
"\"Pony\"",
",",
"\"pink\"",
")",
"self",
... | [
795,
4
] | [
814,
57
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_remove_fk | (self) |
Tests the RemoveField operation on a foreign key.
|
Tests the RemoveField operation on a foreign key.
| def test_remove_fk(self):
"""
Tests the RemoveField operation on a foreign key.
"""
project_state = self.set_up_test_model("test_rfk", related_model=True)
self.assertColumnExists("test_rfk_rider", "pony_id")
operation = migrations.RemoveField("Rider", "pony")
new... | [
"def",
"test_remove_fk",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_rfk\"",
",",
"related_model",
"=",
"True",
")",
"self",
".",
"assertColumnExists",
"(",
"\"test_rfk_rider\"",
",",
"\"pony_id\"",
")",
"operation",... | [
816,
4
] | [
831,
60
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_model_table | (self) |
Tests the AlterModelTable operation.
|
Tests the AlterModelTable operation.
| def test_alter_model_table(self):
"""
Tests the AlterModelTable operation.
"""
project_state = self.set_up_test_model("test_almota")
# Test the state alteration
operation = migrations.AlterModelTable("Pony", "test_almota_pony_2")
self.assertEqual(operation.describ... | [
"def",
"test_alter_model_table",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_almota\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterModelTable",
"(",
"\"Pony\"",
",",
"\"test_almota_pony_... | [
833,
4
] | [
855,
55
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_model_table_noop | (self) |
Tests the AlterModelTable operation if the table name is not changed.
|
Tests the AlterModelTable operation if the table name is not changed.
| def test_alter_model_table_noop(self):
"""
Tests the AlterModelTable operation if the table name is not changed.
"""
project_state = self.set_up_test_model("test_almota")
# Test the state alteration
operation = migrations.AlterModelTable("Pony", "test_almota_pony")
... | [
"def",
"test_alter_model_table_noop",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_almota\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterModelTable",
"(",
"\"Pony\"",
",",
"\"test_almota_... | [
857,
4
] | [
875,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_field | (self) |
Tests the AlterField operation.
|
Tests the AlterField operation.
| def test_alter_field(self):
"""
Tests the AlterField operation.
"""
project_state = self.set_up_test_model("test_alfl")
# Test the state alteration
operation = migrations.AlterField("Pony", "pink", models.IntegerField(null=True))
self.assertEqual(operation.describ... | [
"def",
"test_alter_field",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alfl\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterField",
"(",
"\"Pony\"",
",",
"\"pink\"",
",",
"models",
... | [
877,
4
] | [
897,
58
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_field_pk | (self) |
Tests the AlterField operation on primary keys (for things like PostgreSQL's SERIAL weirdness)
|
Tests the AlterField operation on primary keys (for things like PostgreSQL's SERIAL weirdness)
| def test_alter_field_pk(self):
"""
Tests the AlterField operation on primary keys (for things like PostgreSQL's SERIAL weirdness)
"""
project_state = self.set_up_test_model("test_alflpk")
# Test the state alteration
operation = migrations.AlterField("Pony", "id", models.I... | [
"def",
"test_alter_field_pk",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alflpk\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterField",
"(",
"\"Pony\"",
",",
"\"id\"",
",",
"models",... | [
899,
4
] | [
915,
89
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_field_pk_fk | (self) |
Tests the AlterField operation on primary keys changes any FKs pointing to it.
|
Tests the AlterField operation on primary keys changes any FKs pointing to it.
| def test_alter_field_pk_fk(self):
"""
Tests the AlterField operation on primary keys changes any FKs pointing to it.
"""
project_state = self.set_up_test_model("test_alflpkfk", related_model=True)
# Test the state alteration
operation = migrations.AlterField("Pony", "id",... | [
"def",
"test_alter_field_pk_fk",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alflpkfk\"",
",",
"related_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterField",
"(",
"... | [
918,
4
] | [
944,
34
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_rename_field | (self) |
Tests the RenameField operation.
|
Tests the RenameField operation.
| def test_rename_field(self):
"""
Tests the RenameField operation.
"""
project_state = self.set_up_test_model("test_rnfl", unique_together=True)
# Test the state alteration
operation = migrations.RenameField("Pony", "pink", "blue")
self.assertEqual(operation.descri... | [
"def",
"test_rename_field",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_rnfl\"",
",",
"unique_together",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"RenameField",
"(",
"\"Pony... | [
946,
4
] | [
979,
60
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_unique_together | (self) |
Tests the AlterUniqueTogether operation.
|
Tests the AlterUniqueTogether operation.
| def test_alter_unique_together(self):
"""
Tests the AlterUniqueTogether operation.
"""
project_state = self.set_up_test_model("test_alunto")
# Test the state alteration
operation = migrations.AlterUniqueTogether("Pony", [("pink", "weight")])
self.assertEqual(opera... | [
"def",
"test_alter_unique_together",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alunto\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterUniqueTogether",
"(",
"\"Pony\"",
",",
"[",
"(",
... | [
981,
4
] | [
1015,
111
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_index_together | (self) |
Tests the AlterIndexTogether operation.
|
Tests the AlterIndexTogether operation.
| def test_alter_index_together(self):
"""
Tests the AlterIndexTogether operation.
"""
project_state = self.set_up_test_model("test_alinto")
# Test the state alteration
operation = migrations.AlterIndexTogether("Pony", [("pink", "weight")])
self.assertEqual(operatio... | [
"def",
"test_alter_index_together",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alinto\"",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterIndexTogether",
"(",
"\"Pony\"",
",",
"[",
"(",
... | [
1021,
4
] | [
1042,
73
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_model_options | (self) |
Tests the AlterModelOptions operation.
|
Tests the AlterModelOptions operation.
| def test_alter_model_options(self):
"""
Tests the AlterModelOptions operation.
"""
project_state = self.set_up_test_model("test_almoop")
# Test the state alteration (no DB alteration to test)
operation = migrations.AlterModelOptions("Pony", {"permissions": [("can_groom", ... | [
"def",
"test_alter_model_options",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_almoop\"",
")",
"# Test the state alteration (no DB alteration to test)",
"operation",
"=",
"migrations",
".",
"AlterModelOptions",
"(",
"\"Pony\""... | [
1048,
4
] | [
1060,
107
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_model_options_emptying | (self) |
Tests that the AlterModelOptions operation removes keys from the dict (#23121)
|
Tests that the AlterModelOptions operation removes keys from the dict (#23121)
| def test_alter_model_options_emptying(self):
"""
Tests that the AlterModelOptions operation removes keys from the dict (#23121)
"""
project_state = self.set_up_test_model("test_almoop", options=True)
# Test the state alteration (no DB alteration to test)
operation = migra... | [
"def",
"test_alter_model_options_emptying",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_almoop\"",
",",
"options",
"=",
"True",
")",
"# Test the state alteration (no DB alteration to test)",
"operation",
"=",
"migrations",
"... | [
1062,
4
] | [
1073,
104
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_order_with_respect_to | (self) |
Tests the AlterOrderWithRespectTo operation.
|
Tests the AlterOrderWithRespectTo operation.
| def test_alter_order_with_respect_to(self):
"""
Tests the AlterOrderWithRespectTo operation.
"""
project_state = self.set_up_test_model("test_alorwrtto", related_model=True)
# Test the state alteration
operation = migrations.AlterOrderWithRespectTo("Rider", "pony")
... | [
"def",
"test_alter_order_with_respect_to",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alorwrtto\"",
",",
"related_model",
"=",
"True",
")",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterOrderWi... | [
1075,
4
] | [
1096,
68
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_fk | (self) |
Tests that creating and then altering an FK works correctly
and deals with the pending SQL (#23091)
|
Tests that creating and then altering an FK works correctly
and deals with the pending SQL (#23091)
| def test_alter_fk(self):
"""
Tests that creating and then altering an FK works correctly
and deals with the pending SQL (#23091)
"""
project_state = self.set_up_test_model("test_alfk")
# Test adding and then altering the FK in one go
create_operation = migrations.... | [
"def",
"test_alter_fk",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_alfk\"",
")",
"# Test adding and then altering the FK in one go",
"create_operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"name",
"=",
"\"Rider\""... | [
1098,
4
] | [
1123,
93
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_alter_fk_non_fk | (self) |
Tests that altering an FK to a non-FK works (#23244)
|
Tests that altering an FK to a non-FK works (#23244)
| def test_alter_fk_non_fk(self):
"""
Tests that altering an FK to a non-FK works (#23244)
"""
# Test the state alteration
operation = migrations.AlterField(
model_name="Rider",
name="pony",
field=models.FloatField(),
)
project_st... | [
"def",
"test_alter_fk_non_fk",
"(",
"self",
")",
":",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AlterField",
"(",
"model_name",
"=",
"\"Rider\"",
",",
"name",
"=",
"\"pony\"",
",",
"field",
"=",
"models",
".",
"FloatField",
"(",
")",
... | [
1125,
4
] | [
1147,
63
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_run_sql | (self) |
Tests the RunSQL operation.
|
Tests the RunSQL operation.
| def test_run_sql(self):
"""
Tests the RunSQL operation.
"""
project_state = self.set_up_test_model("test_runsql")
# Create the operation
operation = migrations.RunSQL(
# Use a multi-line string with a comment to test splitting on SQLite and MySQL respectively
... | [
"def",
"test_run_sql",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_runsql\"",
")",
"# Create the operation",
"operation",
"=",
"migrations",
".",
"RunSQL",
"(",
"# Use a multi-line string with a comment to test splitting on SQ... | [
1150,
4
] | [
1195,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_run_sql_params | (self) |
#23426 - RunSQL should accept parameters.
|
#23426 - RunSQL should accept parameters.
| def test_run_sql_params(self):
"""
#23426 - RunSQL should accept parameters.
"""
project_state = self.set_up_test_model("test_runsql")
# Create the operation
operation = migrations.RunSQL(
["CREATE TABLE i_love_ponies (id int, special_thing varchar(15));"],
... | [
"def",
"test_run_sql_params",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_runsql\"",
")",
"# Create the operation",
"operation",
"=",
"migrations",
".",
"RunSQL",
"(",
"[",
"\"CREATE TABLE i_love_ponies (id int, special_thin... | [
1197,
4
] | [
1246,
50
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_run_sql_params_invalid | (self) |
#23426 - RunSQL should fail when a list of statements with an incorrect
number of tuples is given.
|
#23426 - RunSQL should fail when a list of statements with an incorrect
number of tuples is given.
| def test_run_sql_params_invalid(self):
"""
#23426 - RunSQL should fail when a list of statements with an incorrect
number of tuples is given.
"""
project_state = self.set_up_test_model("test_runsql")
new_state = project_state.clone()
operation = migrations.RunSQL(... | [
"def",
"test_run_sql_params_invalid",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_runsql\"",
")",
"new_state",
"=",
"project_state",
".",
"clone",
"(",
")",
"operation",
"=",
"migrations",
".",
"RunSQL",
"(",
"# fo... | [
1248,
4
] | [
1276,
64
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_run_python | (self) |
Tests the RunPython operation
|
Tests the RunPython operation
| def test_run_python(self):
"""
Tests the RunPython operation
"""
project_state = self.set_up_test_model("test_runpython", mti_model=True)
# Create the operation
def inner_method(models, schema_editor):
Pony = models.get_model("test_runpython", "Pony")
... | [
"def",
"test_run_python",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_runpython\"",
",",
"mti_model",
"=",
"True",
")",
"# Create the operation",
"def",
"inner_method",
"(",
"models",
",",
"schema_editor",
")",
":",
... | [
1278,
4
] | [
1349,
111
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_run_python_atomic | (self) |
Tests the RunPython operation correctly handles the "atomic" keyword
|
Tests the RunPython operation correctly handles the "atomic" keyword
| def test_run_python_atomic(self):
"""
Tests the RunPython operation correctly handles the "atomic" keyword
"""
project_state = self.set_up_test_model("test_runpythonatomic", mti_model=True)
def inner_method(models, schema_editor):
Pony = models.get_model("test_runpyt... | [
"def",
"test_run_python_atomic",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_runpythonatomic\"",
",",
"mti_model",
"=",
"True",
")",
"def",
"inner_method",
"(",
"models",
",",
"schema_editor",
")",
":",
"Pony",
"="... | [
1351,
4
] | [
1387,
113
] | python | en | ['en', 'error', 'th'] | False |
OperationTests.test_separate_database_and_state | (self) |
Tests the SeparateDatabaseAndState operation.
|
Tests the SeparateDatabaseAndState operation.
| def test_separate_database_and_state(self):
"""
Tests the SeparateDatabaseAndState operation.
"""
project_state = self.set_up_test_model("test_separatedatabaseandstate")
# Create the operation
database_operation = migrations.RunSQL(
"CREATE TABLE i_love_ponies... | [
"def",
"test_separate_database_and_state",
"(",
"self",
")",
":",
"project_state",
"=",
"self",
".",
"set_up_test_model",
"(",
"\"test_separatedatabaseandstate\"",
")",
"# Create the operation",
"database_operation",
"=",
"migrations",
".",
"RunSQL",
"(",
"\"CREATE TABLE i_... | [
1390,
4
] | [
1420,
50
] | python | en | ['en', 'error', 'th'] | False |
MultiDBOperationTests.test_create_model | (self) |
Tests that CreateModel honours multi-db settings.
|
Tests that CreateModel honours multi-db settings.
| def test_create_model(self):
"""
Tests that CreateModel honours multi-db settings.
"""
operation = migrations.CreateModel(
"Pony",
[
("id", models.AutoField(primary_key=True)),
("pink", models.IntegerField(default=1)),
]... | [
"def",
"test_create_model",
"(",
"self",
")",
":",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"Pony\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"pink\"",
",",
"model... | [
1443,
4
] | [
1466,
51
] | python | en | ['en', 'error', 'th'] | False |
SwappableOperationTests.test_create_ignore_swapped | (self) |
Tests that the CreateTable operation ignores swapped models.
|
Tests that the CreateTable operation ignores swapped models.
| def test_create_ignore_swapped(self):
"""
Tests that the CreateTable operation ignores swapped models.
"""
operation = migrations.CreateModel(
"Pony",
[
("id", models.AutoField(primary_key=True)),
("pink", models.IntegerField(defaul... | [
"def",
"test_create_ignore_swapped",
"(",
"self",
")",
":",
"operation",
"=",
"migrations",
".",
"CreateModel",
"(",
"\"Pony\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"pink\"",
",",... | [
1482,
4
] | [
1510,
53
] | python | en | ['en', 'error', 'th'] | False |
SwappableOperationTests.test_delete_ignore_swapped | (self) |
Tests the DeleteModel operation ignores swapped models.
|
Tests the DeleteModel operation ignores swapped models.
| def test_delete_ignore_swapped(self):
"""
Tests the DeleteModel operation ignores swapped models.
"""
operation = migrations.DeleteModel("Pony")
project_state, new_state = self.make_test_state("test_dligsw", operation)
# Test the database alteration
self.assertTab... | [
"def",
"test_delete_ignore_swapped",
"(",
"self",
")",
":",
"operation",
"=",
"migrations",
".",
"DeleteModel",
"(",
"\"Pony\"",
")",
"project_state",
",",
"new_state",
"=",
"self",
".",
"make_test_state",
"(",
"\"test_dligsw\"",
",",
"operation",
")",
"# Test the... | [
1513,
4
] | [
1527,
53
] | python | en | ['en', 'error', 'th'] | False |
SwappableOperationTests.test_add_field_ignore_swapped | (self) |
Tests the AddField operation.
|
Tests the AddField operation.
| def test_add_field_ignore_swapped(self):
"""
Tests the AddField operation.
"""
# Test the state alteration
operation = migrations.AddField(
"Pony",
"height",
models.FloatField(null=True, default=5),
)
project_state, new_state = ... | [
"def",
"test_add_field_ignore_swapped",
"(",
"self",
")",
":",
"# Test the state alteration",
"operation",
"=",
"migrations",
".",
"AddField",
"(",
"\"Pony\"",
",",
"\"height\"",
",",
"models",
".",
"FloatField",
"(",
"null",
"=",
"True",
",",
"default",
"=",
"5... | [
1530,
4
] | [
1549,
55
] | python | en | ['en', 'error', 'th'] | False |
check.initialize_options | (self) | Sets default values for options. | Sets default values for options. | def initialize_options(self):
"""Sets default values for options."""
self.restructuredtext = 0
self.metadata = 1
self.strict = 0
self._warnings = 0 | [
"def",
"initialize_options",
"(",
"self",
")",
":",
"self",
".",
"restructuredtext",
"=",
"0",
"self",
".",
"metadata",
"=",
"1",
"self",
".",
"strict",
"=",
"0",
"self",
".",
"_warnings",
"=",
"0"
] | [
47,
4
] | [
52,
26
] | python | fr | ['fr', 'fr', 'en'] | True |
check.warn | (self, msg) | Counts the number of warnings that occurs. | Counts the number of warnings that occurs. | def warn(self, msg):
"""Counts the number of warnings that occurs."""
self._warnings += 1
return Command.warn(self, msg) | [
"def",
"warn",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"_warnings",
"+=",
"1",
"return",
"Command",
".",
"warn",
"(",
"self",
",",
"msg",
")"
] | [
57,
4
] | [
60,
38
] | python | en | ['en', 'en', 'en'] | True |
check.run | (self) | Runs the command. | Runs the command. | def run(self):
"""Runs the command."""
# perform the various tests
if self.metadata:
self.check_metadata()
if self.restructuredtext:
if HAS_DOCUTILS:
self.check_restructuredtext()
elif self.strict:
raise DistutilsSetupEr... | [
"def",
"run",
"(",
"self",
")",
":",
"# perform the various tests",
"if",
"self",
".",
"metadata",
":",
"self",
".",
"check_metadata",
"(",
")",
"if",
"self",
".",
"restructuredtext",
":",
"if",
"HAS_DOCUTILS",
":",
"self",
".",
"check_restructuredtext",
"(",
... | [
62,
4
] | [
76,
69
] | python | en | ['en', 'it', 'en'] | True |
check.check_metadata | (self) | Ensures that all required elements of meta-data are supplied.
Required fields:
name, version, URL
Recommended fields:
(author and author_email) or (maintainer and maintainer_email))
Warns if any are missing.
| Ensures that all required elements of meta-data are supplied. | def check_metadata(self):
"""Ensures that all required elements of meta-data are supplied.
Required fields:
name, version, URL
Recommended fields:
(author and author_email) or (maintainer and maintainer_email))
Warns if any are missing.
"""
meta... | [
"def",
"check_metadata",
"(",
"self",
")",
":",
"metadata",
"=",
"self",
".",
"distribution",
".",
"metadata",
"missing",
"=",
"[",
"]",
"for",
"attr",
"in",
"(",
"'name'",
",",
"'version'",
",",
"'url'",
")",
":",
"if",
"not",
"(",
"hasattr",
"(",
"... | [
78,
4
] | [
109,
43
] | python | en | ['en', 'en', 'en'] | True |
check.check_restructuredtext | (self) | Checks if the long string fields are reST-compliant. | Checks if the long string fields are reST-compliant. | def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
data = self.distribution.get_long_description()
for warning in self._check_rst_data(data):
line = warning[-1].get('line')
if line is None:
warning = warning[1]
... | [
"def",
"check_restructuredtext",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"distribution",
".",
"get_long_description",
"(",
")",
"for",
"warning",
"in",
"self",
".",
"_check_rst_data",
"(",
"data",
")",
":",
"line",
"=",
"warning",
"[",
"-",
"1",
... | [
111,
4
] | [
120,
30
] | python | en | ['en', 'en', 'en'] | True |
check._check_rst_data | (self, data) | Returns warnings when the provided data doesn't compile. | Returns warnings when the provided data doesn't compile. | def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
# the include and csv_table directives need this to be a path
source_path = self.distribution.script_name or 'setup.py'
parser = Parser()
settings = frontend.OptionParser(components=(P... | [
"def",
"_check_rst_data",
"(",
"self",
",",
"data",
")",
":",
"# the include and csv_table directives need this to be a path",
"source_path",
"=",
"self",
".",
"distribution",
".",
"script_name",
"or",
"'setup.py'",
"parser",
"=",
"Parser",
"(",
")",
"settings",
"=",
... | [
122,
4
] | [
147,
32
] | python | en | ['en', 'en', 'en'] | True |
field_references_model | (field, model_tuple) | Return whether or not field references model_tuple. | Return whether or not field references model_tuple. | def field_references_model(field, model_tuple):
"""Return whether or not field references model_tuple."""
remote_field = field.remote_field
if remote_field:
if ModelTuple.from_model(remote_field.model) == model_tuple:
return True
through = getattr(remote_field, 'through', None)
... | [
"def",
"field_references_model",
"(",
"field",
",",
"model_tuple",
")",
":",
"remote_field",
"=",
"field",
".",
"remote_field",
"if",
"remote_field",
":",
"if",
"ModelTuple",
".",
"from_model",
"(",
"remote_field",
".",
"model",
")",
"==",
"model_tuple",
":",
... | [
43,
0
] | [
52,
16
] | python | en | ['en', 'en', 'en'] | True |
ModelTuple.from_model | (cls, model, app_label=None, model_name=None) |
Take a model class or an 'app_label.ModelName' string and return a
ModelTuple('app_label', 'modelname'). The optional app_label and
model_name arguments are the defaults if "self" or "ModelName" are
passed.
|
Take a model class or an 'app_label.ModelName' string and return a
ModelTuple('app_label', 'modelname'). The optional app_label and
model_name arguments are the defaults if "self" or "ModelName" are
passed.
| def from_model(cls, model, app_label=None, model_name=None):
"""
Take a model class or an 'app_label.ModelName' string and return a
ModelTuple('app_label', 'modelname'). The optional app_label and
model_name arguments are the defaults if "self" or "ModelName" are
passed.
... | [
"def",
"from_model",
"(",
"cls",
",",
"model",
",",
"app_label",
"=",
"None",
",",
"model_name",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"str",
")",
":",
"if",
"model",
"==",
"RECURSIVE_RELATIONSHIP_CONSTANT",
":",
"return",
"cls",
... | [
18,
4
] | [
31,
65
] | python | en | ['en', 'error', 'th'] | False |
find_commands | (management_dir) |
Given a path to a management directory, return a list of all the command
names that are available.
|
Given a path to a management directory, return a list of all the command
names that are available.
| def find_commands(management_dir):
"""
Given a path to a management directory, return a list of all the command
names that are available.
"""
command_dir = os.path.join(management_dir, 'commands')
return [name for _, name, is_pkg in pkgutil.iter_modules([command_dir])
if not is_pkg a... | [
"def",
"find_commands",
"(",
"management_dir",
")",
":",
"command_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"management_dir",
",",
"'commands'",
")",
"return",
"[",
"name",
"for",
"_",
",",
"name",
",",
"is_pkg",
"in",
"pkgutil",
".",
"iter_modules",... | [
20,
0
] | [
27,
55
] | python | en | ['en', 'error', 'th'] | False |
load_command_class | (app_name, name) |
Given a command name and an application name, return the Command
class instance. Allow all errors raised by the import process
(ImportError, AttributeError) to propagate.
|
Given a command name and an application name, return the Command
class instance. Allow all errors raised by the import process
(ImportError, AttributeError) to propagate.
| def load_command_class(app_name, name):
"""
Given a command name and an application name, return the Command
class instance. Allow all errors raised by the import process
(ImportError, AttributeError) to propagate.
"""
module = import_module('%s.management.commands.%s' % (app_name, name))
re... | [
"def",
"load_command_class",
"(",
"app_name",
",",
"name",
")",
":",
"module",
"=",
"import_module",
"(",
"'%s.management.commands.%s'",
"%",
"(",
"app_name",
",",
"name",
")",
")",
"return",
"module",
".",
"Command",
"(",
")"
] | [
30,
0
] | [
37,
27
] | python | en | ['en', 'error', 'th'] | False |
get_commands | () |
Return a dictionary mapping command names to their callback applications.
Look for a management.commands package in django.core, and in each
installed application -- if a commands package exists, register all
commands in that package.
Core commands are always included. If a settings module has be... |
Return a dictionary mapping command names to their callback applications. | def get_commands():
"""
Return a dictionary mapping command names to their callback applications.
Look for a management.commands package in django.core, and in each
installed application -- if a commands package exists, register all
commands in that package.
Core commands are always included. ... | [
"def",
"get_commands",
"(",
")",
":",
"commands",
"=",
"{",
"name",
":",
"'django.core'",
"for",
"name",
"in",
"find_commands",
"(",
"__path__",
"[",
"0",
"]",
")",
"}",
"if",
"not",
"settings",
".",
"configured",
":",
"return",
"commands",
"for",
"app_c... | [
41,
0
] | [
72,
19
] | python | en | ['en', 'error', 'th'] | False |
call_command | (command_name, *args, **options) |
Call the given command, with the given options and args/kwargs.
This is the primary API you should use for calling specific commands.
`command_name` may be a string or a command object. Using a string is
preferred unless the command object is required for further processing or
testing.
Some ... |
Call the given command, with the given options and args/kwargs. | def call_command(command_name, *args, **options):
"""
Call the given command, with the given options and args/kwargs.
This is the primary API you should use for calling specific commands.
`command_name` may be a string or a command object. Using a string is
preferred unless the command object is r... | [
"def",
"call_command",
"(",
"command_name",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"command_name",
",",
"BaseCommand",
")",
":",
"# Command object passed in.",
"command",
"=",
"command_name",
"command_name",
"=",
"command"... | [
75,
0
] | [
167,
45
] | python | en | ['en', 'error', 'th'] | False |
execute_from_command_line | (argv=None) | Run a ManagementUtility. | Run a ManagementUtility. | def execute_from_command_line(argv=None):
"""Run a ManagementUtility."""
utility = ManagementUtility(argv)
utility.execute() | [
"def",
"execute_from_command_line",
"(",
"argv",
"=",
"None",
")",
":",
"utility",
"=",
"ManagementUtility",
"(",
"argv",
")",
"utility",
".",
"execute",
"(",
")"
] | [
397,
0
] | [
400,
21
] | python | en | ['es', 'lb', 'en'] | False |
ManagementUtility.main_help_text | (self, commands_only=False) | Return the script's main help text, as a string. | Return the script's main help text, as a string. | def main_help_text(self, commands_only=False):
"""Return the script's main help text, as a string."""
if commands_only:
usage = sorted(get_commands())
else:
usage = [
"",
"Type '%s help <subcommand>' for help on a specific subcommand." % se... | [
"def",
"main_help_text",
"(",
"self",
",",
"commands_only",
"=",
"False",
")",
":",
"if",
"commands_only",
":",
"usage",
"=",
"sorted",
"(",
"get_commands",
"(",
")",
")",
"else",
":",
"usage",
"=",
"[",
"\"\"",
",",
"\"Type '%s help <subcommand>' for help on ... | [
181,
4
] | [
212,
31
] | python | en | ['en', 'gd', 'en'] | True |
ManagementUtility.fetch_command | (self, subcommand) |
Try to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
|
Try to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
| def fetch_command(self, subcommand):
"""
Try to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
"""
# Get commands outside of try block to prevent swallo... | [
"def",
"fetch_command",
"(",
"self",
",",
"subcommand",
")",
":",
"# Get commands outside of try block to prevent swallowing exceptions",
"commands",
"=",
"get_commands",
"(",
")",
"try",
":",
"app_name",
"=",
"commands",
"[",
"subcommand",
"]",
"except",
"KeyError",
... | [
214,
4
] | [
244,
20
] | python | en | ['en', 'error', 'th'] | False |
ManagementUtility.autocomplete | (self) |
Output completion suggestions for BASH.
The output of this function is passed to BASH's `COMREPLY` variable and
treated as completion suggestions. `COMREPLY` expects a space
separated string as the result.
The `COMP_WORDS` and `COMP_CWORD` BASH environment variables are used
... |
Output completion suggestions for BASH. | def autocomplete(self):
"""
Output completion suggestions for BASH.
The output of this function is passed to BASH's `COMREPLY` variable and
treated as completion suggestions. `COMREPLY` expects a space
separated string as the result.
The `COMP_WORDS` and `COMP_CWORD` BA... | [
"def",
"autocomplete",
"(",
"self",
")",
":",
"# Don't complete if user hasn't sourced bash_completion file.",
"if",
"'DJANGO_AUTO_COMPLETE'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"cwords",
"=",
"os",
".",
"environ",
"[",
"'COMP_WORDS'",
"]",
".",
"spli... | [
246,
4
] | [
318,
19
] | python | en | ['en', 'error', 'th'] | False |
ManagementUtility.execute | (self) |
Given the command-line arguments, figure out which subcommand is being
run, create a parser appropriate to that command, and run it.
|
Given the command-line arguments, figure out which subcommand is being
run, create a parser appropriate to that command, and run it.
| def execute(self):
"""
Given the command-line arguments, figure out which subcommand is being
run, create a parser appropriate to that command, and run it.
"""
try:
subcommand = self.argv[1]
except IndexError:
subcommand = 'help' # Display help if... | [
"def",
"execute",
"(",
"self",
")",
":",
"try",
":",
"subcommand",
"=",
"self",
".",
"argv",
"[",
"1",
"]",
"except",
"IndexError",
":",
"subcommand",
"=",
"'help'",
"# Display help if no arguments were given.",
"# Preprocess options to extract --settings and --pythonpa... | [
320,
4
] | [
394,
67
] | python | en | ['en', 'error', 'th'] | False |
SpatialProxy.__init__ | (self, klass, field, load_func=None) |
Initialize on the given Geometry or Raster class (not an instance)
and the corresponding field.
|
Initialize on the given Geometry or Raster class (not an instance)
and the corresponding field.
| def __init__(self, klass, field, load_func=None):
"""
Initialize on the given Geometry or Raster class (not an instance)
and the corresponding field.
"""
self._klass = klass
self._load_func = load_func or klass
super().__init__(field) | [
"def",
"__init__",
"(",
"self",
",",
"klass",
",",
"field",
",",
"load_func",
"=",
"None",
")",
":",
"self",
".",
"_klass",
"=",
"klass",
"self",
".",
"_load_func",
"=",
"load_func",
"or",
"klass",
"super",
"(",
")",
".",
"__init__",
"(",
"field",
")... | [
11,
4
] | [
18,
31
] | python | en | ['en', 'error', 'th'] | False |
SpatialProxy.__get__ | (self, instance, cls=None) |
Retrieve the geometry or raster, initializing it using the
corresponding class specified during initialization and the value of
the field. Currently, GEOS or OGR geometries as well as GDALRasters are
supported.
|
Retrieve the geometry or raster, initializing it using the
corresponding class specified during initialization and the value of
the field. Currently, GEOS or OGR geometries as well as GDALRasters are
supported.
| def __get__(self, instance, cls=None):
"""
Retrieve the geometry or raster, initializing it using the
corresponding class specified during initialization and the value of
the field. Currently, GEOS or OGR geometries as well as GDALRasters are
supported.
"""
if ins... | [
"def",
"__get__",
"(",
"self",
",",
"instance",
",",
"cls",
"=",
"None",
")",
":",
"if",
"instance",
"is",
"None",
":",
"# Accessed on a class, not an instance",
"return",
"self",
"# Getting the value of the field.",
"try",
":",
"geo_value",
"=",
"instance",
".",
... | [
20,
4
] | [
46,
22
] | python | en | ['en', 'error', 'th'] | False |
SpatialProxy.__set__ | (self, instance, value) |
Retrieve the proxied geometry or raster with the corresponding class
specified during initialization.
To set geometries, use values of None, HEXEWKB, or WKT.
To set rasters, use JSON or dict values.
|
Retrieve the proxied geometry or raster with the corresponding class
specified during initialization. | def __set__(self, instance, value):
"""
Retrieve the proxied geometry or raster with the corresponding class
specified during initialization.
To set geometries, use values of None, HEXEWKB, or WKT.
To set rasters, use JSON or dict values.
"""
# The geographic typ... | [
"def",
"__set__",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"# The geographic type of the field.",
"gtype",
"=",
"self",
".",
"field",
".",
"geom_type",
"if",
"gtype",
"==",
"'RASTER'",
"and",
"(",
"value",
"is",
"None",
"or",
"isinstance",
"(",
... | [
48,
4
] | [
78,
20
] | python | en | ['en', 'error', 'th'] | False |
clean_ipv6_address | (ip_str, unpack_ipv4=False,
error_message=_("This is not a valid IPv6 address.")) |
Cleans an IPv6 address string.
Validity is checked by calling is_valid_ipv6_address() - if an
invalid address is passed, ValidationError is raised.
Replaces the longest continuous zero-sequence with "::" and
removes leading zeroes and makes sure all hextets are lowercase.
Args:
ip_st... |
Cleans an IPv6 address string. | def clean_ipv6_address(ip_str, unpack_ipv4=False,
error_message=_("This is not a valid IPv6 address.")):
"""
Cleans an IPv6 address string.
Validity is checked by calling is_valid_ipv6_address() - if an
invalid address is passed, ValidationError is raised.
Replaces the longest continuous z... | [
"def",
"clean_ipv6_address",
"(",
"ip_str",
",",
"unpack_ipv4",
"=",
"False",
",",
"error_message",
"=",
"_",
"(",
"\"This is not a valid IPv6 address.\"",
")",
")",
":",
"best_doublecolon_start",
"=",
"-",
"1",
"best_doublecolon_len",
"=",
"0",
"doublecolon_start",
... | [
8,
0
] | [
87,
25
] | python | en | ['en', 'error', 'th'] | False |
_sanitize_ipv4_mapping | (ip_str) |
Sanitize IPv4 mapping in an expanded IPv6 address.
This converts ::ffff:0a0a:0a0a to ::ffff:10.10.10.10.
If there is nothing to sanitize, returns an unchanged
string.
Args:
ip_str: A string, the expanded IPv6 address.
Returns:
The sanitized output string, if applicable.
|
Sanitize IPv4 mapping in an expanded IPv6 address. | def _sanitize_ipv4_mapping(ip_str):
"""
Sanitize IPv4 mapping in an expanded IPv6 address.
This converts ::ffff:0a0a:0a0a to ::ffff:10.10.10.10.
If there is nothing to sanitize, returns an unchanged
string.
Args:
ip_str: A string, the expanded IPv6 address.
Returns:
The sa... | [
"def",
"_sanitize_ipv4_mapping",
"(",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'0000:0000:0000:0000:0000:ffff:'",
")",
":",
"# not an ipv4 mapping",
"return",
"ip_str",
"hextets",
"=",
"ip_str",
".",
"split",
"(... | [
90,
0
] | [
124,
17
] | python | en | ['en', 'error', 'th'] | False |
_unpack_ipv4 | (ip_str) |
Unpack an IPv4 address that was mapped in a compressed IPv6 address.
This converts 0000:0000:0000:0000:0000:ffff:10.10.10.10 to 10.10.10.10.
If there is nothing to sanitize, returns None.
Args:
ip_str: A string, the expanded IPv6 address.
Returns:
The unpacked IPv4 address, or No... |
Unpack an IPv4 address that was mapped in a compressed IPv6 address. | def _unpack_ipv4(ip_str):
"""
Unpack an IPv4 address that was mapped in a compressed IPv6 address.
This converts 0000:0000:0000:0000:0000:ffff:10.10.10.10 to 10.10.10.10.
If there is nothing to sanitize, returns None.
Args:
ip_str: A string, the expanded IPv6 address.
Returns:
... | [
"def",
"_unpack_ipv4",
"(",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'0000:0000:0000:0000:0000:ffff:'",
")",
":",
"return",
"None",
"return",
"ip_str",
".",
"rsplit",
"(",
"':'",
",",
"1",
")",
"[",
"1",... | [
127,
0
] | [
143,
35
] | python | en | ['en', 'error', 'th'] | False |
is_valid_ipv6_address | (ip_str) |
Ensure we have a valid IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A boolean, True if this is a valid IPv6 address.
|
Ensure we have a valid IPv6 address. | def is_valid_ipv6_address(ip_str):
"""
Ensure we have a valid IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A boolean, True if this is a valid IPv6 address.
"""
from django.core.validators import validate_ipv4_address
# We need to have at least one ':'.... | [
"def",
"is_valid_ipv6_address",
"(",
"ip_str",
")",
":",
"from",
"django",
".",
"core",
".",
"validators",
"import",
"validate_ipv4_address",
"# We need to have at least one ':'.",
"if",
"':'",
"not",
"in",
"ip_str",
":",
"return",
"False",
"# We can only have one '::' ... | [
146,
0
] | [
208,
15
] | python | en | ['en', 'error', 'th'] | False |
_explode_shorthand_ip_string | (ip_str) |
Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
|
Expand a shortened IPv6 address. | def _explode_shorthand_ip_string(ip_str):
"""
Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if not _is_shorthand_ip(ip_str):
# We've already got a longhand ip_str.
return ip_str
... | [
"def",
"_explode_shorthand_ip_string",
"(",
"ip_str",
")",
":",
"if",
"not",
"_is_shorthand_ip",
"(",
"ip_str",
")",
":",
"# We've already got a longhand ip_str.",
"return",
"ip_str",
"new_ip",
"=",
"[",
"]",
"hextet",
"=",
"ip_str",
".",
"split",
"(",
"'::'",
"... | [
211,
0
] | [
253,
27
] | python | en | ['en', 'error', 'th'] | False |
_is_shorthand_ip | (ip_str) | Determine if the address is shortened.
Args:
ip_str: A string, the IPv6 address.
Returns:
A boolean, True if the address is shortened.
| Determine if the address is shortened. | def _is_shorthand_ip(ip_str):
"""Determine if the address is shortened.
Args:
ip_str: A string, the IPv6 address.
Returns:
A boolean, True if the address is shortened.
"""
if ip_str.count('::') == 1:
return True
if any(len(x) < 4 for x in ip_str.split(':')):
re... | [
"def",
"_is_shorthand_ip",
"(",
"ip_str",
")",
":",
"if",
"ip_str",
".",
"count",
"(",
"'::'",
")",
"==",
"1",
":",
"return",
"True",
"if",
"any",
"(",
"len",
"(",
"x",
")",
"<",
"4",
"for",
"x",
"in",
"ip_str",
".",
"split",
"(",
"':'",
")",
"... | [
256,
0
] | [
270,
16
] | python | en | ['en', 'en', 'en'] | True |
parse | (doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs) | Parse an HTML document as a string or file-like object into a tree
:arg doc: the document to parse as a string or file-like object
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or not to namespace HTML elements
:returns: parsed tree
Example:
>>> ... | Parse an HTML document as a string or file-like object into a tree | def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse an HTML document as a string or file-like object into a tree
:arg doc: the document to parse as a string or file-like object
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or... | [
"def",
"parse",
"(",
"doc",
",",
"treebuilder",
"=",
"\"etree\"",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"tb",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"treebuilder",
")",
"p",
"=",
"HTMLParser",
"(",
"tb",
... | [
26,
0
] | [
46,
33
] | python | en | ['en', 'en', 'en'] | True |
parseFragment | (doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs) | Parse an HTML fragment as a string or file-like object into a tree
:arg doc: the fragment to parse as a string or file-like object
:arg container: the container context to parse the fragment in
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or not to namesp... | Parse an HTML fragment as a string or file-like object into a tree | def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse an HTML fragment as a string or file-like object into a tree
:arg doc: the fragment to parse as a string or file-like object
:arg container: the container context to parse the fragment in
:arg... | [
"def",
"parseFragment",
"(",
"doc",
",",
"container",
"=",
"\"div\"",
",",
"treebuilder",
"=",
"\"etree\"",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"tb",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"treebuilder",
")... | [
49,
0
] | [
71,
62
] | python | en | ['en', 'en', 'en'] | True |
log | (function) | Logger that records which phase processes each token | Logger that records which phase processes each token | def log(function):
"""Logger that records which phase processes each token"""
type_names = dict((value, key) for key, value in
tokenTypes.items())
def wrapped(self, *args, **kwargs):
if function.__name__.startswith("process") and len(args) > 0:
... | [
"def",
"log",
"(",
"function",
")",
":",
"type_names",
"=",
"dict",
"(",
"(",
"value",
",",
"key",
")",
"for",
"key",
",",
"value",
"in",
"tokenTypes",
".",
"items",
"(",
")",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
... | [
413,
4
] | [
436,
22
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.__init__ | (self, tree=None, strict=False, namespaceHTMLElements=True, debug=False) |
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType)
:arg strict: raise an exception when a parse error is encountered
:arg namespaceHTMLElements:... |
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType) | def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=False):
"""
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType)
:arg ... | [
"def",
"__init__",
"(",
"self",
",",
"tree",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"debug",
"=",
"False",
")",
":",
"# Raise an exception on the first error encountered",
"self",
".",
"strict",
"=",
"strict",
... | [
93,
4
] | [
122,
54
] | 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.