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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
ChangeSettingsTest.test_successful_change_settings | (self) |
A call to /json/settings with valid parameters changes the user's
settings correctly and returns correct values.
|
A call to /json/settings with valid parameters changes the user's
settings correctly and returns correct values.
| def test_successful_change_settings(self) -> None:
"""
A call to /json/settings with valid parameters changes the user's
settings correctly and returns correct values.
"""
user = self.example_user("hamlet")
self.login_user(user)
json_result = self.client_patch(
... | [
"def",
"test_successful_change_settings",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user",
")",
"json_result",
"=",
"self",
".",
"client_patch",
"(",
"\"/json/setting... | [
54,
4
] | [
90,
46
] | python | en | ['en', 'error', 'th'] | False |
ChangeSettingsTest.test_toggling_boolean_user_display_settings | (self) | Test updating each boolean setting in UserProfile property_types | Test updating each boolean setting in UserProfile property_types | def test_toggling_boolean_user_display_settings(self) -> None:
"""Test updating each boolean setting in UserProfile property_types"""
boolean_settings = (
s for s in UserProfile.property_types if UserProfile.property_types[s] is bool
)
for display_setting in boolean_settings:... | [
"def",
"test_toggling_boolean_user_display_settings",
"(",
"self",
")",
"->",
"None",
":",
"boolean_settings",
"=",
"(",
"s",
"for",
"s",
"in",
"UserProfile",
".",
"property_types",
"if",
"UserProfile",
".",
"property_types",
"[",
"s",
"]",
"is",
"bool",
")",
... | [
192,
4
] | [
198,
88
] | python | en | ['en', 'en', 'en'] | True |
ChangeSettingsTest.test_changing_nothing_returns_error | (self) |
We need to supply at least one non-empty parameter
to this API, or it should fail. (Eventually, we should
probably use a patch interface for these changes.)
|
We need to supply at least one non-empty parameter
to this API, or it should fail. (Eventually, we should
probably use a patch interface for these changes.)
| def test_changing_nothing_returns_error(self) -> None:
"""
We need to supply at least one non-empty parameter
to this API, or it should fail. (Eventually, we should
probably use a patch interface for these changes.)
"""
self.login("hamlet")
result = self.client_p... | [
"def",
"test_changing_nothing_returns_error",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_patch",
"(",
"\"/json/settings\"",
",",
"dict",
"(",
"old_password",
"=",
"\"ignored\"",
")",
"... | [
324,
4
] | [
332,
69
] | python | en | ['en', 'error', 'th'] | False |
ChangeSettingsTest.test_change_user_display_setting | (self) | Test updating each non-boolean setting in UserProfile property_types | Test updating each non-boolean setting in UserProfile property_types | def test_change_user_display_setting(self) -> None:
"""Test updating each non-boolean setting in UserProfile property_types"""
user_settings = (
s for s in UserProfile.property_types if UserProfile.property_types[s] is not bool
)
for setting in user_settings:
self... | [
"def",
"test_change_user_display_setting",
"(",
"self",
")",
"->",
"None",
":",
"user_settings",
"=",
"(",
"s",
"for",
"s",
"in",
"UserProfile",
".",
"property_types",
"if",
"UserProfile",
".",
"property_types",
"[",
"s",
"]",
"is",
"not",
"bool",
")",
"for"... | [
381,
4
] | [
387,
61
] | python | en | ['en', 'en', 'en'] | True |
ChangeSettingsTest.test_emojiset | (self) | Test banned emojisets are not accepted. | Test banned emojisets are not accepted. | def test_emojiset(self) -> None:
"""Test banned emojisets are not accepted."""
banned_emojisets = ["apple", "emojione"]
valid_emojisets = ["google", "google-blob", "text", "twitter"]
for emojiset in banned_emojisets:
result = self.do_change_emojiset(emojiset)
sel... | [
"def",
"test_emojiset",
"(",
"self",
")",
"->",
"None",
":",
"banned_emojisets",
"=",
"[",
"\"apple\"",
",",
"\"emojione\"",
"]",
"valid_emojisets",
"=",
"[",
"\"google\"",
",",
"\"google-blob\"",
",",
"\"text\"",
",",
"\"twitter\"",
"]",
"for",
"emojiset",
"i... | [
395,
4
] | [
406,
44
] | python | en | ['en', 'en', 'en'] | True |
main | () | Script entry point. | Script entry point. | def main():
"""Script entry point."""
cfg = parse_args()
status = run_algorithm(cfg)
return status | [
"def",
"main",
"(",
")",
":",
"cfg",
"=",
"parse_args",
"(",
")",
"status",
"=",
"run_algorithm",
"(",
"cfg",
")",
"return",
"status"
] | [
15,
0
] | [
19,
17
] | python | en | ['en', 'en', 'en'] | True |
EventSequence.append | (self, event) | Appends event to the end of the sequence.
Args:
event: The event to append to the end.
| Appends event to the end of the sequence. | def append(self, event):
"""Appends event to the end of the sequence.
Args:
event: The event to append to the end.
"""
pass | [
"def",
"append",
"(",
"self",
",",
"event",
")",
":",
"pass"
] | [
70,
2
] | [
76,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequence.set_length | (self, steps, from_left=False) | Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, will pad to make the sequence
the specified length. If it is too long, it will be truncated to the
requested length.
Args:
steps: How many steps long the event sequence should be.
f... | Sets the length of the sequence to the specified number of steps. | def set_length(self, steps, from_left=False):
"""Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, will pad to make the sequence
the specified length. If it is too long, it will be truncated to the
requested length.
Args:
steps: How ... | [
"def",
"set_length",
"(",
"self",
",",
"steps",
",",
"from_left",
"=",
"False",
")",
":",
"pass"
] | [
79,
2
] | [
90,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequence.__getitem__ | (self, i) | Returns the event at the given index. | Returns the event at the given index. | def __getitem__(self, i):
"""Returns the event at the given index."""
pass | [
"def",
"__getitem__",
"(",
"self",
",",
"i",
")",
":",
"pass"
] | [
93,
2
] | [
95,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequence.__iter__ | (self) | Returns an iterator over the events. | Returns an iterator over the events. | def __iter__(self):
"""Returns an iterator over the events."""
pass | [
"def",
"__iter__",
"(",
"self",
")",
":",
"pass"
] | [
98,
2
] | [
100,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequence.__len__ | (self) | How many events are in this EventSequence.
Returns:
Number of events as an integer.
| How many events are in this EventSequence. | def __len__(self):
"""How many events are in this EventSequence.
Returns:
Number of events as an integer.
"""
pass | [
"def",
"__len__",
"(",
"self",
")",
":",
"pass"
] | [
103,
2
] | [
109,
8
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.__init__ | (self, pad_event, events=None, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER) | Construct a SimpleEventSequence.
If `events` is specified, instantiate with the provided event list.
Otherwise, create an empty SimpleEventSequence.
Args:
pad_event: Event value to use when padding sequences.
events: List of events to instantiate with.
start_step: The integer starting st... | Construct a SimpleEventSequence. | def __init__(self, pad_event, events=None, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER):
"""Construct a SimpleEventSequence.
If `events` is specified, instantiate with the provided event list.
Otherwise, create an empty Simple... | [
"def",
"__init__",
"(",
"self",
",",
"pad_event",
",",
"events",
"=",
"None",
",",
"start_step",
"=",
"0",
",",
"steps_per_bar",
"=",
"DEFAULT_STEPS_PER_BAR",
",",
"steps_per_quarter",
"=",
"DEFAULT_STEPS_PER_QUARTER",
")",
":",
"self",
".",
"_pad_event",
"=",
... | [
133,
2
] | [
158,
33
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence._reset | (self) | Clear events and reset object state. | Clear events and reset object state. | def _reset(self):
"""Clear events and reset object state."""
self._events = []
self._steps_per_bar = DEFAULT_STEPS_PER_BAR
self._steps_per_quarter = DEFAULT_STEPS_PER_QUARTER
self._start_step = 0
self._end_step = 0 | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"_events",
"=",
"[",
"]",
"self",
".",
"_steps_per_bar",
"=",
"DEFAULT_STEPS_PER_BAR",
"self",
".",
"_steps_per_quarter",
"=",
"DEFAULT_STEPS_PER_QUARTER",
"self",
".",
"_start_step",
"=",
"0",
"self",
".",
... | [
160,
2
] | [
166,
22
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence._from_event_list | (self, events, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER) | Initializes with a list of event values and sets attributes. | Initializes with a list of event values and sets attributes. | def _from_event_list(self, events, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER):
"""Initializes with a list of event values and sets attributes."""
self._events = list(events)
self._start_step = start_step
s... | [
"def",
"_from_event_list",
"(",
"self",
",",
"events",
",",
"start_step",
"=",
"0",
",",
"steps_per_bar",
"=",
"DEFAULT_STEPS_PER_BAR",
",",
"steps_per_quarter",
"=",
"DEFAULT_STEPS_PER_QUARTER",
")",
":",
"self",
".",
"_events",
"=",
"list",
"(",
"events",
")",... | [
168,
2
] | [
176,
47
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.__iter__ | (self) | Return an iterator over the events in this SimpleEventSequence.
Returns:
Python iterator over events.
| Return an iterator over the events in this SimpleEventSequence. | def __iter__(self):
"""Return an iterator over the events in this SimpleEventSequence.
Returns:
Python iterator over events.
"""
return iter(self._events) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"_events",
")"
] | [
178,
2
] | [
184,
29
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.__getitem__ | (self, key) | Returns the slice or individual item. | Returns the slice or individual item. | def __getitem__(self, key):
"""Returns the slice or individual item."""
if isinstance(key, int):
return self._events[key]
elif isinstance(key, slice):
events = self._events.__getitem__(key)
return type(self)(pad_event=self._pad_event,
events=events,
... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"int",
")",
":",
"return",
"self",
".",
"_events",
"[",
"key",
"]",
"elif",
"isinstance",
"(",
"key",
",",
"slice",
")",
":",
"events",
"=",
"self",
".",
... | [
186,
2
] | [
196,
65
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.__len__ | (self) | How many events are in this SimpleEventSequence.
Returns:
Number of events as an integer.
| How many events are in this SimpleEventSequence. | def __len__(self):
"""How many events are in this SimpleEventSequence.
Returns:
Number of events as an integer.
"""
return len(self._events) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_events",
")"
] | [
198,
2
] | [
204,
28
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.append | (self, event) | Appends event to the end of the sequence and increments the end step.
Args:
event: The event to append to the end.
| Appends event to the end of the sequence and increments the end step. | def append(self, event):
"""Appends event to the end of the sequence and increments the end step.
Args:
event: The event to append to the end.
"""
self._events.append(event)
self._end_step += 1 | [
"def",
"append",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_events",
".",
"append",
"(",
"event",
")",
"self",
".",
"_end_step",
"+=",
"1"
] | [
242,
2
] | [
249,
23
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.set_length | (self, steps, from_left=False) | Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, pads to make the sequence the
specified length. If it is too long, it will be truncated to the requested
length.
Args:
steps: How many steps long the event sequence should be.
from_l... | Sets the length of the sequence to the specified number of steps. | def set_length(self, steps, from_left=False):
"""Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, pads to make the sequence the
specified length. If it is too long, it will be truncated to the requested
length.
Args:
steps: How many ... | [
"def",
"set_length",
"(",
"self",
",",
"steps",
",",
"from_left",
"=",
"False",
")",
":",
"if",
"steps",
">",
"len",
"(",
"self",
")",
":",
"if",
"from_left",
":",
"self",
".",
"_events",
"[",
":",
"0",
"]",
"=",
"[",
"self",
".",
"_pad_event",
"... | [
251,
2
] | [
276,
47
] | python | en | ['en', 'en', 'en'] | True |
SimpleEventSequence.increase_resolution | (self, k, fill_event=None) | Increase the resolution of an event sequence.
Increases the resolution of a SimpleEventSequence object by a factor of
`k`.
Args:
k: An integer, the factor by which to increase the resolution of the
event sequence.
fill_event: Event value to use to extend each low-resolution event. If... | Increase the resolution of an event sequence. | def increase_resolution(self, k, fill_event=None):
"""Increase the resolution of an event sequence.
Increases the resolution of a SimpleEventSequence object by a factor of
`k`.
Args:
k: An integer, the factor by which to increase the resolution of the
event sequence.
fill_event: ... | [
"def",
"increase_resolution",
"(",
"self",
",",
"k",
",",
"fill_event",
"=",
"None",
")",
":",
"if",
"fill_event",
"is",
"None",
":",
"fill",
"=",
"lambda",
"event",
":",
"[",
"event",
"]",
"*",
"k",
"else",
":",
"fill",
"=",
"lambda",
"event",
":",
... | [
278,
2
] | [
303,
32
] | python | en | ['en', 'en', 'en'] | True |
normalize_angle_degrees | (angle) |
:return: The angle normalized to (-180, 180] degrees.
|
:return: The angle normalized to (-180, 180] degrees.
| def normalize_angle_degrees(angle):
"""
:return: The angle normalized to (-180, 180] degrees.
"""
angle = angle % 360
return angle if angle <= 180 else (angle - 360) | [
"def",
"normalize_angle_degrees",
"(",
"angle",
")",
":",
"angle",
"=",
"angle",
"%",
"360",
"return",
"angle",
"if",
"angle",
"<=",
"180",
"else",
"(",
"angle",
"-",
"360",
")"
] | [
11,
0
] | [
17,
51
] | python | en | ['en', 'error', 'th'] | False |
Bazaar.export | (self, location, url) |
Export the Bazaar repository at the url to the destination location
|
Export the Bazaar repository at the url to the destination location
| def export(self, location, url):
# type: (str, HiddenText) -> None
"""
Export the Bazaar repository at the url to the destination location
"""
# Remove the location to make sure Bazaar can export it correctly
if os.path.exists(location):
rmtree(location)
... | [
"def",
"export",
"(",
"self",
",",
"location",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"# Remove the location to make sure Bazaar can export it correctly",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"location",
")",
":",
"rmtree",
"(",
"location",... | [
45,
4
] | [
57,
9
] | python | en | ['en', 'error', 'th'] | False |
Bazaar.is_commit_id_equal | (cls, dest, name) | Always assume the versions don't match | Always assume the versions don't match | def is_commit_id_equal(cls, dest, name):
"""Always assume the versions don't match"""
return False | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"return",
"False"
] | [
113,
4
] | [
115,
20
] | python | en | ['en', 'en', 'en'] | True |
update_angular_template_hash | (sender, **kwargs) | Listen for compress events.
If the angular templates have been re-compressed, also clear them
from the Django cache backend. This is important to allow
deployers to change a template file, re-compress, and not
accidentally serve the old Django cached version of that content
to clients.
| Listen for compress events. | def update_angular_template_hash(sender, **kwargs):
"""Listen for compress events.
If the angular templates have been re-compressed, also clear them
from the Django cache backend. This is important to allow
deployers to change a template file, re-compress, and not
accidentally serve the old Django... | [
"def",
"update_angular_template_hash",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"kwargs",
"[",
"'context'",
"]",
"# context the compressor is working with",
"compressed",
"=",
"context",
"[",
"'compressed'",
"]",
"# the compressed content",
"c... | [
27,
0
] | [
54,
29
] | python | en | ['en', 'en', 'en'] | True |
angular_escapes | (value) | Provide a basic filter to allow angular template content for Angular.
Djangos 'escapejs' is too aggressive and inserts unicode.
It provide a basic filter to allow angular template content to be used
within javascript strings.
Args:
value: a string
Returns:
string with escaped valu... | Provide a basic filter to allow angular template content for Angular. | def angular_escapes(value):
"""Provide a basic filter to allow angular template content for Angular.
Djangos 'escapejs' is too aggressive and inserts unicode.
It provide a basic filter to allow angular template content to be used
within javascript strings.
Args:
value: a string
Return... | [
"def",
"angular_escapes",
"(",
"value",
")",
":",
"return",
"value",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
".",
"replace",
"(",
"\"'\"",
",",
"\"\\\\'\"",
")",
".",
"replace",
"(",
"\"... | [
58,
0
] | [
76,
29
] | python | en | ['en', 'en', 'en'] | True |
angular_templates | (context) | Generate a dictionary of template contents for all static HTML templates.
If the template has been overridden by a theme, load the
override contents instead of the original HTML file.
One use for this is to pre-populate the angular template cache.
Args:
context: the context of the current Djan... | Generate a dictionary of template contents for all static HTML templates. | def angular_templates(context):
"""Generate a dictionary of template contents for all static HTML templates.
If the template has been overridden by a theme, load the
override contents instead of the original HTML file.
One use for this is to pre-populate the angular template cache.
Args:
c... | [
"def",
"angular_templates",
"(",
"context",
")",
":",
"template_paths",
"=",
"context",
"[",
"'HORIZON_CONFIG'",
"]",
"[",
"'external_templates'",
"]",
"all_theme_static_files",
"=",
"context",
"[",
"'HORIZON_CONFIG'",
"]",
"[",
"'theme_static_files'",
"]",
"this_them... | [
80,
0
] | [
134,
5
] | python | en | ['en', 'en', 'en'] | True |
post_migrate_receiver | (sender, app_config, **kwargs) |
Выполняет регистрацию реализованных в проекте функций
|
Выполняет регистрацию реализованных в проекте функций
| def post_migrate_receiver(sender, app_config, **kwargs):
"""
Выполняет регистрацию реализованных в проекте функций
"""
if app_config.name == 'function_tools':
registrar = FunctionRegistrar()
registrar.run() | [
"def",
"post_migrate_receiver",
"(",
"sender",
",",
"app_config",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"app_config",
".",
"name",
"==",
"'function_tools'",
":",
"registrar",
"=",
"FunctionRegistrar",
"(",
")",
"registrar",
".",
"run",
"(",
")"
] | [
146,
0
] | [
152,
23
] | python | en | ['en', 'error', 'th'] | False |
FunctionRegistrar._find_functions | (self) |
Поиск реализованных функций системы
|
Поиск реализованных функций системы
| def _find_functions(self):
"""
Поиск реализованных функций системы
"""
functions_module = import_module(FUNCTION_TOOLS_FUNCTIONS_MODULE_PATH)
excluded_base_functions = [
name
for name, class_ in functions_module.__dict__.items()
if isclass(clas... | [
"def",
"_find_functions",
"(",
"self",
")",
":",
"functions_module",
"=",
"import_module",
"(",
"FUNCTION_TOOLS_FUNCTIONS_MODULE_PATH",
")",
"excluded_base_functions",
"=",
"[",
"name",
"for",
"name",
",",
"class_",
"in",
"functions_module",
".",
"__dict__",
".",
"i... | [
56,
4
] | [
80,
17
] | python | en | ['en', 'error', 'th'] | False |
FunctionRegistrar._process_creating_functions | (self) |
Обработка создаваемых функций системы
|
Обработка создаваемых функций системы
| def _process_creating_functions(self):
"""
Обработка создаваемых функций системы
"""
for_creating = []
creating_function_paths = filter(lambda f_p: f_p not in self._registered_functions_map, self._functions.keys())
for creating_function_path in creating_function_paths:
... | [
"def",
"_process_creating_functions",
"(",
"self",
")",
":",
"for_creating",
"=",
"[",
"]",
"creating_function_paths",
"=",
"filter",
"(",
"lambda",
"f_p",
":",
"f_p",
"not",
"in",
"self",
".",
"_registered_functions_map",
",",
"self",
".",
"_functions",
".",
... | [
82,
4
] | [
99,
65
] | python | en | ['en', 'error', 'th'] | False |
FunctionRegistrar._process_updating_functions | (self) |
Обработка обновляемых функций системы
|
Обработка обновляемых функций системы
| def _process_updating_functions(self):
"""
Обработка обновляемых функций системы
"""
updating_function_paths = filter(lambda f_p: f_p in self._registered_functions_map, self._functions.keys())
for updating_function_path in updating_function_paths:
if (
... | [
"def",
"_process_updating_functions",
"(",
"self",
")",
":",
"updating_function_paths",
"=",
"filter",
"(",
"lambda",
"f_p",
":",
"f_p",
"in",
"self",
".",
"_registered_functions_map",
",",
"self",
".",
"_functions",
".",
"keys",
"(",
")",
")",
"for",
"updatin... | [
101,
4
] | [
117,
77
] | python | en | ['en', 'error', 'th'] | False |
FunctionRegistrar._process_deleted_functions | (self) |
Обработка удаленных, перенесенных или находящихся в отключенных плагинах функций системы
|
Обработка удаленных, перенесенных или находящихся в отключенных плагинах функций системы
| def _process_deleted_functions(self):
"""
Обработка удаленных, перенесенных или находящихся в отключенных плагинах функций системы
"""
deleted_functions = set(self._registered_functions_map.keys()).difference(self._functions.keys())
if deleted_functions:
for deleted_f... | [
"def",
"_process_deleted_functions",
"(",
"self",
")",
":",
"deleted_functions",
"=",
"set",
"(",
"self",
".",
"_registered_functions_map",
".",
"keys",
"(",
")",
")",
".",
"difference",
"(",
"self",
".",
"_functions",
".",
"keys",
"(",
")",
")",
"if",
"de... | [
119,
4
] | [
131,
17
] | python | en | ['en', 'error', 'th'] | False |
FunctionRegistrar._register | (self) |
Регистрация реализованных функций системы
|
Регистрация реализованных функций системы
| def _register(self):
"""
Регистрация реализованных функций системы
"""
self._process_creating_functions()
self._process_updating_functions()
self._process_deleted_functions() | [
"def",
"_register",
"(",
"self",
")",
":",
"self",
".",
"_process_creating_functions",
"(",
")",
"self",
".",
"_process_updating_functions",
"(",
")",
"self",
".",
"_process_deleted_functions",
"(",
")"
] | [
133,
4
] | [
139,
41
] | python | en | ['en', 'error', 'th'] | False |
Node.__init__ | (self, name) | Creates a Node
:arg name: The tag name associated with the node
| Creates a Node | def __init__(self, name):
"""Creates a Node
:arg name: The tag name associated with the node
"""
# The tag name associated with the node
self.name = name
# The parent of the current node (or None for the document node)
self.parent = None
# The value of t... | [
"def",
"__init__",
"(",
"self",
",",
"name",
")",
":",
"# The tag name associated with the node",
"self",
".",
"name",
"=",
"name",
"# The parent of the current node (or None for the document node)",
"self",
".",
"parent",
"=",
"None",
"# The value of the current node (applie... | [
24,
4
] | [
42,
24
] | python | en | ['en', 'gl', 'en'] | True |
Node.appendChild | (self, node) | Insert node as a child of the current node
:arg node: the node to insert
| Insert node as a child of the current node | def appendChild(self, node):
"""Insert node as a child of the current node
:arg node: the node to insert
"""
raise NotImplementedError | [
"def",
"appendChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
56,
4
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertText | (self, data, insertBefore=None) | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
and False if you want to insert it after the node
... | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text. | def insertText(self, data, insertBefore=None):
"""Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"insertBefore",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | [
64,
4
] | [
74,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertBefore | (self, node, refNode) | Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
| Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node | def insertBefore(self, node, refNode):
"""Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
... | [
"def",
"insertBefore",
"(",
"self",
",",
"node",
",",
"refNode",
")",
":",
"raise",
"NotImplementedError"
] | [
76,
4
] | [
86,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.removeChild | (self, node) | Remove node from the children of the current node
:arg node: the child node to remove
| Remove node from the children of the current node | def removeChild(self, node):
"""Remove node from the children of the current node
:arg node: the child node to remove
"""
raise NotImplementedError | [
"def",
"removeChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
88,
4
] | [
94,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.reparentChildren | (self, newParent) | Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
| Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way | def reparentChildren(self, newParent):
"""Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
"""
# XXX - should... | [
"def",
"reparentChildren",
"(",
"self",
",",
"newParent",
")",
":",
"# XXX - should this method be made more general?",
"for",
"child",
"in",
"self",
".",
"childNodes",
":",
"newParent",
".",
"appendChild",
"(",
"child",
")",
"self",
".",
"childNodes",
"=",
"[",
... | [
96,
4
] | [
107,
28
] | python | en | ['en', 'en', 'en'] | True |
Node.cloneNode | (self) | Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| def cloneNode(self):
"""Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
"""
raise NotImplementedError | [
"def",
"cloneNode",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
109,
4
] | [
113,
33
] | python | en | ['en', 'pt', 'en'] | True |
Node.hasContent | (self) | Return true if the node has children or text, false otherwise
| Return true if the node has children or text, false otherwise
| def hasContent(self):
"""Return true if the node has children or text, false otherwise
"""
raise NotImplementedError | [
"def",
"hasContent",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
115,
4
] | [
118,
33
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.__init__ | (self, namespaceHTMLElements) | Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
| Create a TreeBuilder | def __init__(self, namespaceHTMLElements):
"""Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
"""
if namespaceHTMLElements:
self.defaultNamespace = "http://www.w3.org/1999/xhtml"
else:
self.defaultNamespace = No... | [
"def",
"__init__",
"(",
"self",
",",
"namespaceHTMLElements",
")",
":",
"if",
"namespaceHTMLElements",
":",
"self",
".",
"defaultNamespace",
"=",
"\"http://www.w3.org/1999/xhtml\"",
"else",
":",
"self",
".",
"defaultNamespace",
"=",
"None",
"self",
".",
"reset",
"... | [
171,
4
] | [
181,
20
] | python | en | ['en', 'ro', 'en'] | True |
TreeBuilder.elementInActiveFormattingElements | (self, name) | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | def elementInActiveFormattingElements(self, name):
"""Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false"""
for item in self.activeFormattingElements[::-1]:
# Check for Marker first becau... | [
"def",
"elementInActiveFormattingElements",
"(",
"self",
",",
"name",
")",
":",
"for",
"item",
"in",
"self",
".",
"activeFormattingElements",
"[",
":",
":",
"-",
"1",
"]",
":",
"# Check for Marker first because if it's a Marker it doesn't have a",
"# name attribute.",
"... | [
268,
4
] | [
280,
20
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.createElement | (self, token) | Create an element but don't insert it anywhere | Create an element but don't insert it anywhere | def createElement(self, token):
"""Create an element but don't insert it anywhere"""
name = token["name"]
namespace = token.get("namespace", self.defaultNamespace)
element = self.elementClass(name, namespace)
element.attributes = token["data"]
return element | [
"def",
"createElement",
"(",
"self",
",",
"token",
")",
":",
"name",
"=",
"token",
"[",
"\"name\"",
"]",
"namespace",
"=",
"token",
".",
"get",
"(",
"\"namespace\"",
",",
"self",
".",
"defaultNamespace",
")",
"element",
"=",
"self",
".",
"elementClass",
... | [
300,
4
] | [
306,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder._setInsertFromTable | (self, value) | Switch the function used to insert an element from the
normal one to the misnested table one and back again | Switch the function used to insert an element from the
normal one to the misnested table one and back again | def _setInsertFromTable(self, value):
"""Switch the function used to insert an element from the
normal one to the misnested table one and back again"""
self._insertFromTable = value
if value:
self.insertElement = self.insertElementTable
else:
self.insertEl... | [
"def",
"_setInsertFromTable",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_insertFromTable",
"=",
"value",
"if",
"value",
":",
"self",
".",
"insertElement",
"=",
"self",
".",
"insertElementTable",
"else",
":",
"self",
".",
"insertElement",
"=",
"self"... | [
311,
4
] | [
318,
57
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertElementTable | (self, token) | Create an element and insert it into the tree | Create an element and insert it into the tree | def insertElementTable(self, token):
"""Create an element and insert it into the tree"""
element = self.createElement(token)
if self.openElements[-1].name not in tableInsertModeElements:
return self.insertElementNormal(token)
else:
# We should be in the InTable mo... | [
"def",
"insertElementTable",
"(",
"self",
",",
"token",
")",
":",
"element",
"=",
"self",
".",
"createElement",
"(",
"token",
")",
"if",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
".",
"name",
"not",
"in",
"tableInsertModeElements",
":",
"return",
... | [
332,
4
] | [
346,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertText | (self, data, parent=None) | Insert text data. | Insert text data. | def insertText(self, data, parent=None):
"""Insert text data."""
if parent is None:
parent = self.openElements[-1]
if (not self.insertFromTable or (self.insertFromTable and
self.openElements[-1].name
n... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
"if",
"(",
"not",
"self",
".",
"insertFromTable",
"or",
"(",
"se... | [
348,
4
] | [
361,
49
] | python | en | ['fr', 'lb', 'en'] | False |
TreeBuilder.getTableMisnestedNodePosition | (self) | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | def getTableMisnestedNodePosition(self):
"""Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node"""
# The foster parent element is the one which comes before the most
# recently opened table element
# XXX - this is really ine... | [
"def",
"getTableMisnestedNodePosition",
"(",
"self",
")",
":",
"# The foster parent element is the one which comes before the most",
"# recently opened table element",
"# XXX - this is really inelegant",
"lastTable",
"=",
"None",
"fosterParent",
"=",
"None",
"insertBefore",
"=",
"N... | [
363,
4
] | [
387,
41
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.getDocument | (self) | Return the final tree | Return the final tree | def getDocument(self):
"""Return the final tree"""
return self.document | [
"def",
"getDocument",
"(",
"self",
")",
":",
"return",
"self",
".",
"document"
] | [
399,
4
] | [
401,
28
] | python | en | ['en', 'mt', 'en'] | True |
TreeBuilder.getFragment | (self) | Return the final fragment | Return the final fragment | def getFragment(self):
"""Return the final fragment"""
# assert self.innerHTML
fragment = self.fragmentClass()
self.openElements[0].reparentChildren(fragment)
return fragment | [
"def",
"getFragment",
"(",
"self",
")",
":",
"# assert self.innerHTML",
"fragment",
"=",
"self",
".",
"fragmentClass",
"(",
")",
"self",
".",
"openElements",
"[",
"0",
"]",
".",
"reparentChildren",
"(",
"fragment",
")",
"return",
"fragment"
] | [
403,
4
] | [
408,
23
] | python | en | ['en', 'no', 'en'] | True |
TreeBuilder.testSerializer | (self, node) | Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
| Serialize the subtree of node in the format required by unit tests | def testSerializer(self, node):
"""Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
"""
raise NotImplementedError | [
"def",
"testSerializer",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
410,
4
] | [
416,
33
] | python | en | ['en', 'en', 'en'] | True |
Paper.jeeves_restrict_paperlabel | (paper, ctxt) |
Policy for seeing author of papers.
|
Policy for seeing author of papers.
| def jeeves_restrict_paperlabel(paper, ctxt):
'''
Policy for seeing author of papers.
'''
if phase == 'final':
return True
else:
if paper == None:
return False
if PaperPCConflict.objects.get(paper=paper, pc=ctxt) != None:
... | [
"def",
"jeeves_restrict_paperlabel",
"(",
"paper",
",",
"ctxt",
")",
":",
"if",
"phase",
"==",
"'final'",
":",
"return",
"True",
"else",
":",
"if",
"paper",
"==",
"None",
":",
"return",
"False",
"if",
"PaperPCConflict",
".",
"objects",
".",
"get",
"(",
"... | [
75,
4
] | [
91,
84
] | python | en | ['en', 'error', 'th'] | False |
is_url | (name) |
Return true if the name looks like a URL.
|
Return true if the name looks like a URL.
| def is_url(name):
# type: (Union[str, Text]) -> bool
"""
Return true if the name looks like a URL.
"""
scheme = get_url_scheme(name)
if scheme is None:
return False
return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes | [
"def",
"is_url",
"(",
"name",
")",
":",
"# type: (Union[str, Text]) -> bool",
"scheme",
"=",
"get_url_scheme",
"(",
"name",
")",
"if",
"scheme",
"is",
"None",
":",
"return",
"False",
"return",
"scheme",
"in",
"[",
"'http'",
",",
"'https'",
",",
"'file'",
","... | [
55,
0
] | [
63,
71
] | python | en | ['en', 'error', 'th'] | False |
make_vcs_requirement_url | (repo_url, rev, project_name, subdir=None) |
Return the URL for a VCS requirement.
Args:
repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+").
project_name: the (unescaped) project name.
|
Return the URL for a VCS requirement. | def make_vcs_requirement_url(repo_url, rev, project_name, subdir=None):
# type: (str, str, str, Optional[str]) -> str
"""
Return the URL for a VCS requirement.
Args:
repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+").
project_name: the (unescaped) project name.
"""
... | [
"def",
"make_vcs_requirement_url",
"(",
"repo_url",
",",
"rev",
",",
"project_name",
",",
"subdir",
"=",
"None",
")",
":",
"# type: (str, str, str, Optional[str]) -> str",
"egg_project_name",
"=",
"pkg_resources",
".",
"to_filename",
"(",
"project_name",
")",
"req",
"... | [
66,
0
] | [
80,
14
] | python | en | ['en', 'error', 'th'] | False |
call_subprocess | (
cmd, # type: Union[List[str], CommandArgs]
cwd=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
log_failed_cmd=True # type: Optional[bool]
) |
Args:
extra_ok_returncodes: an iterable of integer return codes that are
acceptable, in addition to 0. Defaults to None, which means [].
log_failed_cmd: if false, failed commands are not logged,
only raised.
|
Args:
extra_ok_returncodes: an iterable of integer return codes that are
acceptable, in addition to 0. Defaults to None, which means [].
log_failed_cmd: if false, failed commands are not logged,
only raised.
| def call_subprocess(
cmd, # type: Union[List[str], CommandArgs]
cwd=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
log_failed_cmd=True # type: Optional[bool]
):
# type: (...) -> Text
"""
... | [
"def",
"call_subprocess",
"(",
"cmd",
",",
"# type: Union[List[str], CommandArgs]",
"cwd",
"=",
"None",
",",
"# type: Optional[str]",
"extra_environ",
"=",
"None",
",",
"# type: Optional[Mapping[str, Any]]",
"extra_ok_returncodes",
"=",
"None",
",",
"# type: Optional[Iterable... | [
83,
0
] | [
166,
30
] | python | en | ['en', 'error', 'th'] | False |
find_path_to_setup_from_repo_root | (location, repo_root) |
Find the path to `setup.py` by searching up the filesystem from `location`.
Return the path to `setup.py` relative to `repo_root`.
Return None if `setup.py` is in `repo_root` or cannot be found.
|
Find the path to `setup.py` by searching up the filesystem from `location`.
Return the path to `setup.py` relative to `repo_root`.
Return None if `setup.py` is in `repo_root` or cannot be found.
| def find_path_to_setup_from_repo_root(location, repo_root):
# type: (str, str) -> Optional[str]
"""
Find the path to `setup.py` by searching up the filesystem from `location`.
Return the path to `setup.py` relative to `repo_root`.
Return None if `setup.py` is in `repo_root` or cannot be found.
"... | [
"def",
"find_path_to_setup_from_repo_root",
"(",
"location",
",",
"repo_root",
")",
":",
"# type: (str, str) -> Optional[str]",
"# find setup.py",
"orig_location",
"=",
"location",
"while",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join"... | [
169,
0
] | [
194,
47
] | python | en | ['en', 'error', 'th'] | False |
RevOptions.__init__ | (
self,
vc_class, # type: Type[VersionControl]
rev=None, # type: Optional[str]
extra_args=None, # type: Optional[CommandArgs]
) |
Args:
vc_class: a VersionControl subclass.
rev: the name of the revision to install.
extra_args: a list of extra options.
|
Args:
vc_class: a VersionControl subclass.
rev: the name of the revision to install.
extra_args: a list of extra options.
| def __init__(
self,
vc_class, # type: Type[VersionControl]
rev=None, # type: Optional[str]
extra_args=None, # type: Optional[CommandArgs]
):
# type: (...) -> None
"""
Args:
vc_class: a VersionControl subclass.
rev: the name of the revisi... | [
"def",
"__init__",
"(",
"self",
",",
"vc_class",
",",
"# type: Type[VersionControl]",
"rev",
"=",
"None",
",",
"# type: Optional[str]",
"extra_args",
"=",
"None",
",",
"# type: Optional[CommandArgs]",
")",
":",
"# type: (...) -> None",
"if",
"extra_args",
"is",
"None"... | [
210,
4
] | [
229,
31
] | python | en | ['en', 'error', 'th'] | False |
RevOptions.to_args | (self) |
Return the VCS-specific command arguments.
|
Return the VCS-specific command arguments.
| def to_args(self):
# type: () -> CommandArgs
"""
Return the VCS-specific command arguments.
"""
args = [] # type: CommandArgs
rev = self.arg_rev
if rev is not None:
args += self.vc_class.get_base_rev_args(rev)
args += self.extra_args
... | [
"def",
"to_args",
"(",
"self",
")",
":",
"# type: () -> CommandArgs",
"args",
"=",
"[",
"]",
"# type: CommandArgs",
"rev",
"=",
"self",
".",
"arg_rev",
"if",
"rev",
"is",
"not",
"None",
":",
"args",
"+=",
"self",
".",
"vc_class",
".",
"get_base_rev_args",
... | [
243,
4
] | [
254,
19
] | python | en | ['en', 'error', 'th'] | False |
RevOptions.make_new | (self, rev) |
Make a copy of the current instance, but with a new rev.
Args:
rev: the name of the revision for the new object.
|
Make a copy of the current instance, but with a new rev. | def make_new(self, rev):
# type: (str) -> RevOptions
"""
Make a copy of the current instance, but with a new rev.
Args:
rev: the name of the revision for the new object.
"""
return self.vc_class.make_rev_options(rev, extra_args=self.extra_args) | [
"def",
"make_new",
"(",
"self",
",",
"rev",
")",
":",
"# type: (str) -> RevOptions",
"return",
"self",
".",
"vc_class",
".",
"make_rev_options",
"(",
"rev",
",",
"extra_args",
"=",
"self",
".",
"extra_args",
")"
] | [
263,
4
] | [
271,
78
] | python | en | ['en', 'error', 'th'] | False |
VcsSupport.get_backend_for_dir | (self, location) |
Return a VersionControl object if a repository of that type is found
at the given directory.
|
Return a VersionControl object if a repository of that type is found
at the given directory.
| def get_backend_for_dir(self, location):
# type: (str) -> Optional[VersionControl]
"""
Return a VersionControl object if a repository of that type is found
at the given directory.
"""
vcs_backends = {}
for vcs_backend in self._registry.values():
repo_p... | [
"def",
"get_backend_for_dir",
"(",
"self",
",",
"location",
")",
":",
"# type: (str) -> Optional[VersionControl]",
"vcs_backends",
"=",
"{",
"}",
"for",
"vcs_backend",
"in",
"self",
".",
"_registry",
".",
"values",
"(",
")",
":",
"repo_path",
"=",
"vcs_backend",
... | [
324,
4
] | [
347,
49
] | python | en | ['en', 'error', 'th'] | False |
VcsSupport.get_backend_for_scheme | (self, scheme) |
Return a VersionControl object or None.
|
Return a VersionControl object or None.
| def get_backend_for_scheme(self, scheme):
# type: (str) -> Optional[VersionControl]
"""
Return a VersionControl object or None.
"""
for vcs_backend in self._registry.values():
if scheme in vcs_backend.schemes:
return vcs_backend
return None | [
"def",
"get_backend_for_scheme",
"(",
"self",
",",
"scheme",
")",
":",
"# type: (str) -> Optional[VersionControl]",
"for",
"vcs_backend",
"in",
"self",
".",
"_registry",
".",
"values",
"(",
")",
":",
"if",
"scheme",
"in",
"vcs_backend",
".",
"schemes",
":",
"ret... | [
349,
4
] | [
357,
19
] | python | en | ['en', 'error', 'th'] | False |
VcsSupport.get_backend | (self, name) |
Return a VersionControl object or None.
|
Return a VersionControl object or None.
| def get_backend(self, name):
# type: (str) -> Optional[VersionControl]
"""
Return a VersionControl object or None.
"""
name = name.lower()
return self._registry.get(name) | [
"def",
"get_backend",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> Optional[VersionControl]",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"return",
"self",
".",
"_registry",
".",
"get",
"(",
"name",
")"
] | [
359,
4
] | [
365,
39
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.should_add_vcs_url_prefix | (cls, remote_url) |
Return whether the vcs prefix (e.g. "git+") should be added to a
repository's remote url when used in a requirement.
|
Return whether the vcs prefix (e.g. "git+") should be added to a
repository's remote url when used in a requirement.
| def should_add_vcs_url_prefix(cls, remote_url):
# type: (str) -> bool
"""
Return whether the vcs prefix (e.g. "git+") should be added to a
repository's remote url when used in a requirement.
"""
return not remote_url.lower().startswith('{}:'.format(cls.name)) | [
"def",
"should_add_vcs_url_prefix",
"(",
"cls",
",",
"remote_url",
")",
":",
"# type: (str) -> bool",
"return",
"not",
"remote_url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'{}:'",
".",
"format",
"(",
"cls",
".",
"name",
")",
")"
] | [
382,
4
] | [
388,
72
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_subdirectory | (cls, location) |
Return the path to setup.py, relative to the repo root.
Return None if setup.py is in the repo root.
|
Return the path to setup.py, relative to the repo root.
Return None if setup.py is in the repo root.
| def get_subdirectory(cls, location):
# type: (str) -> Optional[str]
"""
Return the path to setup.py, relative to the repo root.
Return None if setup.py is in the repo root.
"""
return None | [
"def",
"get_subdirectory",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> Optional[str]",
"return",
"None"
] | [
391,
4
] | [
397,
19
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_requirement_revision | (cls, repo_dir) |
Return the revision string that should be used in a requirement.
|
Return the revision string that should be used in a requirement.
| def get_requirement_revision(cls, repo_dir):
# type: (str) -> str
"""
Return the revision string that should be used in a requirement.
"""
return cls.get_revision(repo_dir) | [
"def",
"get_requirement_revision",
"(",
"cls",
",",
"repo_dir",
")",
":",
"# type: (str) -> str",
"return",
"cls",
".",
"get_revision",
"(",
"repo_dir",
")"
] | [
400,
4
] | [
405,
41
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_src_requirement | (cls, repo_dir, project_name) |
Return the requirement string to use to redownload the files
currently at the given repository directory.
Args:
project_name: the (unescaped) project name.
The return value has a form similar to the following:
{repository_url}@{revision}#egg={project_name}
... |
Return the requirement string to use to redownload the files
currently at the given repository directory. | def get_src_requirement(cls, repo_dir, project_name):
# type: (str, str) -> Optional[str]
"""
Return the requirement string to use to redownload the files
currently at the given repository directory.
Args:
project_name: the (unescaped) project name.
The return... | [
"def",
"get_src_requirement",
"(",
"cls",
",",
"repo_dir",
",",
"project_name",
")",
":",
"# type: (str, str) -> Optional[str]",
"repo_url",
"=",
"cls",
".",
"get_remote_url",
"(",
"repo_dir",
")",
"if",
"repo_url",
"is",
"None",
":",
"return",
"None",
"if",
"cl... | [
408,
4
] | [
433,
18
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_base_rev_args | (rev) |
Return the base revision arguments for a vcs command.
Args:
rev: the name of a revision to install. Cannot be None.
|
Return the base revision arguments for a vcs command. | def get_base_rev_args(rev):
# type: (str) -> List[str]
"""
Return the base revision arguments for a vcs command.
Args:
rev: the name of a revision to install. Cannot be None.
"""
raise NotImplementedError | [
"def",
"get_base_rev_args",
"(",
"rev",
")",
":",
"# type: (str) -> List[str]",
"raise",
"NotImplementedError"
] | [
436,
4
] | [
444,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.is_immutable_rev_checkout | (self, url, dest) |
Return true if the commit hash checked out at dest matches
the revision in url.
Always return False, if the VCS does not support immutable commit
hashes.
This method does not check if there are local uncommitted changes
in dest after checkout, as pip currently has no u... |
Return true if the commit hash checked out at dest matches
the revision in url. | def is_immutable_rev_checkout(self, url, dest):
# type: (str, str) -> bool
"""
Return true if the commit hash checked out at dest matches
the revision in url.
Always return False, if the VCS does not support immutable commit
hashes.
This method does not check if... | [
"def",
"is_immutable_rev_checkout",
"(",
"self",
",",
"url",
",",
"dest",
")",
":",
"# type: (str, str) -> bool",
"return",
"False"
] | [
446,
4
] | [
458,
20
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.make_rev_options | (cls, rev=None, extra_args=None) |
Return a RevOptions object.
Args:
rev: the name of a revision to install.
extra_args: a list of extra options.
|
Return a RevOptions object. | def make_rev_options(cls, rev=None, extra_args=None):
# type: (Optional[str], Optional[CommandArgs]) -> RevOptions
"""
Return a RevOptions object.
Args:
rev: the name of a revision to install.
extra_args: a list of extra options.
"""
return RevOptions... | [
"def",
"make_rev_options",
"(",
"cls",
",",
"rev",
"=",
"None",
",",
"extra_args",
"=",
"None",
")",
":",
"# type: (Optional[str], Optional[CommandArgs]) -> RevOptions",
"return",
"RevOptions",
"(",
"cls",
",",
"rev",
",",
"extra_args",
"=",
"extra_args",
")"
] | [
461,
4
] | [
470,
58
] | python | en | ['en', 'error', 'th'] | False |
VersionControl._is_local_repository | (cls, repo) |
posix absolute paths start with os.path.sep,
win32 ones start with drive (like c:\\folder)
|
posix absolute paths start with os.path.sep,
win32 ones start with drive (like c:\\folder)
| def _is_local_repository(cls, repo):
# type: (str) -> bool
"""
posix absolute paths start with os.path.sep,
win32 ones start with drive (like c:\\folder)
"""
drive, tail = os.path.splitdrive(repo)
return repo.startswith(os.path.sep) or bool(drive) | [
"def",
"_is_local_repository",
"(",
"cls",
",",
"repo",
")",
":",
"# type: (str) -> bool",
"drive",
",",
"tail",
"=",
"os",
".",
"path",
".",
"splitdrive",
"(",
"repo",
")",
"return",
"repo",
".",
"startswith",
"(",
"os",
".",
"path",
".",
"sep",
")",
... | [
473,
4
] | [
480,
58
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.export | (self, location, url) |
Export the repository at the url to the destination location
i.e. only download the files, without vcs informations
:param url: the repository URL starting with a vcs prefix.
|
Export the repository at the url to the destination location
i.e. only download the files, without vcs informations | def export(self, location, url):
# type: (str, HiddenText) -> None
"""
Export the repository at the url to the destination location
i.e. only download the files, without vcs informations
:param url: the repository URL starting with a vcs prefix.
"""
raise NotImpl... | [
"def",
"export",
"(",
"self",
",",
"location",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"raise",
"NotImplementedError"
] | [
482,
4
] | [
490,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_netloc_and_auth | (cls, netloc, scheme) |
Parse the repository URL's netloc, and return the new netloc to use
along with auth information.
Args:
netloc: the original repository URL netloc.
scheme: the repository URL's scheme without the vcs prefix.
This is mainly for the Subversion class to override, so th... |
Parse the repository URL's netloc, and return the new netloc to use
along with auth information. | def get_netloc_and_auth(cls, netloc, scheme):
# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]
"""
Parse the repository URL's netloc, and return the new netloc to use
along with auth information.
Args:
netloc: the original repository URL netloc.
... | [
"def",
"get_netloc_and_auth",
"(",
"cls",
",",
"netloc",
",",
"scheme",
")",
":",
"# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]",
"return",
"netloc",
",",
"(",
"None",
",",
"None",
")"
] | [
493,
4
] | [
510,
35
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_url_rev_and_auth | (cls, url) |
Parse the repository URL to use, and return the URL, revision,
and auth info to use.
Returns: (url, rev, (username, password)).
|
Parse the repository URL to use, and return the URL, revision,
and auth info to use. | def get_url_rev_and_auth(cls, url):
# type: (str) -> Tuple[str, Optional[str], AuthInfo]
"""
Parse the repository URL to use, and return the URL, revision,
and auth info to use.
Returns: (url, rev, (username, password)).
"""
scheme, netloc, path, query, frag = ur... | [
"def",
"get_url_rev_and_auth",
"(",
"cls",
",",
"url",
")",
":",
"# type: (str) -> Tuple[str, Optional[str], AuthInfo]",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"frag",
"=",
"urllib_parse",
".",
"urlsplit",
"(",
"url",
")",
"if",
"'+'",
"not",
... | [
513,
4
] | [
541,
34
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.make_rev_args | (username, password) |
Return the RevOptions "extra arguments" to use in obtain().
|
Return the RevOptions "extra arguments" to use in obtain().
| def make_rev_args(username, password):
# type: (Optional[str], Optional[HiddenText]) -> CommandArgs
"""
Return the RevOptions "extra arguments" to use in obtain().
"""
return [] | [
"def",
"make_rev_args",
"(",
"username",
",",
"password",
")",
":",
"# type: (Optional[str], Optional[HiddenText]) -> CommandArgs",
"return",
"[",
"]"
] | [
544,
4
] | [
549,
17
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_url_rev_options | (self, url) |
Return the URL and RevOptions object to use in obtain() and in
some cases export(), as a tuple (url, rev_options).
|
Return the URL and RevOptions object to use in obtain() and in
some cases export(), as a tuple (url, rev_options).
| def get_url_rev_options(self, url):
# type: (HiddenText) -> Tuple[HiddenText, RevOptions]
"""
Return the URL and RevOptions object to use in obtain() and in
some cases export(), as a tuple (url, rev_options).
"""
secret_url, rev, user_pass = self.get_url_rev_and_auth(url.... | [
"def",
"get_url_rev_options",
"(",
"self",
",",
"url",
")",
":",
"# type: (HiddenText) -> Tuple[HiddenText, RevOptions]",
"secret_url",
",",
"rev",
",",
"user_pass",
"=",
"self",
".",
"get_url_rev_and_auth",
"(",
"url",
".",
"secret",
")",
"username",
",",
"secret_p... | [
551,
4
] | [
565,
48
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.normalize_url | (url) |
Normalize a URL for comparison by unquoting it and removing any
trailing slash.
|
Normalize a URL for comparison by unquoting it and removing any
trailing slash.
| def normalize_url(url):
# type: (str) -> str
"""
Normalize a URL for comparison by unquoting it and removing any
trailing slash.
"""
return urllib_parse.unquote(url).rstrip('/') | [
"def",
"normalize_url",
"(",
"url",
")",
":",
"# type: (str) -> str",
"return",
"urllib_parse",
".",
"unquote",
"(",
"url",
")",
".",
"rstrip",
"(",
"'/'",
")"
] | [
568,
4
] | [
574,
52
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.compare_urls | (cls, url1, url2) |
Compare two repo URLs for identity, ignoring incidental differences.
|
Compare two repo URLs for identity, ignoring incidental differences.
| def compare_urls(cls, url1, url2):
# type: (str, str) -> bool
"""
Compare two repo URLs for identity, ignoring incidental differences.
"""
return (cls.normalize_url(url1) == cls.normalize_url(url2)) | [
"def",
"compare_urls",
"(",
"cls",
",",
"url1",
",",
"url2",
")",
":",
"# type: (str, str) -> bool",
"return",
"(",
"cls",
".",
"normalize_url",
"(",
"url1",
")",
"==",
"cls",
".",
"normalize_url",
"(",
"url2",
")",
")"
] | [
577,
4
] | [
582,
67
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.fetch_new | (self, dest, url, rev_options) |
Fetch a revision from a repository, in the case that this is the
first fetch from the repository.
Args:
dest: the directory to fetch the repository to.
rev_options: a RevOptions object.
|
Fetch a revision from a repository, in the case that this is the
first fetch from the repository. | def fetch_new(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
"""
Fetch a revision from a repository, in the case that this is the
first fetch from the repository.
Args:
dest: the directory to fetch the repository to.
rev_options:... | [
"def",
"fetch_new",
"(",
"self",
",",
"dest",
",",
"url",
",",
"rev_options",
")",
":",
"# type: (str, HiddenText, RevOptions) -> None",
"raise",
"NotImplementedError"
] | [
584,
4
] | [
594,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.switch | (self, dest, url, rev_options) |
Switch the repo at ``dest`` to point to ``URL``.
Args:
rev_options: a RevOptions object.
|
Switch the repo at ``dest`` to point to ``URL``. | def switch(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
"""
Switch the repo at ``dest`` to point to ``URL``.
Args:
rev_options: a RevOptions object.
"""
raise NotImplementedError | [
"def",
"switch",
"(",
"self",
",",
"dest",
",",
"url",
",",
"rev_options",
")",
":",
"# type: (str, HiddenText, RevOptions) -> None",
"raise",
"NotImplementedError"
] | [
596,
4
] | [
604,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.update | (self, dest, url, rev_options) |
Update an already-existing repo to the given ``rev_options``.
Args:
rev_options: a RevOptions object.
|
Update an already-existing repo to the given ``rev_options``. | def update(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
"""
Update an already-existing repo to the given ``rev_options``.
Args:
rev_options: a RevOptions object.
"""
raise NotImplementedError | [
"def",
"update",
"(",
"self",
",",
"dest",
",",
"url",
",",
"rev_options",
")",
":",
"# type: (str, HiddenText, RevOptions) -> None",
"raise",
"NotImplementedError"
] | [
606,
4
] | [
614,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.is_commit_id_equal | (cls, dest, name) |
Return whether the id of the current commit equals the given name.
Args:
dest: the repository directory.
name: a string name.
|
Return whether the id of the current commit equals the given name. | def is_commit_id_equal(cls, dest, name):
# type: (str, Optional[str]) -> bool
"""
Return whether the id of the current commit equals the given name.
Args:
dest: the repository directory.
name: a string name.
"""
raise NotImplementedError | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"# type: (str, Optional[str]) -> bool",
"raise",
"NotImplementedError"
] | [
617,
4
] | [
626,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.obtain | (self, dest, url) |
Install or update in editable mode the package represented by this
VersionControl object.
:param dest: the repository directory in which to install or update.
:param url: the repository URL starting with a vcs prefix.
|
Install or update in editable mode the package represented by this
VersionControl object. | def obtain(self, dest, url):
# type: (str, HiddenText) -> None
"""
Install or update in editable mode the package represented by this
VersionControl object.
:param dest: the repository directory in which to install or update.
:param url: the repository URL starting with ... | [
"def",
"obtain",
"(",
"self",
",",
"dest",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"url",
",",
"rev_options",
"=",
"self",
".",
"get_url_rev_options",
"(",
"url",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dest",
")",
":... | [
628,
4
] | [
720,
47
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.unpack | (self, location, url) |
Clean up current location and download the url repository
(and vcs infos) into location
:param url: the repository URL starting with a vcs prefix.
|
Clean up current location and download the url repository
(and vcs infos) into location | def unpack(self, location, url):
# type: (str, HiddenText) -> None
"""
Clean up current location and download the url repository
(and vcs infos) into location
:param url: the repository URL starting with a vcs prefix.
"""
if os.path.exists(location):
... | [
"def",
"unpack",
"(",
"self",
",",
"location",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"location",
")",
":",
"rmtree",
"(",
"location",
")",
"self",
".",
"obtain",
"(",
"location",
",",
"url... | [
722,
4
] | [
732,
38
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_remote_url | (cls, location) |
Return the url used at location
Raises RemoteNotFoundError if the repository does not have a remote
url configured.
|
Return the url used at location | def get_remote_url(cls, location):
# type: (str) -> str
"""
Return the url used at location
Raises RemoteNotFoundError if the repository does not have a remote
url configured.
"""
raise NotImplementedError | [
"def",
"get_remote_url",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> str",
"raise",
"NotImplementedError"
] | [
735,
4
] | [
743,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_revision | (cls, location) |
Return the current commit id of the files at the given location.
|
Return the current commit id of the files at the given location.
| def get_revision(cls, location):
# type: (str) -> str
"""
Return the current commit id of the files at the given location.
"""
raise NotImplementedError | [
"def",
"get_revision",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> str",
"raise",
"NotImplementedError"
] | [
746,
4
] | [
751,
33
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.run_command | (
cls,
cmd, # type: Union[List[str], CommandArgs]
cwd=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
log_failed_cmd=True # type: bool
) |
Run a VCS subcommand
This is simply a wrapper around call_subprocess that adds the VCS
command name, and checks that the VCS is available
|
Run a VCS subcommand
This is simply a wrapper around call_subprocess that adds the VCS
command name, and checks that the VCS is available
| def run_command(
cls,
cmd, # type: Union[List[str], CommandArgs]
cwd=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
log_failed_cmd=True # type: bool
):
# type:... | [
"def",
"run_command",
"(",
"cls",
",",
"cmd",
",",
"# type: Union[List[str], CommandArgs]",
"cwd",
"=",
"None",
",",
"# type: Optional[str]",
"extra_environ",
"=",
"None",
",",
"# type: Optional[Mapping[str, Any]]",
"extra_ok_returncodes",
"=",
"None",
",",
"# type: Optio... | [
754,
4
] | [
783,
21
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.is_repository_directory | (cls, path) |
Return whether a directory path is a repository directory.
|
Return whether a directory path is a repository directory.
| def is_repository_directory(cls, path):
# type: (str) -> bool
"""
Return whether a directory path is a repository directory.
"""
logger.debug('Checking in %s for %s (%s)...',
path, cls.dirname, cls.name)
return os.path.exists(os.path.join(path, cls.di... | [
"def",
"is_repository_directory",
"(",
"cls",
",",
"path",
")",
":",
"# type: (str) -> bool",
"logger",
".",
"debug",
"(",
"'Checking in %s for %s (%s)...'",
",",
"path",
",",
"cls",
".",
"dirname",
",",
"cls",
".",
"name",
")",
"return",
"os",
".",
"path",
... | [
786,
4
] | [
793,
62
] | python | en | ['en', 'error', 'th'] | False |
VersionControl.get_repository_root | (cls, location) |
Return the "root" (top-level) directory controlled by the vcs,
or `None` if the directory is not in any.
It is meant to be overridden to implement smarter detection
mechanisms for specific vcs.
This can do more than is_repository_directory() alone. For
example, the Git... |
Return the "root" (top-level) directory controlled by the vcs,
or `None` if the directory is not in any. | def get_repository_root(cls, location):
# type: (str) -> Optional[str]
"""
Return the "root" (top-level) directory controlled by the vcs,
or `None` if the directory is not in any.
It is meant to be overridden to implement smarter detection
mechanisms for specific vcs.
... | [
"def",
"get_repository_root",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> Optional[str]",
"if",
"cls",
".",
"is_repository_directory",
"(",
"location",
")",
":",
"return",
"location",
"return",
"None"
] | [
796,
4
] | [
810,
19
] | python | en | ['en', 'error', 'th'] | False |
freeze_includes | () |
Returns a list of module names used by py.test that should be
included by cx_freeze.
|
Returns a list of module names used by py.test that should be
included by cx_freeze.
| def freeze_includes():
"""
Returns a list of module names used by py.test that should be
included by cx_freeze.
"""
import py
import _pytest
result = list(_iter_all_modules(py))
result += list(_iter_all_modules(_pytest))
return result | [
"def",
"freeze_includes",
"(",
")",
":",
"import",
"py",
"import",
"_pytest",
"result",
"=",
"list",
"(",
"_iter_all_modules",
"(",
"py",
")",
")",
"result",
"+=",
"list",
"(",
"_iter_all_modules",
"(",
"_pytest",
")",
")",
"return",
"result"
] | [
7,
0
] | [
16,
17
] | python | en | ['en', 'error', 'th'] | False |
_iter_all_modules | (package, prefix='') |
Iterates over the names of all modules that can be found in the given
package, recursively.
Example:
_iter_all_modules(_pytest) ->
['_pytest.assertion.newinterpret',
'_pytest.capture',
'_pytest.core',
...
]
|
Iterates over the names of all modules that can be found in the given
package, recursively.
Example:
_iter_all_modules(_pytest) ->
['_pytest.assertion.newinterpret',
'_pytest.capture',
'_pytest.core',
...
]
| def _iter_all_modules(package, prefix=''):
"""
Iterates over the names of all modules that can be found in the given
package, recursively.
Example:
_iter_all_modules(_pytest) ->
['_pytest.assertion.newinterpret',
'_pytest.capture',
'_pytest.core',
... | [
"def",
"_iter_all_modules",
"(",
"package",
",",
"prefix",
"=",
"''",
")",
":",
"import",
"os",
"import",
"pkgutil",
"if",
"type",
"(",
"package",
")",
"is",
"not",
"str",
":",
"path",
",",
"prefix",
"=",
"package",
".",
"__path__",
"[",
"0",
"]",
",... | [
19,
0
] | [
42,
31
] | python | en | ['en', 'error', 'th'] | False |
get_installed_apps | () |
Generate a list of modules in settings.INSTALLED_APPS.
|
Generate a list of modules in settings.INSTALLED_APPS.
| def get_installed_apps():
"""
Generate a list of modules in settings.INSTALLED_APPS.
"""
out = set()
for app in django_settings.INSTALLED_APPS:
out.add(app)
return out | [
"def",
"get_installed_apps",
"(",
")",
":",
"out",
"=",
"set",
"(",
")",
"for",
"app",
"in",
"django_settings",
".",
"INSTALLED_APPS",
":",
"out",
".",
"add",
"(",
"app",
")",
"return",
"out"
] | [
170,
0
] | [
177,
14
] | python | en | ['en', 'error', 'th'] | False |
get_controllers | () | Returns a list of discovered GameSirController instances. | Returns a list of discovered GameSirController instances. | def get_controllers() -> Sequence[GameSirController]:
"""Returns a list of discovered GameSirController instances."""
controllers = []
for device_path in evdev.list_devices():
try:
controllers.append(GameSirController(device_path))
except ValueError:
pass
return c... | [
"def",
"get_controllers",
"(",
")",
"->",
"Sequence",
"[",
"GameSirController",
"]",
":",
"controllers",
"=",
"[",
"]",
"for",
"device_path",
"in",
"evdev",
".",
"list_devices",
"(",
")",
":",
"try",
":",
"controllers",
".",
"append",
"(",
"GameSirController... | [
64,
0
] | [
72,
22
] | python | en | ['en', 'lb', 'en'] | True |
check_xfail_no_run | (item) | check xfail(run=False) | check xfail(run=False) | def check_xfail_no_run(item):
"""check xfail(run=False)"""
if not item.config.option.runxfail:
evalxfail = item._evalxfail
if evalxfail.istrue():
if not evalxfail.get('run', True):
xfail("[NOTRUN] " + evalxfail.getexplanation()) | [
"def",
"check_xfail_no_run",
"(",
"item",
")",
":",
"if",
"not",
"item",
".",
"config",
".",
"option",
".",
"runxfail",
":",
"evalxfail",
"=",
"item",
".",
"_evalxfail",
"if",
"evalxfail",
".",
"istrue",
"(",
")",
":",
"if",
"not",
"evalxfail",
".",
"g... | [
202,
0
] | [
208,
63
] | python | en | ['en', 'ms', 'en'] | False |
check_strict_xfail | (pyfuncitem) | check xfail(strict=True) for the given PASSING test | check xfail(strict=True) for the given PASSING test | def check_strict_xfail(pyfuncitem):
"""check xfail(strict=True) for the given PASSING test"""
evalxfail = pyfuncitem._evalxfail
if evalxfail.istrue():
strict_default = pyfuncitem.config.getini('xfail_strict')
is_strict_xfail = evalxfail.get('strict', strict_default)
if is_strict_xfai... | [
"def",
"check_strict_xfail",
"(",
"pyfuncitem",
")",
":",
"evalxfail",
"=",
"pyfuncitem",
".",
"_evalxfail",
"if",
"evalxfail",
".",
"istrue",
"(",
")",
":",
"strict_default",
"=",
"pyfuncitem",
".",
"config",
".",
"getini",
"(",
"'xfail_strict'",
")",
"is_str... | [
211,
0
] | [
220,
65
] | python | en | ['en', 'en', 'en'] | True |
register_account | (request) | Account registration.
| Account registration.
| def register_account(request):
"""Account registration.
"""
if request.user.is_authenticated():
return HttpResponseRedirect("index")
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
user = form.save()
print user.usern... | [
"def",
"register_account",
"(",
"request",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"HttpResponseRedirect",
"(",
"\"index\"",
")",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"form",
"=",
"UserCreatio... | [
58,
0
] | [
89,
41
] | python | en | ['en', 'ca', 'en'] | False |
add_to_context | (context_dict, request, template_name, profile, concretize) | Adds relevant arguments to the context.
| Adds relevant arguments to the context.
| def add_to_context(context_dict, request, template_name, profile, concretize):
"""Adds relevant arguments to the context.
"""
template_name = concretize(template_name)
context_dict['concretize'] = concretize
context_dict['profile'] = profile
context_dict['is_logged_in'] = (request.user and
... | [
"def",
"add_to_context",
"(",
"context_dict",
",",
"request",
",",
"template_name",
",",
"profile",
",",
"concretize",
")",
":",
"template_name",
"=",
"concretize",
"(",
"template_name",
")",
"context_dict",
"[",
"'concretize'",
"]",
"=",
"concretize",
"context_di... | [
92,
0
] | [
100,
70
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.