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.open | (self, filename) | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | def open(self, filename):
"""Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor."""
self.filename = filename
self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0 | [
"def",
"open",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"file",
"=",
"io",
".",
"open",
"(",
"self",
".",
"filename",
",",
"'r'",
",",
"errors",
"=",
"self",
".",
"errors",
")",
"self",
".",
"... | [
110,
4
] | [
115,
29
] | python | en | ['en', 'en', 'en'] | True |
TextFile.close | (self) | Close the current file and forget everything we know about it
(filename, current line number). | Close the current file and forget everything we know about it
(filename, current line number). | def close(self):
"""Close the current file and forget everything we know about it
(filename, current line number)."""
file = self.file
self.file = None
self.filename = None
self.current_line = None
file.close() | [
"def",
"close",
"(",
"self",
")",
":",
"file",
"=",
"self",
".",
"file",
"self",
".",
"file",
"=",
"None",
"self",
".",
"filename",
"=",
"None",
"self",
".",
"current_line",
"=",
"None",
"file",
".",
"close",
"(",
")"
] | [
117,
4
] | [
124,
20
] | python | en | ['en', 'en', 'en'] | True |
TextFile.warn | (self, msg, line=None) | Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it overrides
the current line number;... | Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it overrides
the current line number;... | def warn(self, msg, line=None):
"""Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
whole range, eg. "lines 3-5". If 'line' supplied, it ov... | [
"def",
"warn",
"(",
"self",
",",
"msg",
",",
"line",
"=",
"None",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"warning: \"",
"+",
"self",
".",
"gen_error",
"(",
"msg",
",",
"line",
")",
"+",
"\"\\n\"",
")"
] | [
141,
4
] | [
149,
72
] | python | en | ['en', 'en', 'en'] | True |
TextFile.readline | (self) | Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
single string. Updat... | Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
single string. Updat... | def readline(self):
"""Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
may involve reading multiple physical lines concatenated into a
... | [
"def",
"readline",
"(",
"self",
")",
":",
"# If any \"unread\" lines waiting in 'linebuf', return the top",
"# one. (We don't actually buffer read-ahead data -- lines only",
"# get put in 'linebuf' if the client explicitly does an",
"# 'unreadline()'.",
"if",
"self",
".",
"linebuf",
":"... | [
151,
4
] | [
269,
23
] | python | en | ['en', 'en', 'en'] | True |
TextFile.readlines | (self) | Read and return the list of all logical lines remaining in the
current file. | Read and return the list of all logical lines remaining in the
current file. | def readlines(self):
"""Read and return the list of all logical lines remaining in the
current file."""
lines = []
while True:
line = self.readline()
if line is None:
return lines
lines.append(line) | [
"def",
"readlines",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"line",
"is",
"None",
":",
"return",
"lines",
"lines",
".",
"append",
"(",
"line",
")"
] | [
271,
4
] | [
279,
30
] | python | en | ['en', 'en', 'en'] | True |
TextFile.unreadline | (self, line) | Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead. | Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead. | def unreadline(self, line):
"""Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead."""
self.linebuf.append(line) | [
"def",
"unreadline",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"linebuf",
".",
"append",
"(",
"line",
")"
] | [
281,
4
] | [
285,
33
] | python | en | ['en', 'en', 'en'] | True |
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 |
get_oxm | (field_obj) |
Returns an oxm and an arg-dict for updating an arg-list to
simple_tcp_packet
|
Returns an oxm and an arg-dict for updating an arg-list to
simple_tcp_packet
| def get_oxm(field_obj):
"""
Returns an oxm and an arg-dict for updating an arg-list to
simple_tcp_packet
"""
if field_obj.field == "OFPXMT_OFB_VLAN_VID":
return (ofp.oxm.vlan_vid(field_obj.testval),
{"vlan_vid": field_obj.testval, "dl_vlan_enable": True})
elif field_obj.field... | [
"def",
"get_oxm",
"(",
"field_obj",
")",
":",
"if",
"field_obj",
".",
"field",
"==",
"\"OFPXMT_OFB_VLAN_VID\"",
":",
"return",
"(",
"ofp",
".",
"oxm",
".",
"vlan_vid",
"(",
"field_obj",
".",
"testval",
")",
",",
"{",
"\"vlan_vid\"",
":",
"field_obj",
".",
... | [
49,
0
] | [
59,
43
] | python | en | ['en', 'error', 'th'] | False |
get_match | (match_fields) |
Returns a packet and an OXM list that the packet matches,
according to match_fields.
|
Returns a packet and an OXM list that the packet matches,
according to match_fields.
| def get_match(match_fields):
"""
Returns a packet and an OXM list that the packet matches,
according to match_fields.
"""
match, args = ofp.match(), {}
for _, field_obj in match_fields.items():
oxm, pkt_arg = get_oxm(field_obj)
match.oxm_list.append(oxm)
args.update(pkt_a... | [
"def",
"get_match",
"(",
"match_fields",
")",
":",
"match",
",",
"args",
"=",
"ofp",
".",
"match",
"(",
")",
",",
"{",
"}",
"for",
"_",
",",
"field_obj",
"in",
"match_fields",
".",
"items",
"(",
")",
":",
"oxm",
",",
"pkt_arg",
"=",
"get_oxm",
"(",... | [
61,
0
] | [
71,
50
] | python | en | ['en', 'error', 'th'] | False |
get_apply_actions | (actions) |
Returns a 1 element list of APPLY_ACTIONS instructions,
with actions specified in actions.
|
Returns a 1 element list of APPLY_ACTIONS instructions,
with actions specified in actions.
| def get_apply_actions(actions):
"""
Returns a 1 element list of APPLY_ACTIONS instructions,
with actions specified in actions.
"""
instruction = ofp.instruction.apply_actions()
for action, arg in actions.items():
instruction.actions.append(get_action(action, arg))
return [instruction... | [
"def",
"get_apply_actions",
"(",
"actions",
")",
":",
"instruction",
"=",
"ofp",
".",
"instruction",
".",
"apply_actions",
"(",
")",
"for",
"action",
",",
"arg",
"in",
"actions",
".",
"items",
"(",
")",
":",
"instruction",
".",
"actions",
".",
"append",
... | [
83,
0
] | [
91,
24
] | python | en | ['en', 'error', 'th'] | False |
SOCKSConnection._new_conn | (self) |
Establish a new connection via the SOCKS proxy.
|
Establish a new connection via the SOCKS proxy.
| def _new_conn(self):
"""
Establish a new connection via the SOCKS proxy.
"""
extra_kw = {}
if self.source_address:
extra_kw["source_address"] = self.source_address
if self.socket_options:
extra_kw["socket_options"] = self.socket_options
t... | [
"def",
"_new_conn",
"(",
"self",
")",
":",
"extra_kw",
"=",
"{",
"}",
"if",
"self",
".",
"source_address",
":",
"extra_kw",
"[",
"\"source_address\"",
"]",
"=",
"self",
".",
"source_address",
"if",
"self",
".",
"socket_options",
":",
"extra_kw",
"[",
"\"so... | [
83,
4
] | [
139,
19
] | python | en | ['en', 'error', 'th'] | False |
RedirectForm.clean | (self) |
The unique_together condition on the model is ignored if site is None, so need to
check for duplicates manually
|
The unique_together condition on the model is ignored if site is None, so need to
check for duplicates manually
| def clean(self):
"""
The unique_together condition on the model is ignored if site is None, so need to
check for duplicates manually
"""
cleaned_data = super().clean()
if cleaned_data.get('site') is None:
old_path = cleaned_data.get('old_path')
if... | [
"def",
"clean",
"(",
"self",
")",
":",
"cleaned_data",
"=",
"super",
"(",
")",
".",
"clean",
"(",
")",
"if",
"cleaned_data",
".",
"get",
"(",
"'site'",
")",
"is",
"None",
":",
"old_path",
"=",
"cleaned_data",
".",
"get",
"(",
"'old_path'",
")",
"if",... | [
21,
4
] | [
41,
91
] | python | en | ['en', 'error', 'th'] | False |
FeatureRegistry.function_as_entity_handler | (identifier, fn) | Supports legacy registering of entity handlers as functions. | Supports legacy registering of entity handlers as functions. | def function_as_entity_handler(identifier, fn):
"""Supports legacy registering of entity handlers as functions."""
return type('EntityHandlerRegisteredAsFunction', (object,), {
'identifier': identifier,
'expand_db_attributes': staticmethod(fn),
}) | [
"def",
"function_as_entity_handler",
"(",
"identifier",
",",
"fn",
")",
":",
"return",
"type",
"(",
"'EntityHandlerRegisteredAsFunction'",
",",
"(",
"object",
",",
")",
",",
"{",
"'identifier'",
":",
"identifier",
",",
"'expand_db_attributes'",
":",
"staticmethod",
... | [
100,
4
] | [
105,
10
] | python | en | ['en', 'en', 'en'] | True |
install | () | Download chromium if not install. | Download chromium if not install. | def install() -> None:
"""Download chromium if not install."""
if not check_chromium():
download_chromium()
else:
logging.getLogger(__name__).warning('chromium is already installed.') | [
"def",
"install",
"(",
")",
"->",
"None",
":",
"if",
"not",
"check_chromium",
"(",
")",
":",
"download_chromium",
"(",
")",
"else",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"warning",
"(",
"'chromium is already installed.'",
")"
] | [
10,
0
] | [
15,
77
] | python | en | ['en', 'en', 'en'] | True |
clip | (data, mean, sigma, siglow, sighigh, indices=None) | Perform kappa-sigma clipping of data around mean
Args:
data (numpy.ndarray): N-dimensional array of values
mean (float): value around which to clip (does not have to be the mean)
sigma (float): sigma-value for clipping
siglow (float): lower kappa clipping values
sighigh... | Perform kappa-sigma clipping of data around mean | def clip(data, mean, sigma, siglow, sighigh, indices=None):
"""Perform kappa-sigma clipping of data around mean
Args:
data (numpy.ndarray): N-dimensional array of values
mean (float): value around which to clip (does not have to be the mean)
sigma (float): sigma-value for clipping
... | [
"def",
"clip",
"(",
"data",
",",
"mean",
",",
"sigma",
",",
"siglow",
",",
"sighigh",
",",
"indices",
"=",
"None",
")",
":",
"if",
"indices",
"is",
"not",
"None",
":",
"ilow",
"=",
"numpy",
".",
"logical_and",
"(",
"data",
">=",
"mean",
"-",
"sigma... | [
10,
0
] | [
42,
18
] | python | en | ['en', 'en', 'en'] | True |
calcmean | (data, errors=None) | Calculate the mean and the standard deviation of the mean | Calculate the mean and the standard deviation of the mean | def calcmean(data, errors=None):
"""Calculate the mean and the standard deviation of the mean"""
N = len(data)
if errors is None:
mean = data.sum() / N
sigma = numpy.sqrt(((data**2).sum() - N * mean**2) / (N - 1) / N)
else:
w = 1. / errors**2
mean = (w * data).sum() / w.... | [
"def",
"calcmean",
"(",
"data",
",",
"errors",
"=",
"None",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"if",
"errors",
"is",
"None",
":",
"mean",
"=",
"data",
".",
"sum",
"(",
")",
"/",
"N",
"sigma",
"=",
"numpy",
".",
"sqrt",
"(",
"(",
"("... | [
45,
0
] | [
56,
22
] | python | en | ['en', 'en', 'en'] | True |
calcsigma | (data, errors=None, mean=None, axis=None, errors_as_weight=False) | Calculate the sample standard deviation
Args:
data (numpy.ndarray): Data to be averaged. No conversion from
eg a list to a numpy.array is done.
Kwargs:
errors (numpy.ndarray, None): Eerrors for the data. Errors
needs to be the same shape as data (this is different tha... | Calculate the sample standard deviation | def calcsigma(data, errors=None, mean=None, axis=None, errors_as_weight=False):
"""Calculate the sample standard deviation
Args:
data (numpy.ndarray): Data to be averaged. No conversion from
eg a list to a numpy.array is done.
Kwargs:
errors (numpy.ndarray, None): Eerrors for... | [
"def",
"calcsigma",
"(",
"data",
",",
"errors",
"=",
"None",
",",
"mean",
"=",
"None",
",",
"axis",
"=",
"None",
",",
"errors_as_weight",
"=",
"False",
")",
":",
"N",
"=",
"data",
".",
"shape",
"[",
"axis",
"]",
"if",
"axis",
"else",
"len",
"(",
... | [
59,
0
] | [
119,
22
] | python | en | ['en', 'en', 'en'] | True |
sigmaclip | (data, errors=None, niter=0, siglow=3., sighigh=3.,
use_median=False) | Remove outliers from data which lie more than siglow/sighigh
sample standard deviations from mean.
Args:
data (numpy.ndarray): Numpy array containing data values.
Kwargs:
errors (numpy.ndarray, None): Errors associated with the data
values. If None, unweighted mean and standa... | Remove outliers from data which lie more than siglow/sighigh
sample standard deviations from mean. | def sigmaclip(data, errors=None, niter=0, siglow=3., sighigh=3.,
use_median=False):
"""Remove outliers from data which lie more than siglow/sighigh
sample standard deviations from mean.
Args:
data (numpy.ndarray): Numpy array containing data values.
Kwargs:
errors (nump... | [
"def",
"sigmaclip",
"(",
"data",
",",
"errors",
"=",
"None",
",",
"niter",
"=",
"0",
",",
"siglow",
"=",
"3.",
",",
"sighigh",
"=",
"3.",
",",
"use_median",
"=",
"False",
")",
":",
"# indices keeps track which data should be discarded",
"indices",
"=",
"nump... | [
122,
0
] | [
180,
25
] | python | en | ['en', 'en', 'en'] | True |
UserForm.validate_password | (self) |
Run the Django password validators against the new password. This must
be called after the user instance in self.instance is populated with
the new data from the form, as some validators rely on attributes on
the user model.
|
Run the Django password validators against the new password. This must
be called after the user instance in self.instance is populated with
the new data from the form, as some validators rely on attributes on
the user model.
| def validate_password(self):
"""
Run the Django password validators against the new password. This must
be called after the user instance in self.instance is populated with
the new data from the form, as some validators rely on attributes on
the user model.
"""
pa... | [
"def",
"validate_password",
"(",
"self",
")",
":",
"password1",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"password1\"",
")",
"password2",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"password2\"",
")",
"if",
"password1",
"and",
"password... | [
134,
4
] | [
144,
60
] | python | en | ['en', 'error', 'th'] | False |
BaseGroupPagePermissionFormSet.clean | (self) | Checks that no two forms refer to the same page object | Checks that no two forms refer to the same page object | def clean(self):
"""Checks that no two forms refer to the same page object"""
if any(self.errors):
# Don't bother validating the formset unless each form is valid on its own
return
pages = [
form.cleaned_data['page']
for form in self.forms
... | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"any",
"(",
"self",
".",
"errors",
")",
":",
"# Don't bother validating the formset unless each form is valid on its own",
"return",
"pages",
"=",
"[",
"form",
".",
"cleaned_data",
"[",
"'page'",
"]",
"for",
"form",
"... | [
299,
4
] | [
314,
108
] | python | en | ['en', 'en', 'en'] | True |
kml | (request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS) |
This view generates KML for the given app label, model, and field name.
The field name must be that of a geographic field.
|
This view generates KML for the given app label, model, and field name. | def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
"""
This view generates KML for the given app label, model, and field name.
The field name must be that of a geographic field.
"""
placemarks = []
try:
klass = apps.get_model(label, model)
excep... | [
"def",
"kml",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
"=",
"None",
",",
"compress",
"=",
"False",
",",
"using",
"=",
"DEFAULT_DB_ALIAS",
")",
":",
"placemarks",
"=",
"[",
"]",
"try",
":",
"klass",
"=",
"apps",
".",
"get_model",
... | [
11,
0
] | [
55,
67
] | python | en | ['en', 'error', 'th'] | False |
kmz | (request, label, model, field_name=None, using=DEFAULT_DB_ALIAS) |
This view returns KMZ for the given app label, model, and field name.
|
This view returns KMZ for the given app label, model, and field name.
| def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS):
"""
This view returns KMZ for the given app label, model, and field name.
"""
return kml(request, label, model, field_name, compress=True, using=using) | [
"def",
"kmz",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
"=",
"None",
",",
"using",
"=",
"DEFAULT_DB_ALIAS",
")",
":",
"return",
"kml",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
",",
"compress",
"=",
"True",
","... | [
58,
0
] | [
62,
77
] | python | en | ['en', 'error', 'th'] | False |
generate_build_file_contents | (
name: str, dependencies: List[str], whl_file_deps: List[str], pip_data_exclude: List[str],
) | Generate a BUILD file for an unzipped Wheel
Args:
name: the target name of the py_library
dependencies: a list of Bazel labels pointing to dependencies of the library
whl_file_deps: a list of Bazel labels pointing to wheel file dependencies of this wheel.
Returns:
A complete BU... | Generate a BUILD file for an unzipped Wheel | def generate_build_file_contents(
name: str, dependencies: List[str], whl_file_deps: List[str], pip_data_exclude: List[str],
) -> str:
"""Generate a BUILD file for an unzipped Wheel
Args:
name: the target name of the py_library
dependencies: a list of Bazel labels pointing to dependencies o... | [
"def",
"generate_build_file_contents",
"(",
"name",
":",
"str",
",",
"dependencies",
":",
"List",
"[",
"str",
"]",
",",
"whl_file_deps",
":",
"List",
"[",
"str",
"]",
",",
"pip_data_exclude",
":",
"List",
"[",
"str",
"]",
",",
")",
"->",
"str",
":",
"d... | [
14,
0
] | [
61,
5
] | python | en | ['en', 'en', 'en'] | True |
generate_requirements_file_contents | (repo_name: str, targets: Iterable[str]) | Generate a requirements.bzl file for a given pip repository
The file allows converting the PyPI name to a bazel label. Additionally, it adds a function which can glob all the
installed dependencies.
Args:
repo_name: the name of the pip repository
targets: a list of Bazel labels pointing to... | Generate a requirements.bzl file for a given pip repository | def generate_requirements_file_contents(repo_name: str, targets: Iterable[str]) -> str:
"""Generate a requirements.bzl file for a given pip repository
The file allows converting the PyPI name to a bazel label. Additionally, it adds a function which can glob all the
installed dependencies.
Args:
... | [
"def",
"generate_requirements_file_contents",
"(",
"repo_name",
":",
"str",
",",
"targets",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"str",
":",
"sorted_targets",
"=",
"sorted",
"(",
"targets",
")",
"requirement_labels",
"=",
"\",\"",
".",
"join",
"(",
"... | [
64,
0
] | [
103,
5
] | python | en | ['en', 'en', 'en'] | True |
sanitise_name | (name: str, prefix: str = DEFAULT_PACKAGE_PREFIX) | Sanitises the name to be compatible with Bazel labels.
There are certain requirements around Bazel labels that we need to consider. From the Bazel docs:
Package names must be composed entirely of characters drawn from the set A-Z, a–z, 0–9, '/', '-', '.', and '_',
and cannot start with a slash.
... | Sanitises the name to be compatible with Bazel labels. | def sanitise_name(name: str, prefix: str = DEFAULT_PACKAGE_PREFIX) -> str:
"""Sanitises the name to be compatible with Bazel labels.
There are certain requirements around Bazel labels that we need to consider. From the Bazel docs:
Package names must be composed entirely of characters drawn from the se... | [
"def",
"sanitise_name",
"(",
"name",
":",
"str",
",",
"prefix",
":",
"str",
"=",
"DEFAULT_PACKAGE_PREFIX",
")",
"->",
"str",
":",
"return",
"prefix",
"+",
"name",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"_\... | [
116,
0
] | [
133,
68
] | python | en | ['en', 'en', 'en'] | True |
setup_namespace_pkg_compatibility | (wheel_dir: str) | Converts native namespace packages to pkgutil-style packages
Namespace packages can be created in one of three ways. They are detailed here:
https://packaging.python.org/guides/packaging-namespace-packages/#creating-a-namespace-package
'pkgutil-style namespace packages' (2) and 'pkg_resources-style namesp... | Converts native namespace packages to pkgutil-style packages | def setup_namespace_pkg_compatibility(wheel_dir: str) -> None:
"""Converts native namespace packages to pkgutil-style packages
Namespace packages can be created in one of three ways. They are detailed here:
https://packaging.python.org/guides/packaging-namespace-packages/#creating-a-namespace-package
... | [
"def",
"setup_namespace_pkg_compatibility",
"(",
"wheel_dir",
":",
"str",
")",
"->",
"None",
":",
"namespace_pkg_dirs",
"=",
"namespace_pkgs",
".",
"implicit_namespace_packages",
"(",
"wheel_dir",
",",
"ignored_dirnames",
"=",
"[",
"\"%s/bin\"",
"%",
"wheel_dir",
"]",... | [
136,
0
] | [
156,
71
] | python | en | ['en', 'en', 'en'] | True |
extract_wheel | (
wheel_file: str,
extras: Dict[str, Set[str]],
pip_data_exclude: List[str],
enable_implicit_namespace_pkgs: bool,
incremental: bool = False,
incremental_repo_prefix: Optional[str] = None,
) | Extracts wheel into given directory and creates py_library and filegroup targets.
Args:
wheel_file: the filepath of the .whl
extras: a list of extras to add as dependencies for the installed wheel
pip_data_exclude: list of file patterns to exclude from the generated data section of the py_l... | Extracts wheel into given directory and creates py_library and filegroup targets. | def extract_wheel(
wheel_file: str,
extras: Dict[str, Set[str]],
pip_data_exclude: List[str],
enable_implicit_namespace_pkgs: bool,
incremental: bool = False,
incremental_repo_prefix: Optional[str] = None,
) -> str:
"""Extracts wheel into given directory and creates py_library and filegroup ... | [
"def",
"extract_wheel",
"(",
"wheel_file",
":",
"str",
",",
"extras",
":",
"Dict",
"[",
"str",
",",
"Set",
"[",
"str",
"]",
"]",
",",
"pip_data_exclude",
":",
"List",
"[",
"str",
"]",
",",
"enable_implicit_namespace_pkgs",
":",
"bool",
",",
"incremental",
... | [
179,
0
] | [
253,
29
] | python | en | ['en', 'en', 'en'] | True |
TestUserbarTag.test_userbar_tag_self | (self) |
Ensure the userbar renders with `self` instead of `PAGE_TEMPLATE_VAR`
|
Ensure the userbar renders with `self` instead of `PAGE_TEMPLATE_VAR`
| def test_userbar_tag_self(self):
"""
Ensure the userbar renders with `self` instead of `PAGE_TEMPLATE_VAR`
"""
template = Template("{% load wagtailuserbar %}{% wagtailuserbar %}")
content = template.render(Context({
'self': self.homepage,
'request': self.d... | [
"def",
"test_userbar_tag_self",
"(",
"self",
")",
":",
"template",
"=",
"Template",
"(",
"\"{% load wagtailuserbar %}{% wagtailuserbar %}\"",
")",
"content",
"=",
"template",
".",
"render",
"(",
"Context",
"(",
"{",
"'self'",
":",
"self",
".",
"homepage",
",",
"... | [
41,
4
] | [
51,
70
] | python | en | ['en', 'error', 'th'] | False |
defaultStreamOpener | (name) |
This function returns a read-only stream, given its name. The name passed
in should correspond to an existing stream, otherwise an exception will be
raised.
This is the default value of L{streamOpener}; assign your own callable to
streamOpener to return streams based on names. For example, y... |
This function returns a read-only stream, given its name. The name passed
in should correspond to an existing stream, otherwise an exception will be
raised.
This is the default value of L{streamOpener}; assign your own callable to
streamOpener to return streams based on names. For example, y... | def defaultStreamOpener(name):
"""
This function returns a read-only stream, given its name. The name passed
in should correspond to an existing stream, otherwise an exception will be
raised.
This is the default value of L{streamOpener}; assign your own callable to
streamOpener to return... | [
"def",
"defaultStreamOpener",
"(",
"name",
")",
":",
"return",
"ConfigInputStream",
"(",
"file",
"(",
"name",
",",
"'rb'",
")",
")"
] | [
265,
0
] | [
280,
46
] | python | en | ['en', 'ja', 'th'] | False |
isWord | (s) |
See if a passed-in value is an identifier. If the value passed in is not a
string, False is returned. An identifier consists of alphanumerics or
underscore characters.
Examples::
isWord('a word') ->False
isWord('award') -> True
isWord(9) -> False
isWord('a_b_... |
See if a passed-in value is an identifier. If the value passed in is not a
string, False is returned. An identifier consists of alphanumerics or
underscore characters.
Examples::
isWord('a word') ->False
isWord('award') -> True
isWord(9) -> False
isWord('a_b_... | def isWord(s):
"""
See if a passed-in value is an identifier. If the value passed in is not a
string, False is returned. An identifier consists of alphanumerics or
underscore characters.
Examples::
isWord('a word') ->False
isWord('award') -> True
isWord(9) -> Fals... | [
"def",
"isWord",
"(",
"s",
")",
":",
"if",
"type",
"(",
"s",
")",
"!=",
"type",
"(",
"''",
")",
":",
"return",
"False",
"s",
"=",
"s",
".",
"replace",
"(",
"'_'",
",",
"''",
")",
"return",
"s",
".",
"isalnum",
"(",
")"
] | [
304,
0
] | [
328,
22
] | python | en | ['en', 'ja', 'th'] | False |
makePath | (prefix, suffix) |
Make a path from a prefix and suffix.
Examples::
makePath('', 'suffix') -> 'suffix'
makePath('prefix', 'suffix') -> 'prefix.suffix'
makePath('prefix', '[1]') -> 'prefix[1]'
@param prefix: The prefix to use. If it evaluates as false, the suffix
is re... |
Make a path from a prefix and suffix.
Examples::
makePath('', 'suffix') -> 'suffix'
makePath('prefix', 'suffix') -> 'prefix.suffix'
makePath('prefix', '[1]') -> 'prefix[1]'
| def makePath(prefix, suffix):
"""
Make a path from a prefix and suffix.
Examples::
makePath('', 'suffix') -> 'suffix'
makePath('prefix', 'suffix') -> 'prefix.suffix'
makePath('prefix', '[1]') -> 'prefix[1]'
@param prefix: The prefix to use. If it evaluates as false,... | [
"def",
"makePath",
"(",
"prefix",
",",
"suffix",
")",
":",
"if",
"not",
"prefix",
":",
"rv",
"=",
"suffix",
"elif",
"suffix",
"[",
"0",
"]",
"==",
"'['",
":",
"rv",
"=",
"prefix",
"+",
"suffix",
"else",
":",
"rv",
"=",
"prefix",
"+",
"'.'",
"+",
... | [
330,
0
] | [
357,
13
] | python | en | ['en', 'ja', 'th'] | False |
defaultMergeResolve | (map1, map2, key) |
A default resolver for merge conflicts. Returns a string
indicating what action to take to resolve the conflict.
@param map1: The map being merged into.
@type map1: L{Mapping}.
@param map2: The map being used as the merge operand.
@type map2: L{Mapping}.
@param key: The key in map2... |
A default resolver for merge conflicts. Returns a string
indicating what action to take to resolve the conflict.
| def defaultMergeResolve(map1, map2, key):
"""
A default resolver for merge conflicts. Returns a string
indicating what action to take to resolve the conflict.
@param map1: The map being merged into.
@type map1: L{Mapping}.
@param map2: The map being used as the merge operand.
@type ... | [
"def",
"defaultMergeResolve",
"(",
"map1",
",",
"map2",
",",
"key",
")",
":",
"obj1",
"=",
"map1",
"[",
"key",
"]",
"obj2",
"=",
"map2",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"obj1",
",",
"Mapping",
")",
"and",
"isinstance",
"(",
"obj2",
",",
"... | [
1505,
0
] | [
1531,
13
] | python | en | ['en', 'ja', 'th'] | False |
overwriteMergeResolve | (map1, map2, key) |
An overwriting resolver for merge conflicts. Calls L{defaultMergeResolve},
but where a "mismatch" is detected, returns "overwrite" instead.
@param map1: The map being merged into.
@type map1: L{Mapping}.
@param map2: The map being used as the merge operand.
@type map2: L{Mapping}.
... |
An overwriting resolver for merge conflicts. Calls L{defaultMergeResolve},
but where a "mismatch" is detected, returns "overwrite" instead.
| def overwriteMergeResolve(map1, map2, key):
"""
An overwriting resolver for merge conflicts. Calls L{defaultMergeResolve},
but where a "mismatch" is detected, returns "overwrite" instead.
@param map1: The map being merged into.
@type map1: L{Mapping}.
@param map2: The map being used as t... | [
"def",
"overwriteMergeResolve",
"(",
"map1",
",",
"map2",
",",
"key",
")",
":",
"rv",
"=",
"defaultMergeResolve",
"(",
"map1",
",",
"map2",
",",
"key",
")",
"if",
"rv",
"==",
"\"mismatch\"",
":",
"rv",
"=",
"\"overwrite\"",
"return",
"rv"
] | [
1533,
0
] | [
1548,
13
] | python | en | ['en', 'ja', 'th'] | False |
ConfigInputStream.__init__ | (self, stream) |
Initialize an instance.
@param stream: The underlying stream to be read. Should be seekable.
@type stream: A stream (file-like object).
|
Initialize an instance.
| def __init__(self, stream):
"""
Initialize an instance.
@param stream: The underlying stream to be read. Should be seekable.
@type stream: A stream (file-like object).
"""
encoding = None
signature = stream.read(4)
used = -1
if has_utf32... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
")",
":",
"encoding",
"=",
"None",
"signature",
"=",
"stream",
".",
"read",
"(",
"4",
")",
"used",
"=",
"-",
"1",
"if",
"has_utf32",
":",
"if",
"signature",
"==",
"codecs",
".",
"BOM_UTF32_LE",
":",
"enc... | [
158,
4
] | [
191,
32
] | python | en | ['en', 'ja', 'th'] | False |
ConfigOutputStream.__init__ | (self, stream, encoding=None) |
Initialize an instance.
@param stream: The underlying stream to be written.
@type stream: A stream (file-like object).
@param encoding: The desired encoding.
@type encoding: str
|
Initialize an instance.
| def __init__(self, stream, encoding=None):
"""
Initialize an instance.
@param stream: The underlying stream to be written.
@type stream: A stream (file-like object).
@param encoding: The desired encoding.
@type encoding: str
"""
if encoding is no... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"not",
"None",
":",
"encoding",
"=",
"str",
"(",
"encoding",
")",
".",
"lower",
"(",
")",
"self",
".",
"encoding",
"=",
"encoding",
"if",
... | [
228,
4
] | [
254,
28
] | python | en | ['en', 'ja', 'th'] | False |
Container.__init__ | (self, parent) |
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
|
Initialize an instance.
| def __init__(self, parent):
"""
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
"""
object.__setattr__(self, 'parent', parent) | [
"def",
"__init__",
"(",
"self",
",",
"parent",
")",
":",
"object",
".",
"__setattr__",
"(",
"self",
",",
"'parent'",
",",
"parent",
")"
] | [
371,
4
] | [
378,
50
] | python | en | ['en', 'ja', 'th'] | False |
Container.setPath | (self, path) |
Set the path for this instance.
@param path: The path - a string which describes how to get
to this instance from the root of the hierarchy.
@type path: str
|
Set the path for this instance.
| def setPath(self, path):
"""
Set the path for this instance.
@param path: The path - a string which describes how to get
to this instance from the root of the hierarchy.
@type path: str
"""
object.__setattr__(self, 'path', path) | [
"def",
"setPath",
"(",
"self",
",",
"path",
")",
":",
"object",
".",
"__setattr__",
"(",
"self",
",",
"'path'",
",",
"path",
")"
] | [
380,
4
] | [
387,
46
] | python | en | ['en', 'ja', 'th'] | False |
Container.evaluate | (self, item) |
Evaluate items which are instances of L{Reference} or L{Expression}.
L{Reference} instances are evaluated using L{Reference.resolve},
and L{Expression} instances are evaluated using
L{Expression.evaluate}.
@param item: The item to be evaluated.
@type item: any
... |
Evaluate items which are instances of L{Reference} or L{Expression}.
L{Reference} instances are evaluated using L{Reference.resolve},
and L{Expression} instances are evaluated using
L{Expression.evaluate}.
| def evaluate(self, item):
"""
Evaluate items which are instances of L{Reference} or L{Expression}.
L{Reference} instances are evaluated using L{Reference.resolve},
and L{Expression} instances are evaluated using
L{Expression.evaluate}.
@param item: The item to b... | [
"def",
"evaluate",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"Reference",
")",
":",
"item",
"=",
"item",
".",
"resolve",
"(",
"self",
")",
"elif",
"isinstance",
"(",
"item",
",",
"Expression",
")",
":",
"item",
"=",
... | [
389,
4
] | [
407,
19
] | python | en | ['en', 'ja', 'th'] | False |
Container.writeToStream | (self, stream, indent, container) |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent: The indentation level
@type indent: int
@para... |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
| def writeToStream(self, stream, indent, container):
"""
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent:... | [
"def",
"writeToStream",
"(",
"self",
",",
"stream",
",",
"indent",
",",
"container",
")",
":",
"raise",
"NotImplementedError"
] | [
409,
4
] | [
423,
33
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.__init__ | (self, parent=None) |
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
|
Initialize an instance.
| def __init__(self, parent=None):
"""
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
"""
Container.__init__(self, parent)
object.__setattr__(self, 'path', '')
object.__se... | [
"def",
"__init__",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"Container",
".",
"__init__",
"(",
"self",
",",
"parent",
")",
"object",
".",
"__setattr__",
"(",
"self",
",",
"'path'",
",",
"''",
")",
"object",
".",
"__setattr__",
"(",
"self",
... | [
442,
4
] | [
453,
48
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.__delitem__ | (self, key) |
Remove an item
|
Remove an item
| def __delitem__(self, key):
"""
Remove an item
"""
data = object.__getattribute__(self, 'data')
if key not in data:
raise AttributeError(key)
order = object.__getattribute__(self, 'order')
comments = object.__getattribute__(self, 'comments')
... | [
"def",
"__delitem__",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'data'",
")",
"if",
"key",
"not",
"in",
"data",
":",
"raise",
"AttributeError",
"(",
"key",
")",
"order",
"=",
"object",
".",
... | [
455,
4
] | [
466,
25
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.addMapping | (self, key, value, comment, setting=False) |
Add a key-value mapping with a comment.
@param key: The key for the mapping.
@type key: str
@param value: The value for the mapping.
@type value: any
@param comment: The comment for the key (can be None).
@type comment: str
@param setting: If Tr... |
Add a key-value mapping with a comment.
| def addMapping(self, key, value, comment, setting=False):
"""
Add a key-value mapping with a comment.
@param key: The key for the mapping.
@type key: str
@param value: The value for the mapping.
@type value: any
@param comment: The comment for the key (ca... | [
"def",
"addMapping",
"(",
"self",
",",
"key",
",",
"value",
",",
"comment",
",",
"setting",
"=",
"False",
")",
":",
"data",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'data'",
")",
"order",
"=",
"object",
".",
"__getattribute__",
"(",
"... | [
503,
4
] | [
527,
31
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.keys | (self) |
Return the keys in a similar way to a dictionary.
|
Return the keys in a similar way to a dictionary.
| def keys(self):
"""
Return the keys in a similar way to a dictionary.
"""
return object.__getattribute__(self, 'order') | [
"def",
"keys",
"(",
"self",
")",
":",
"return",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'order'",
")"
] | [
534,
4
] | [
538,
53
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.get | (self, key, default=None) |
Allows a dictionary-style get operation.
|
Allows a dictionary-style get operation.
| def get(self, key, default=None):
"""
Allows a dictionary-style get operation.
"""
if key in self:
return self[key]
return default | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"return",
"default"
] | [
540,
4
] | [
546,
22
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.writeToStream | (self, stream, indent, container) |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent: The indentation level
@type indent: int
@para... |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
| def writeToStream(self, stream, indent, container):
"""
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent:... | [
"def",
"writeToStream",
"(",
"self",
",",
"stream",
",",
"indent",
",",
"container",
")",
":",
"indstr",
"=",
"indent",
"*",
"' '",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"stream",
".",
"write",
"(",
"' { }%s'",
"%",
"NEWLINE",
")",
"else",
... | [
564,
4
] | [
585,
53
] | python | en | ['en', 'ja', 'th'] | False |
Mapping.save | (self, stream, indent=0) |
Save this configuration to the specified stream.
@param stream: A stream to which the configuration is written.
@type stream: A write-only stream (file-like object).
@param indent: The indentation level for the output.
@type indent: int
|
Save this configuration to the specified stream.
| def save(self, stream, indent=0):
"""
Save this configuration to the specified stream.
@param stream: A stream to which the configuration is written.
@type stream: A write-only stream (file-like object).
@param indent: The indentation level for the output.
@type ind... | [
"def",
"save",
"(",
"self",
",",
"stream",
",",
"indent",
"=",
"0",
")",
":",
"indstr",
"=",
"indent",
"*",
"' '",
"order",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'order'",
")",
"data",
"=",
"object",
".",
"__getattribute__",
"(",
... | [
587,
4
] | [
612,
54
] | python | en | ['en', 'ja', 'th'] | False |
Config.__init__ | (self, streamOrFile=None, parent=None) |
Initializes an instance.
@param streamOrFile: If specified, causes this instance to be loaded
from the stream (by calling L{load}). If a string is provided, it is
passed to L{streamOpener} to open a stream. Otherwise, the passed
value is assumed to be a stream and used as... |
Initializes an instance.
| def __init__(self, streamOrFile=None, parent=None):
"""
Initializes an instance.
@param streamOrFile: If specified, causes this instance to be loaded
from the stream (by calling L{load}). If a string is provided, it is
passed to L{streamOpener} to open a stream. Otherwise,... | [
"def",
"__init__",
"(",
"self",
",",
"streamOrFile",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"Mapping",
".",
"__init__",
"(",
"self",
",",
"parent",
")",
"object",
".",
"__setattr__",
"(",
"self",
",",
"'reader'",
",",
"ConfigReader",
"(",
"... | [
633,
4
] | [
657,
30
] | python | en | ['en', 'ja', 'th'] | False |
Config.load | (self, stream) |
Load the configuration from the specified stream. Multiple streams can
be used to populate the same instance, as long as there are no
clashing keys. The stream is closed.
@param stream: A stream from which the configuration is read.
@type stream: A read-only stream (file-li... |
Load the configuration from the specified stream. Multiple streams can
be used to populate the same instance, as long as there are no
clashing keys. The stream is closed.
| def load(self, stream):
"""
Load the configuration from the specified stream. Multiple streams can
be used to populate the same instance, as long as there are no
clashing keys. The stream is closed.
@param stream: A stream from which the configuration is read.
@type... | [
"def",
"load",
"(",
"self",
",",
"stream",
")",
":",
"reader",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'reader'",
")",
"#object.__setattr__(self, 'root', reader.load(stream))\r",
"reader",
".",
"load",
"(",
"stream",
")",
"stream",
".",
"close... | [
659,
4
] | [
673,
22
] | python | en | ['en', 'ja', 'th'] | False |
Config.addNamespace | (self, ns, name=None) |
Add a namespace to this configuration which can be used to evaluate
(resolve) dotted-identifier expressions.
@param ns: The namespace to be added.
@type ns: A module or other namespace suitable for passing as an
argument to vars().
@param name: A name for the names... |
Add a namespace to this configuration which can be used to evaluate
(resolve) dotted-identifier expressions.
| def addNamespace(self, ns, name=None):
"""
Add a namespace to this configuration which can be used to evaluate
(resolve) dotted-identifier expressions.
@param ns: The namespace to be added.
@type ns: A module or other namespace suitable for passing as an
argument to... | [
"def",
"addNamespace",
"(",
"self",
",",
"ns",
",",
"name",
"=",
"None",
")",
":",
"namespaces",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'namespaces'",
")",
"if",
"name",
"is",
"None",
":",
"namespaces",
".",
"append",
"(",
"ns",
")"... | [
675,
4
] | [
690,
44
] | python | en | ['en', 'ja', 'th'] | False |
Config.removeNamespace | (self, ns, name=None) |
Remove a namespace added with L{addNamespace}.
@param ns: The namespace to be removed.
@param name: The name which was specified when L{addNamespace} was
called.
@type name: str
|
Remove a namespace added with L{addNamespace}.
| def removeNamespace(self, ns, name=None):
"""
Remove a namespace added with L{addNamespace}.
@param ns: The namespace to be removed.
@param name: The name which was specified when L{addNamespace} was
called.
@type name: str
"""
namespaces = object.... | [
"def",
"removeNamespace",
"(",
"self",
",",
"ns",
",",
"name",
"=",
"None",
")",
":",
"namespaces",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'namespaces'",
")",
"if",
"name",
"is",
"None",
":",
"namespaces",
".",
"remove",
"(",
"ns",
... | [
692,
4
] | [
704,
40
] | python | en | ['en', 'ja', 'th'] | False |
Config.save | (self, stream, indent=0) |
Save this configuration to the specified stream. The stream is
closed if this is the top-level configuration in the hierarchy.
L{Mapping.save} is called to do all the work.
@param stream: A stream to which the configuration is written.
@type stream: A write-only stream (fil... |
Save this configuration to the specified stream. The stream is
closed if this is the top-level configuration in the hierarchy.
L{Mapping.save} is called to do all the work.
| def save(self, stream, indent=0):
"""
Save this configuration to the specified stream. The stream is
closed if this is the top-level configuration in the hierarchy.
L{Mapping.save} is called to do all the work.
@param stream: A stream to which the configuration is written.
... | [
"def",
"save",
"(",
"self",
",",
"stream",
",",
"indent",
"=",
"0",
")",
":",
"Mapping",
".",
"save",
"(",
"self",
",",
"stream",
",",
"indent",
")",
"if",
"indent",
"==",
"0",
":",
"stream",
".",
"close",
"(",
")"
] | [
706,
4
] | [
718,
26
] | python | en | ['en', 'ja', 'th'] | False |
Config.getByPath | (self, path) |
Obtain a value in the configuration via its path.
@param path: The path of the required value
@type path: str
@return the value at the specified path.
@rtype: any
@raise ConfigError: If the path is invalid
|
Obtain a value in the configuration via its path.
| def getByPath(self, path):
"""
Obtain a value in the configuration via its path.
@param path: The path of the required value
@type path: str
@return the value at the specified path.
@rtype: any
@raise ConfigError: If the path is invalid
"""
... | [
"def",
"getByPath",
"(",
"self",
",",
"path",
")",
":",
"s",
"=",
"'self.'",
"+",
"path",
"try",
":",
"return",
"eval",
"(",
"s",
")",
"except",
"Exception",
",",
"e",
":",
"raise",
"ConfigError",
"(",
"str",
"(",
"e",
")",
")"
] | [
720,
4
] | [
733,
37
] | python | en | ['en', 'ja', 'th'] | False |
Sequence.__init__ | (self, parent=None) |
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
|
Initialize an instance.
| def __init__(self, parent=None):
"""
Initialize an instance.
@param parent: The parent of this instance in the hierarchy.
@type parent: A L{Container} instance.
"""
Container.__init__(self, parent)
object.__setattr__(self, 'data', [])
object.__se... | [
"def",
"__init__",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"Container",
".",
"__init__",
"(",
"self",
",",
"parent",
")",
"object",
".",
"__setattr__",
"(",
"self",
",",
"'data'",
",",
"[",
"]",
")",
"object",
".",
"__setattr__",
"(",
"sel... | [
758,
4
] | [
767,
48
] | python | en | ['en', 'ja', 'th'] | False |
Sequence.append | (self, item, comment) |
Add an item to the sequence.
@param item: The item to add.
@type item: any
@param comment: A comment for the item.
@type comment: str
|
Add an item to the sequence.
| def append(self, item, comment):
"""
Add an item to the sequence.
@param item: The item to add.
@type item: any
@param comment: A comment for the item.
@type comment: str
"""
data = object.__getattribute__(self, 'data')
comments = object... | [
"def",
"append",
"(",
"self",
",",
"item",
",",
"comment",
")",
":",
"data",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'data'",
")",
"comments",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'comments'",
")",
"data",
".",
... | [
769,
4
] | [
781,
32
] | python | en | ['en', 'ja', 'th'] | False |
Sequence.writeToStream | (self, stream, indent, container) |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent: The indentation level
@type indent: int
@para... |
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
| def writeToStream(self, stream, indent, container):
"""
Write this instance to a stream at the specified indentation level.
Should be redefined in subclasses.
@param stream: The stream to write to
@type stream: A writable stream (file-like object)
@param indent:... | [
"def",
"writeToStream",
"(",
"self",
",",
"stream",
",",
"indent",
",",
"container",
")",
":",
"indstr",
"=",
"indent",
"*",
"' '",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"stream",
".",
"write",
"(",
"' [ ]%s'",
"%",
"NEWLINE",
")",
"else",
... | [
811,
4
] | [
832,
53
] | python | en | ['en', 'ja', 'th'] | False |
Sequence.save | (self, stream, indent) |
Save this instance to the specified stream.
@param stream: A stream to which the configuration is written.
@type stream: A write-only stream (file-like object).
@param indent: The indentation level for the output, > 0
@type indent: int
|
Save this instance to the specified stream.
| def save(self, stream, indent):
"""
Save this instance to the specified stream.
@param stream: A stream to which the configuration is written.
@type stream: A write-only stream (file-like object).
@param indent: The indentation level for the output, > 0
@type indent... | [
"def",
"save",
"(",
"self",
",",
"stream",
",",
"indent",
")",
":",
"if",
"indent",
"==",
"0",
":",
"raise",
"ConfigError",
"(",
"\"sequence cannot be saved as a top-level item\"",
")",
"data",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'data'"... | [
834,
4
] | [
855,
54
] | python | en | ['en', 'ja', 'th'] | False |
Reference.__init__ | (self, config, type, ident) |
Initialize an instance.
@param config: The configuration which contains this reference.
@type config: A L{Config} instance.
@param type: The type of reference.
@type type: BACKTICK or DOLLAR
@param ident: The identifier which starts the reference.
@type ... |
Initialize an instance.
| def __init__(self, config, type, ident):
"""
Initialize an instance.
@param config: The configuration which contains this reference.
@type config: A L{Config} instance.
@param type: The type of reference.
@type type: BACKTICK or DOLLAR
@param ident: The i... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"type",
",",
"ident",
")",
":",
"self",
".",
"config",
"=",
"config",
"self",
".",
"type",
"=",
"type",
"self",
".",
"elements",
"=",
"[",
"ident",
"]"
] | [
861,
4
] | [
874,
31
] | python | en | ['en', 'ja', 'th'] | False |
Reference.addElement | (self, type, ident) |
Add an element to the reference.
@param type: The type of reference.
@type type: BACKTICK or DOLLAR
@param ident: The identifier which continues the reference.
@type ident: str
|
Add an element to the reference.
| def addElement(self, type, ident):
"""
Add an element to the reference.
@param type: The type of reference.
@type type: BACKTICK or DOLLAR
@param ident: The identifier which continues the reference.
@type ident: str
"""
self.elements.append((type... | [
"def",
"addElement",
"(",
"self",
",",
"type",
",",
"ident",
")",
":",
"self",
".",
"elements",
".",
"append",
"(",
"(",
"type",
",",
"ident",
")",
")"
] | [
876,
4
] | [
885,
43
] | python | en | ['en', 'ja', 'th'] | False |
Reference.findConfig | (self, container) |
Find the closest enclosing configuration to the specified container.
@param container: The container to start from.
@type container: L{Container}
@return: The closest enclosing configuration, or None.
@rtype: L{Config}
|
Find the closest enclosing configuration to the specified container.
| def findConfig(self, container):
"""
Find the closest enclosing configuration to the specified container.
@param container: The container to start from.
@type container: L{Container}
@return: The closest enclosing configuration, or None.
@rtype: L{Config}
... | [
"def",
"findConfig",
"(",
"self",
",",
"container",
")",
":",
"while",
"(",
"container",
"is",
"not",
"None",
")",
"and",
"not",
"isinstance",
"(",
"container",
",",
"Config",
")",
":",
"container",
"=",
"object",
".",
"__getattribute__",
"(",
"container",... | [
887,
4
] | [
898,
24
] | python | en | ['en', 'ja', 'th'] | False |
Reference.resolve | (self, container) |
Resolve this instance in the context of a container.
@param container: The container to resolve from.
@type container: L{Container}
@return: The resolved value.
@rtype: any
@raise ConfigResolutionError: If resolution fails.
|
Resolve this instance in the context of a container.
| def resolve(self, container):
"""
Resolve this instance in the context of a container.
@param container: The container to resolve from.
@type container: L{Container}
@return: The resolved value.
@rtype: any
@raise ConfigResolutionError: If resolution fail... | [
"def",
"resolve",
"(",
"self",
",",
"container",
")",
":",
"rv",
"=",
"None",
"path",
"=",
"object",
".",
"__getattribute__",
"(",
"container",
",",
"'path'",
")",
"current",
"=",
"self",
".",
"findConfig",
"(",
"container",
")",
"while",
"current",
"is"... | [
900,
4
] | [
955,
17
] | python | en | ['en', 'ja', 'th'] | False |
Expression.__init__ | (self, op, lhs, rhs) |
Initialize an instance.
@param op: the operation expressed in the expression.
@type op: PLUS, MINUS, STAR, SLASH, MOD
@param lhs: the left-hand-side operand of the expression.
@type lhs: any Expression or primary value.
@param rhs: the right-hand-side operand of ... |
Initialize an instance.
| def __init__(self, op, lhs, rhs):
"""
Initialize an instance.
@param op: the operation expressed in the expression.
@type op: PLUS, MINUS, STAR, SLASH, MOD
@param lhs: the left-hand-side operand of the expression.
@type lhs: any Expression or primary value.
... | [
"def",
"__init__",
"(",
"self",
",",
"op",
",",
"lhs",
",",
"rhs",
")",
":",
"self",
".",
"op",
"=",
"op",
"self",
".",
"lhs",
"=",
"lhs",
"self",
".",
"rhs",
"=",
"rhs"
] | [
976,
4
] | [
989,
22
] | python | en | ['en', 'ja', 'th'] | False |
Expression.evaluate | (self, container) |
Evaluate this instance in the context of a container.
@param container: The container to evaluate in from.
@type container: L{Container}
@return: The evaluated value.
@rtype: any
@raise ConfigResolutionError: If evaluation fails.
@raise ZeroDivideError: ... |
Evaluate this instance in the context of a container.
| def evaluate(self, container):
"""
Evaluate this instance in the context of a container.
@param container: The container to evaluate in from.
@type container: L{Container}
@return: The evaluated value.
@rtype: any
@raise ConfigResolutionError: If evaluati... | [
"def",
"evaluate",
"(",
"self",
",",
"container",
")",
":",
"lhs",
"=",
"self",
".",
"lhs",
"if",
"isinstance",
"(",
"lhs",
",",
"Reference",
")",
":",
"lhs",
"=",
"lhs",
".",
"resolve",
"(",
"container",
")",
"elif",
"isinstance",
"(",
"lhs",
",",
... | [
997,
4
] | [
1031,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.location | (self) |
Return the current location (filename, line, column) in the stream
as a string.
Used when printing error messages,
@return: A string representing a location in the stream being read.
@rtype: str
|
Return the current location (filename, line, column) in the stream
as a string.
Used when printing error messages,
| def location(self):
"""
Return the current location (filename, line, column) in the stream
as a string.
Used when printing error messages,
@return: A string representing a location in the stream being read.
@rtype: str
"""
return "%s(%d,%d)" % ... | [
"def",
"location",
"(",
"self",
")",
":",
"return",
"\"%s(%d,%d)\"",
"%",
"(",
"self",
".",
"filename",
",",
"self",
".",
"lineno",
",",
"self",
".",
"colno",
")"
] | [
1056,
4
] | [
1066,
69
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.getChar | (self) |
Get the next char from the stream. Update line and column numbers
appropriately.
@return: The next character from the stream.
@rtype: str
|
Get the next char from the stream. Update line and column numbers
appropriately.
| def getChar(self):
"""
Get the next char from the stream. Update line and column numbers
appropriately.
@return: The next character from the stream.
@rtype: str
"""
if self.pbchars:
c = self.pbchars.pop()
else:
c = self.... | [
"def",
"getChar",
"(",
"self",
")",
":",
"if",
"self",
".",
"pbchars",
":",
"c",
"=",
"self",
".",
"pbchars",
".",
"pop",
"(",
")",
"else",
":",
"c",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"1",
")",
"self",
".",
"colno",
"+=",
"1",
"if... | [
1068,
4
] | [
1084,
16
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.getToken | (self) |
Get a token from the stream. String values are returned in a form
where you need to eval() the returned value to get the actual
string. The return value is (token_type, token_value).
Multiline string tokenizing is thanks to David Janes (BlogMatrix)
@return: The next tok... |
Get a token from the stream. String values are returned in a form
where you need to eval() the returned value to get the actual
string. The return value is (token_type, token_value).
Multiline string tokenizing is thanks to David Janes (BlogMatrix)
| def getToken(self):
"""
Get a token from the stream. String values are returned in a form
where you need to eval() the returned value to get the actual
string. The return value is (token_type, token_value).
Multiline string tokenizing is thanks to David Janes (BlogMatrix)
... | [
"def",
"getToken",
"(",
"self",
")",
":",
"if",
"self",
".",
"pbtokens",
":",
"return",
"self",
".",
"pbtokens",
".",
"pop",
"(",
")",
"stream",
"=",
"self",
".",
"stream",
"self",
".",
"comment",
"=",
"None",
"token",
"=",
"''",
"tt",
"=",
"EOF",
... | [
1091,
4
] | [
1207,
26
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.load | (self, stream, parent=None, suffix=None) |
Load the configuration from the specified stream.
@param stream: A stream from which to load the configuration.
@type stream: A stream (file-like object).
@param parent: The parent of the configuration (to which this reader
belongs) in the hierarchy. Specified when the co... |
Load the configuration from the specified stream.
| def load(self, stream, parent=None, suffix=None):
"""
Load the configuration from the specified stream.
@param stream: A stream from which to load the configuration.
@type stream: A stream (file-like object).
@param parent: The parent of the configuration (to which this re... | [
"def",
"load",
"(",
"self",
",",
"stream",
",",
"parent",
"=",
"None",
",",
"suffix",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"not",
"None",
":",
"if",
"suffix",
"is",
"None",
":",
"raise",
"ConfigError",
"(",
"\"internal error: load called with paren... | [
1209,
4
] | [
1232,
101
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.setStream | (self, stream) |
Set the stream to the specified value, and prepare to read from it.
@param stream: A stream from which to load the configuration.
@type stream: A stream (file-like object).
|
Set the stream to the specified value, and prepare to read from it.
| def setStream(self, stream):
"""
Set the stream to the specified value, and prepare to read from it.
@param stream: A stream from which to load the configuration.
@type stream: A stream (file-like object).
"""
self.stream = stream
if hasattr(stream, 'name... | [
"def",
"setStream",
"(",
"self",
",",
"stream",
")",
":",
"self",
".",
"stream",
"=",
"stream",
"if",
"hasattr",
"(",
"stream",
",",
"'name'",
")",
":",
"filename",
"=",
"stream",
".",
"name",
"else",
":",
"filename",
"=",
"'?'",
"self",
".",
"filena... | [
1234,
4
] | [
1248,
22
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.match | (self, t) |
Ensure that the current token type matches the specified value, and
advance to the next token.
@param t: The token type to match.
@type t: A valid token type.
@return: The token which was last read from the stream before this
function is called.
@rtype: ... |
Ensure that the current token type matches the specified value, and
advance to the next token.
| def match(self, t):
"""
Ensure that the current token type matches the specified value, and
advance to the next token.
@param t: The token type to match.
@type t: A valid token type.
@return: The token which was last read from the stream before this
funct... | [
"def",
"match",
"(",
"self",
",",
"t",
")",
":",
"if",
"self",
".",
"token",
"[",
"0",
"]",
"!=",
"t",
":",
"raise",
"ConfigFormatError",
"(",
"\"%s: expecting %s, found %r\"",
"%",
"(",
"self",
".",
"location",
"(",
")",
",",
"t",
",",
"self",
".",
... | [
1250,
4
] | [
1266,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseMappingBody | (self, parent) |
Parse the internals of a mapping, and add entries to the provided
L{Mapping}.
@param parent: The mapping to add entries to.
@type parent: A L{Mapping} instance.
|
Parse the internals of a mapping, and add entries to the provided
L{Mapping}.
| def parseMappingBody(self, parent):
"""
Parse the internals of a mapping, and add entries to the provided
L{Mapping}.
@param parent: The mapping to add entries to.
@type parent: A L{Mapping} instance.
"""
while self.token[0] in [WORD, STRING]:
... | [
"def",
"parseMappingBody",
"(",
"self",
",",
"parent",
")",
":",
"while",
"self",
".",
"token",
"[",
"0",
"]",
"in",
"[",
"WORD",
",",
"STRING",
"]",
":",
"self",
".",
"parseKeyValuePair",
"(",
"parent",
")"
] | [
1268,
4
] | [
1277,
42
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseKeyValuePair | (self, parent) |
Parse a key-value pair, and add it to the provided L{Mapping}.
@param parent: The mapping to add entries to.
@type parent: A L{Mapping} instance.
@raise ConfigFormatError: if a syntax error is found.
|
Parse a key-value pair, and add it to the provided L{Mapping}.
| def parseKeyValuePair(self, parent):
"""
Parse a key-value pair, and add it to the provided L{Mapping}.
@param parent: The mapping to add entries to.
@type parent: A L{Mapping} instance.
@raise ConfigFormatError: if a syntax error is found.
"""
comment = ... | [
"def",
"parseKeyValuePair",
"(",
"self",
",",
"parent",
")",
":",
"comment",
"=",
"self",
".",
"comment",
"tt",
",",
"tv",
"=",
"self",
".",
"token",
"if",
"tt",
"==",
"WORD",
":",
"key",
"=",
"tv",
"suffix",
"=",
"tv",
"elif",
"tt",
"==",
"STRING"... | [
1279,
4
] | [
1316,
40
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseValue | (self, parent, suffix) |
Parse a value.
@param parent: The container to which the value will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: The value
@rtype: any
@raise ConfigFormatError: if a syntax ... |
Parse a value.
| def parseValue(self, parent, suffix):
"""
Parse a value.
@param parent: The container to which the value will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: The value
@rtype: a... | [
"def",
"parseValue",
"(",
"self",
",",
"parent",
",",
"suffix",
")",
":",
"tt",
"=",
"self",
".",
"token",
"[",
"0",
"]",
"if",
"tt",
"in",
"[",
"STRING",
",",
"WORD",
",",
"NUMBER",
",",
"LPAREN",
",",
"DOLLAR",
",",
"TRUE",
",",
"FALSE",
",",
... | [
1318,
4
] | [
1341,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseSequence | (self, parent, suffix) |
Parse a sequence.
@param parent: The container to which the sequence will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: a L{Sequence} instance representing the sequence.
@rtype: L{Seq... |
Parse a sequence.
| def parseSequence(self, parent, suffix):
"""
Parse a sequence.
@param parent: The container to which the sequence will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: a L{Sequence} insta... | [
"def",
"parseSequence",
"(",
"self",
",",
"parent",
",",
"suffix",
")",
":",
"rv",
"=",
"Sequence",
"(",
"parent",
")",
"rv",
".",
"setPath",
"(",
"makePath",
"(",
"object",
".",
"__getattribute__",
"(",
"parent",
",",
"'path'",
")",
",",
"suffix",
")"... | [
1343,
4
] | [
1373,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseMapping | (self, parent, suffix) |
Parse a mapping.
@param parent: The container to which the mapping will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: a L{Mapping} instance representing the mapping.
@rtype: L{Mapping... |
Parse a mapping.
| def parseMapping(self, parent, suffix):
"""
Parse a mapping.
@param parent: The container to which the mapping will be added.
@type parent: A L{Container} instance.
@param suffix: The suffix for the value.
@type suffix: str
@return: a L{Mapping} instance ... | [
"def",
"parseMapping",
"(",
"self",
",",
"parent",
",",
"suffix",
")",
":",
"if",
"self",
".",
"token",
"[",
"0",
"]",
"==",
"LCURLY",
":",
"self",
".",
"match",
"(",
"LCURLY",
")",
"rv",
"=",
"Mapping",
"(",
"parent",
")",
"rv",
".",
"setPath",
... | [
1375,
4
] | [
1398,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseScalar | (self) |
Parse a scalar - a terminal value such as a string or number, or
an L{Expression} or L{Reference}.
@return: the parsed scalar
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
|
Parse a scalar - a terminal value such as a string or number, or
an L{Expression} or L{Reference}.
| def parseScalar(self):
"""
Parse a scalar - a terminal value such as a string or number, or
an L{Expression} or L{Reference}.
@return: the parsed scalar
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
"""
lhs = self.parse... | [
"def",
"parseScalar",
"(",
"self",
")",
":",
"lhs",
"=",
"self",
".",
"parseTerm",
"(",
")",
"tt",
"=",
"self",
".",
"token",
"[",
"0",
"]",
"while",
"tt",
"in",
"[",
"PLUS",
",",
"MINUS",
"]",
":",
"self",
".",
"match",
"(",
"tt",
")",
"rhs",
... | [
1400,
4
] | [
1416,
18
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseTerm | (self) |
Parse a term in an additive expression (a + b, a - b)
@return: the parsed term
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
|
Parse a term in an additive expression (a + b, a - b)
| def parseTerm(self):
"""
Parse a term in an additive expression (a + b, a - b)
@return: the parsed term
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
"""
lhs = self.parseFactor()
tt = self.token[0]
while tt in ... | [
"def",
"parseTerm",
"(",
"self",
")",
":",
"lhs",
"=",
"self",
".",
"parseFactor",
"(",
")",
"tt",
"=",
"self",
".",
"token",
"[",
"0",
"]",
"while",
"tt",
"in",
"[",
"STAR",
",",
"SLASH",
",",
"MOD",
"]",
":",
"self",
".",
"match",
"(",
"tt",
... | [
1418,
4
] | [
1433,
18
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseFactor | (self) |
Parse a factor in an multiplicative expression (a * b, a / b, a % b)
@return: the parsed factor
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
|
Parse a factor in an multiplicative expression (a * b, a / b, a % b)
| def parseFactor(self):
"""
Parse a factor in an multiplicative expression (a * b, a / b, a % b)
@return: the parsed factor
@rtype: any scalar
@raise ConfigFormatError: if a syntax error is found.
"""
tt = self.token[0]
if tt in [NUMBER, WORD, STR... | [
"def",
"parseFactor",
"(",
"self",
")",
":",
"tt",
"=",
"self",
".",
"token",
"[",
"0",
"]",
"if",
"tt",
"in",
"[",
"NUMBER",
",",
"WORD",
",",
"STRING",
",",
"TRUE",
",",
"FALSE",
",",
"NONE",
"]",
":",
"rv",
"=",
"self",
".",
"token",
"[",
... | [
1435,
4
] | [
1466,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseReference | (self, type) |
Parse a reference.
@return: the parsed reference
@rtype: L{Reference}
@raise ConfigFormatError: if a syntax error is found.
|
Parse a reference.
| def parseReference(self, type):
"""
Parse a reference.
@return: the parsed reference
@rtype: L{Reference}
@raise ConfigFormatError: if a syntax error is found.
"""
word = self.match(WORD)
rv = Reference(self.config, type, word[1])
while ... | [
"def",
"parseReference",
"(",
"self",
",",
"type",
")",
":",
"word",
"=",
"self",
".",
"match",
"(",
"WORD",
")",
"rv",
"=",
"Reference",
"(",
"self",
".",
"config",
",",
"type",
",",
"word",
"[",
"1",
"]",
")",
"while",
"self",
".",
"token",
"["... | [
1468,
4
] | [
1480,
17
] | python | en | ['en', 'ja', 'th'] | False |
ConfigReader.parseSuffix | (self, ref) |
Parse a reference suffix.
@param ref: The reference of which this suffix is a part.
@type ref: L{Reference}.
@raise ConfigFormatError: if a syntax error is found.
|
Parse a reference suffix.
| def parseSuffix(self, ref):
"""
Parse a reference suffix.
@param ref: The reference of which this suffix is a part.
@type ref: L{Reference}.
@raise ConfigFormatError: if a syntax error is found.
"""
tt = self.token[0]
if tt == DOT:
s... | [
"def",
"parseSuffix",
"(",
"self",
",",
"ref",
")",
":",
"tt",
"=",
"self",
".",
"token",
"[",
"0",
"]",
"if",
"tt",
"==",
"DOT",
":",
"self",
".",
"match",
"(",
"DOT",
")",
"word",
"=",
"self",
".",
"match",
"(",
"WORD",
")",
"ref",
".",
"ad... | [
1482,
4
] | [
1503,
38
] | python | en | ['en', 'ja', 'th'] | False |
ConfigMerger.__init__ | (self, resolver=defaultMergeResolve) |
Initialise an instance.
@param resolver:
@type resolver: A callable which takes the argument list
(map1, map2, key) where map1 is the mapping being merged into,
map2 is the merge operand and key is the clashing key. The callable
should return a string indicating ... |
Initialise an instance.
| def __init__(self, resolver=defaultMergeResolve):
"""
Initialise an instance.
@param resolver:
@type resolver: A callable which takes the argument list
(map1, map2, key) where map1 is the mapping being merged into,
map2 is the merge operand and key is the clashing... | [
"def",
"__init__",
"(",
"self",
",",
"resolver",
"=",
"defaultMergeResolve",
")",
":",
"self",
".",
"resolver",
"=",
"resolver"
] | [
1559,
4
] | [
1571,
32
] | python | en | ['en', 'ja', 'th'] | False |
ConfigMerger.merge | (self, merged, mergee) |
Merge two configurations. The second configuration is unchanged,
and the first is changed to reflect the results of the merge.
@param merged: The configuration to merge into.
@type merged: L{Config}.
@param mergee: The configuration to merge.
@type mergee: L{Conf... |
Merge two configurations. The second configuration is unchanged,
and the first is changed to reflect the results of the merge.
| def merge(self, merged, mergee):
"""
Merge two configurations. The second configuration is unchanged,
and the first is changed to reflect the results of the merge.
@param merged: The configuration to merge into.
@type merged: L{Config}.
@param mergee: The configur... | [
"def",
"merge",
"(",
"self",
",",
"merged",
",",
"mergee",
")",
":",
"self",
".",
"mergeMapping",
"(",
"merged",
",",
"mergee",
")"
] | [
1573,
4
] | [
1583,
41
] | python | en | ['en', 'ja', 'th'] | False |
ConfigMerger.mergeMapping | (self, map1, map2) |
Merge two mappings recursively. The second mapping is unchanged,
and the first is changed to reflect the results of the merge.
@param map1: The mapping to merge into.
@type map1: L{Mapping}.
@param map2: The mapping to merge.
@type map2: L{Mapping}.
|
Merge two mappings recursively. The second mapping is unchanged,
and the first is changed to reflect the results of the merge.
| def mergeMapping(self, map1, map2):
"""
Merge two mappings recursively. The second mapping is unchanged,
and the first is changed to reflect the results of the merge.
@param map1: The mapping to merge into.
@type map1: L{Mapping}.
@param map2: The mapping to merge... | [
"def",
"mergeMapping",
"(",
"self",
",",
"map1",
",",
"map2",
")",
":",
"keys",
"=",
"map1",
".",
"keys",
"(",
")",
"for",
"key",
"in",
"map2",
".",
"keys",
"(",
")",
":",
"if",
"key",
"not",
"in",
"keys",
":",
"map1",
"[",
"key",
"]",
"=",
"... | [
1585,
4
] | [
1613,
52
] | python | en | ['en', 'ja', 'th'] | False |
ConfigMerger.mergeSequence | (self, seq1, seq2) |
Merge two sequences. The second sequence is unchanged,
and the first is changed to have the elements of the second
appended to it.
@param seq1: The sequence to merge into.
@type seq1: L{Sequence}.
@param seq2: The sequence to merge.
@type seq2: L{Sequenc... |
Merge two sequences. The second sequence is unchanged,
and the first is changed to have the elements of the second
appended to it.
| def mergeSequence(self, seq1, seq2):
"""
Merge two sequences. The second sequence is unchanged,
and the first is changed to have the elements of the second
appended to it.
@param seq1: The sequence to merge into.
@type seq1: L{Sequence}.
@param seq2: The ... | [
"def",
"mergeSequence",
"(",
"self",
",",
"seq1",
",",
"seq2",
")",
":",
"data1",
"=",
"object",
".",
"__getattribute__",
"(",
"seq1",
",",
"'data'",
")",
"data2",
"=",
"object",
".",
"__getattribute__",
"(",
"seq2",
",",
"'data'",
")",
"for",
"obj",
"... | [
1615,
4
] | [
1633,
32
] | python | en | ['en', 'ja', 'th'] | False |
ConfigMerger.handleMismatch | (self, obj1, obj2) |
Handle a mismatch between two objects.
@param obj1: The object to merge into.
@type obj1: any
@param obj2: The object to merge.
@type obj2: any
|
Handle a mismatch between two objects.
| def handleMismatch(self, obj1, obj2):
"""
Handle a mismatch between two objects.
@param obj1: The object to merge into.
@type obj1: any
@param obj2: The object to merge.
@type obj2: any
"""
raise ConfigError("unable to merge %r with %r" % (obj1, ... | [
"def",
"handleMismatch",
"(",
"self",
",",
"obj1",
",",
"obj2",
")",
":",
"raise",
"ConfigError",
"(",
"\"unable to merge %r with %r\"",
"%",
"(",
"obj1",
",",
"obj2",
")",
")"
] | [
1635,
4
] | [
1644,
70
] | python | en | ['en', 'ja', 'th'] | False |
ConfigList.getByPath | (self, path) |
Obtain a value from the first configuration in the list which defines
it.
@param path: The path of the value to retrieve.
@type path: str
@return: The value from the earliest configuration in the list which
defines it.
@rtype: any
@raise ConfigE... |
Obtain a value from the first configuration in the list which defines
it.
| def getByPath(self, path):
"""
Obtain a value from the first configuration in the list which defines
it.
@param path: The path of the value to retrieve.
@type path: str
@return: The value from the earliest configuration in the list which
defines it.
... | [
"def",
"getByPath",
"(",
"self",
",",
"path",
")",
":",
"found",
"=",
"False",
"rv",
"=",
"None",
"for",
"entry",
"in",
"self",
":",
"try",
":",
"rv",
"=",
"entry",
".",
"getByPath",
"(",
"path",
")",
"found",
"=",
"True",
"break",
"except",
"Confi... | [
1653,
4
] | [
1677,
17
] | python | en | ['en', 'ja', 'th'] | False |
TestAuthentication.test_login_view | (self) |
This tests that the login view responds with a login page
|
This tests that the login view responds with a login page
| def test_login_view(self):
"""
This tests that the login view responds with a login page
"""
# Get login page
response = self.client.get(reverse('wagtailadmin_login'))
# Check that the user received a login page
self.assertEqual(response.status_code, 200)
... | [
"def",
"test_login_view",
"(",
"self",
")",
":",
"# Get login page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_login'",
")",
")",
"# Check that the user received a login page",
"self",
".",
"assertEqual",
"(",
"response"... | [
26,
4
] | [
35,
68
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_login_view_post | (self) |
This posts user credentials to the login view and checks that
the user was logged in successfully
|
This posts user credentials to the login view and checks that
the user was logged in successfully
| def test_login_view_post(self):
"""
This posts user credentials to the login view and checks that
the user was logged in successfully
"""
# Create user to log in with
self.create_superuser(username='test', email='test@email.com', password='password')
# Post crede... | [
"def",
"test_login_view_post",
"(",
"self",
")",
":",
"# Create user to log in with",
"self",
".",
"create_superuser",
"(",
"username",
"=",
"'test'",
",",
"email",
"=",
"'test@email.com'",
",",
"password",
"=",
"'password'",
")",
"# Post credentials to the login page",... | [
37,
4
] | [
62,
9
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_already_logged_in_redirect | (self) |
This tests that a user who is already logged in is automatically
redirected to the admin dashboard if they try to access the login
page
|
This tests that a user who is already logged in is automatically
redirected to the admin dashboard if they try to access the login
page
| def test_already_logged_in_redirect(self):
"""
This tests that a user who is already logged in is automatically
redirected to the admin dashboard if they try to access the login
page
"""
# Login
self.login()
# Get login page
response = self.client... | [
"def",
"test_already_logged_in_redirect",
"(",
"self",
")",
":",
"# Login",
"self",
".",
"login",
"(",
")",
"# Get login page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_login'",
")",
")",
"# Check that the user was re... | [
64,
4
] | [
77,
68
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_logged_in_as_non_privileged_user_doesnt_redirect | (self) |
This tests that if the user is logged in but hasn't got permission
to access the admin, they are not redirected to the admin
This tests issue #431
|
This tests that if the user is logged in but hasn't got permission
to access the admin, they are not redirected to the admin | def test_logged_in_as_non_privileged_user_doesnt_redirect(self):
"""
This tests that if the user is logged in but hasn't got permission
to access the admin, they are not redirected to the admin
This tests issue #431
"""
# Login as unprivileged user
self.create_us... | [
"def",
"test_logged_in_as_non_privileged_user_doesnt_redirect",
"(",
"self",
")",
":",
"# Login as unprivileged user",
"self",
".",
"create_user",
"(",
"username",
"=",
"'unprivileged'",
",",
"password",
"=",
"'123'",
")",
"self",
".",
"login",
"(",
"username",
"=",
... | [
79,
4
] | [
95,
68
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_logout | (self) |
This tests that the user can logout
|
This tests that the user can logout
| def test_logout(self):
"""
This tests that the user can logout
"""
# Login
self.login()
# Get logout page
response = self.client.get(reverse('wagtailadmin_logout'))
# Check that the user was redirected to the login page
self.assertRedirects(respo... | [
"def",
"test_logout",
"(",
"self",
")",
":",
"# Login",
"self",
".",
"login",
"(",
")",
"# Get logout page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_logout'",
")",
")",
"# Check that the user was redirected to the lo... | [
97,
4
] | [
111,
64
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_not_logged_in_redirect | (self) |
This tests that a not logged in user is redirected to the
login page
|
This tests that a not logged in user is redirected to the
login page
| def test_not_logged_in_redirect(self):
"""
This tests that a not logged in user is redirected to the
login page
"""
# Get dashboard
response = self.client.get(reverse('wagtailadmin_home'))
# Check that the user was redirected to the login page and that next was s... | [
"def",
"test_not_logged_in_redirect",
"(",
"self",
")",
":",
"# Get dashboard",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_home'",
")",
")",
"# Check that the user was redirected to the login page and that next was set correctly",
... | [
113,
4
] | [
122,
111
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_not_logged_in_gives_403_to_ajax_requests | (self) |
This tests that a not logged in user is given a 403 error on AJAX requests
|
This tests that a not logged in user is given a 403 error on AJAX requests
| def test_not_logged_in_gives_403_to_ajax_requests(self):
"""
This tests that a not logged in user is given a 403 error on AJAX requests
"""
# Get dashboard
response = self.client.get(reverse('wagtailadmin_home'), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# AJAX requests sh... | [
"def",
"test_not_logged_in_gives_403_to_ajax_requests",
"(",
"self",
")",
":",
"# Get dashboard",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_home'",
")",
",",
"HTTP_X_REQUESTED_WITH",
"=",
"'XMLHttpRequest'",
")",
"# AJAX r... | [
124,
4
] | [
132,
51
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_not_logged_in_redirect_default_settings | (self) |
This does the same as the above test but checks that it
redirects to the correct place when the user has not set
the LOGIN_URL setting correctly
|
This does the same as the above test but checks that it
redirects to the correct place when the user has not set
the LOGIN_URL setting correctly
| def test_not_logged_in_redirect_default_settings(self):
"""
This does the same as the above test but checks that it
redirects to the correct place when the user has not set
the LOGIN_URL setting correctly
"""
# Get dashboard with default LOGIN_URL setting
with sel... | [
"def",
"test_not_logged_in_redirect_default_settings",
"(",
"self",
")",
":",
"# Get dashboard with default LOGIN_URL setting",
"with",
"self",
".",
"settings",
"(",
"LOGIN_URL",
"=",
"'django.contrib.auth.views.login'",
")",
":",
"response",
"=",
"self",
".",
"client",
"... | [
134,
4
] | [
148,
111
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_logged_in_no_permission_redirect | (self) |
This tests that a logged in user without admin access permissions is
redirected to the login page, with an error message
|
This tests that a logged in user without admin access permissions is
redirected to the login page, with an error message
| def test_logged_in_no_permission_redirect(self):
"""
This tests that a logged in user without admin access permissions is
redirected to the login page, with an error message
"""
# Login as unprivileged user
self.create_user(username='unprivileged', password='123')
... | [
"def",
"test_logged_in_no_permission_redirect",
"(",
"self",
")",
":",
"# Login as unprivileged user",
"self",
".",
"create_user",
"(",
"username",
"=",
"'unprivileged'",
",",
"password",
"=",
"'123'",
")",
"self",
".",
"login",
"(",
"username",
"=",
"'unprivileged'... | [
150,
4
] | [
164,
87
] | python | en | ['en', 'error', 'th'] | False |
TestAuthentication.test_logged_in_no_permission_gives_403_to_ajax_requests | (self) |
This tests that a logged in user without admin access permissions is
given a 403 error on ajax requests
|
This tests that a logged in user without admin access permissions is
given a 403 error on ajax requests
| def test_logged_in_no_permission_gives_403_to_ajax_requests(self):
"""
This tests that a logged in user without admin access permissions is
given a 403 error on ajax requests
"""
# Login as unprivileged user
self.create_user(username='unprivileged', password='123')
... | [
"def",
"test_logged_in_no_permission_gives_403_to_ajax_requests",
"(",
"self",
")",
":",
"# Login as unprivileged user",
"self",
".",
"create_user",
"(",
"username",
"=",
"'unprivileged'",
",",
"password",
"=",
"'123'",
")",
"self",
".",
"login",
"(",
"username",
"=",... | [
166,
4
] | [
179,
51
] | python | en | ['en', 'error', 'th'] | False |
TestAccountSection.test_account_view | (self) |
This tests that the accounts view responds with an index page
|
This tests that the accounts view responds with an index page
| def test_account_view(self):
"""
This tests that the accounts view responds with an index page
"""
# Get account page
response = self.client.get(reverse('wagtailadmin_account'))
# Check that the user received an account page
self.assertEqual(response.status_code,... | [
"def",
"test_account_view",
"(",
"self",
")",
":",
"# Get account page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_account'",
")",
")",
"# Check that the user received an account page",
"self",
".",
"assertEqual",
"(",
"... | [
220,
4
] | [
246,
62
] | python | en | ['en', 'error', 'th'] | False |
TestAccountUploadAvatar.test_account_view | (self) |
This tests that the account view renders a "Upload a profile picture:" field
|
This tests that the account view renders a "Upload a profile picture:" field
| def test_account_view(self):
"""
This tests that the account view renders a "Upload a profile picture:" field
"""
response = self.client.get(reverse('wagtailadmin_account'))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Upload a profile pictu... | [
"def",
"test_account_view",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_account'",
")",
")",
"self",
".",
"assertEqual",
"(",
"response",
".",
"status_code",
",",
"200",
")",
"self",
".",
... | [
496,
4
] | [
503,
66
] | 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.