repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Loudr/pale | pale/endpoint.py | Endpoint._fix_up_fields | def _fix_up_fields(cls):
"""Add names to all of the Endpoint's Arguments.
This method will get called on class declaration because of
Endpoint's metaclass. The functionality is based on Google's NDB
implementation."""
cls._arguments = dict()
if cls.__module__ == __name_... | python | def _fix_up_fields(cls):
"""Add names to all of the Endpoint's Arguments.
This method will get called on class declaration because of
Endpoint's metaclass. The functionality is based on Google's NDB
implementation."""
cls._arguments = dict()
if cls.__module__ == __name_... | [
"def",
"_fix_up_fields",
"(",
"cls",
")",
":",
"cls",
".",
"_arguments",
"=",
"dict",
"(",
")",
"if",
"cls",
".",
"__module__",
"==",
"__name__",
":",
"# skip the classes in this file",
"return",
"for",
"name",
"in",
"set",
"(",
"dir",
"(",
"cls",
")",
"... | Add names to all of the Endpoint's Arguments.
This method will get called on class declaration because of
Endpoint's metaclass. The functionality is based on Google's NDB
implementation. | [
"Add",
"names",
"to",
"all",
"of",
"the",
"Endpoint",
"s",
"Arguments",
"."
] | dc002ee6032c856551143af222ff8f71ed9853fe | https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L68-L87 | train |
Loudr/pale | pale/endpoint.py | Endpoint._execute | def _execute(self, request, **kwargs):
"""The top-level execute function for the endpoint.
This method is intended to remain as-is, and not be overridden.
It gets called by your HTTP framework's route handler, and performs
the following actions to process the request:
``authent... | python | def _execute(self, request, **kwargs):
"""The top-level execute function for the endpoint.
This method is intended to remain as-is, and not be overridden.
It gets called by your HTTP framework's route handler, and performs
the following actions to process the request:
``authent... | [
"def",
"_execute",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_create_context",
"(",
"request",
")",
"self",
".",
"_authenticate",
"(",
")",
"context",
"=",
"get_current_context",
"(",
")",
"self",
".",
"_... | The top-level execute function for the endpoint.
This method is intended to remain as-is, and not be overridden.
It gets called by your HTTP framework's route handler, and performs
the following actions to process the request:
``authenticate_request``
Validate the Bearer to... | [
"The",
"top",
"-",
"level",
"execute",
"function",
"for",
"the",
"endpoint",
"."
] | dc002ee6032c856551143af222ff8f71ed9853fe | https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L122-L286 | train |
AASHE/python-membersuite-api-client | membersuite_api_client/client.py | ConciergeClient.construct_concierge_header | def construct_concierge_header(self, url):
"""
Constructs the Concierge Request Header lxml object to be used as the
'_soapheaders' argument for WSDL methods.
"""
concierge_request_header = (
etree.Element(
etree.QName(XHTML_NAMESPACE, "ConciergeReques... | python | def construct_concierge_header(self, url):
"""
Constructs the Concierge Request Header lxml object to be used as the
'_soapheaders' argument for WSDL methods.
"""
concierge_request_header = (
etree.Element(
etree.QName(XHTML_NAMESPACE, "ConciergeReques... | [
"def",
"construct_concierge_header",
"(",
"self",
",",
"url",
")",
":",
"concierge_request_header",
"=",
"(",
"etree",
".",
"Element",
"(",
"etree",
".",
"QName",
"(",
"XHTML_NAMESPACE",
",",
"\"ConciergeRequestHeader\"",
")",
",",
"nsmap",
"=",
"{",
"'sch'",
... | Constructs the Concierge Request Header lxml object to be used as the
'_soapheaders' argument for WSDL methods. | [
"Constructs",
"the",
"Concierge",
"Request",
"Header",
"lxml",
"object",
"to",
"be",
"used",
"as",
"the",
"_soapheaders",
"argument",
"for",
"WSDL",
"methods",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/client.py#L65-L96 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | options_string_builder | def options_string_builder(option_mapping, args):
"""Return arguments for CLI invocation of kal."""
options_string = ""
for option, flag in option_mapping.items():
if option in args:
options_string += str(" %s %s" % (flag, str(args[option])))
return options_string | python | def options_string_builder(option_mapping, args):
"""Return arguments for CLI invocation of kal."""
options_string = ""
for option, flag in option_mapping.items():
if option in args:
options_string += str(" %s %s" % (flag, str(args[option])))
return options_string | [
"def",
"options_string_builder",
"(",
"option_mapping",
",",
"args",
")",
":",
"options_string",
"=",
"\"\"",
"for",
"option",
",",
"flag",
"in",
"option_mapping",
".",
"items",
"(",
")",
":",
"if",
"option",
"in",
"args",
":",
"options_string",
"+=",
"str",... | Return arguments for CLI invocation of kal. | [
"Return",
"arguments",
"for",
"CLI",
"invocation",
"of",
"kal",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L6-L12 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | build_kal_scan_band_string | def build_kal_scan_band_string(kal_bin, band, args):
"""Return string for CLI invocation of kal, for band scan."""
option_mapping = {"gain": "-g",
"device": "-d",
"error": "-e"}
if not sanity.scan_band_is_valid(band):
err_txt = "Unsupported band designatio... | python | def build_kal_scan_band_string(kal_bin, band, args):
"""Return string for CLI invocation of kal, for band scan."""
option_mapping = {"gain": "-g",
"device": "-d",
"error": "-e"}
if not sanity.scan_band_is_valid(band):
err_txt = "Unsupported band designatio... | [
"def",
"build_kal_scan_band_string",
"(",
"kal_bin",
",",
"band",
",",
"args",
")",
":",
"option_mapping",
"=",
"{",
"\"gain\"",
":",
"\"-g\"",
",",
"\"device\"",
":",
"\"-d\"",
",",
"\"error\"",
":",
"\"-e\"",
"}",
"if",
"not",
"sanity",
".",
"scan_band_is_... | Return string for CLI invocation of kal, for band scan. | [
"Return",
"string",
"for",
"CLI",
"invocation",
"of",
"kal",
"for",
"band",
"scan",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L15-L25 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | build_kal_scan_channel_string | def build_kal_scan_channel_string(kal_bin, channel, args):
"""Return string for CLI invocation of kal, for channel scan."""
option_mapping = {"gain": "-g",
"device": "-d",
"error": "-e"}
base_string = "%s -v -c %s" % (kal_bin, channel)
base_string += options_s... | python | def build_kal_scan_channel_string(kal_bin, channel, args):
"""Return string for CLI invocation of kal, for channel scan."""
option_mapping = {"gain": "-g",
"device": "-d",
"error": "-e"}
base_string = "%s -v -c %s" % (kal_bin, channel)
base_string += options_s... | [
"def",
"build_kal_scan_channel_string",
"(",
"kal_bin",
",",
"channel",
",",
"args",
")",
":",
"option_mapping",
"=",
"{",
"\"gain\"",
":",
"\"-g\"",
",",
"\"device\"",
":",
"\"-d\"",
",",
"\"error\"",
":",
"\"-e\"",
"}",
"base_string",
"=",
"\"%s -v -c %s\"",
... | Return string for CLI invocation of kal, for channel scan. | [
"Return",
"string",
"for",
"CLI",
"invocation",
"of",
"kal",
"for",
"channel",
"scan",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L28-L35 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | determine_final_freq | def determine_final_freq(base, direction, modifier):
"""Return integer for frequency."""
result = 0
if direction == "+":
result = base + modifier
elif direction == "-":
result = base - modifier
return(result) | python | def determine_final_freq(base, direction, modifier):
"""Return integer for frequency."""
result = 0
if direction == "+":
result = base + modifier
elif direction == "-":
result = base - modifier
return(result) | [
"def",
"determine_final_freq",
"(",
"base",
",",
"direction",
",",
"modifier",
")",
":",
"result",
"=",
"0",
"if",
"direction",
"==",
"\"+\"",
":",
"result",
"=",
"base",
"+",
"modifier",
"elif",
"direction",
"==",
"\"-\"",
":",
"result",
"=",
"base",
"-... | Return integer for frequency. | [
"Return",
"integer",
"for",
"frequency",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L55-L62 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | to_eng | def to_eng(num_in):
"""Return number in engineering notation."""
x = decimal.Decimal(str(num_in))
eng_not = x.normalize().to_eng_string()
return(eng_not) | python | def to_eng(num_in):
"""Return number in engineering notation."""
x = decimal.Decimal(str(num_in))
eng_not = x.normalize().to_eng_string()
return(eng_not) | [
"def",
"to_eng",
"(",
"num_in",
")",
":",
"x",
"=",
"decimal",
".",
"Decimal",
"(",
"str",
"(",
"num_in",
")",
")",
"eng_not",
"=",
"x",
".",
"normalize",
"(",
")",
".",
"to_eng_string",
"(",
")",
"return",
"(",
"eng_not",
")"
] | Return number in engineering notation. | [
"Return",
"number",
"in",
"engineering",
"notation",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L65-L69 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | determine_device | def determine_device(kal_out):
"""Extract and return device from scan results."""
device = ""
while device == "":
for line in kal_out.splitlines():
if "Using device " in line:
device = str(line.split(' ', 2)[-1])
if device == "":
device = None
retu... | python | def determine_device(kal_out):
"""Extract and return device from scan results."""
device = ""
while device == "":
for line in kal_out.splitlines():
if "Using device " in line:
device = str(line.split(' ', 2)[-1])
if device == "":
device = None
retu... | [
"def",
"determine_device",
"(",
"kal_out",
")",
":",
"device",
"=",
"\"\"",
"while",
"device",
"==",
"\"\"",
":",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"\"Using device \"",
"in",
"line",
":",
"device",
"=",
"str",
"(",
... | Extract and return device from scan results. | [
"Extract",
"and",
"return",
"device",
"from",
"scan",
"results",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L81-L90 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | extract_value_from_output | def extract_value_from_output(canary, split_offset, kal_out):
"""Return value parsed from output.
Args:
canary(str): This string must exist in the target line.
split_offset(int): Split offset for target value in string.
kal_out(int): Output from kal.
"""
retval = ""
while re... | python | def extract_value_from_output(canary, split_offset, kal_out):
"""Return value parsed from output.
Args:
canary(str): This string must exist in the target line.
split_offset(int): Split offset for target value in string.
kal_out(int): Output from kal.
"""
retval = ""
while re... | [
"def",
"extract_value_from_output",
"(",
"canary",
",",
"split_offset",
",",
"kal_out",
")",
":",
"retval",
"=",
"\"\"",
"while",
"retval",
"==",
"\"\"",
":",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"canary",
"in",
"line",
... | Return value parsed from output.
Args:
canary(str): This string must exist in the target line.
split_offset(int): Split offset for target value in string.
kal_out(int): Output from kal. | [
"Return",
"value",
"parsed",
"from",
"output",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L103-L118 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | determine_chan_detect_threshold | def determine_chan_detect_threshold(kal_out):
"""Return channel detect threshold from kal output."""
channel_detect_threshold = ""
while channel_detect_threshold == "":
for line in kal_out.splitlines():
if "channel detect threshold: " in line:
channel_detect_threshold = s... | python | def determine_chan_detect_threshold(kal_out):
"""Return channel detect threshold from kal output."""
channel_detect_threshold = ""
while channel_detect_threshold == "":
for line in kal_out.splitlines():
if "channel detect threshold: " in line:
channel_detect_threshold = s... | [
"def",
"determine_chan_detect_threshold",
"(",
"kal_out",
")",
":",
"channel_detect_threshold",
"=",
"\"\"",
"while",
"channel_detect_threshold",
"==",
"\"\"",
":",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"\"channel detect threshold: \"... | Return channel detect threshold from kal output. | [
"Return",
"channel",
"detect",
"threshold",
"from",
"kal",
"output",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L127-L137 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | determine_band_channel | def determine_band_channel(kal_out):
"""Return band, channel, target frequency from kal output."""
band = ""
channel = ""
tgt_freq = ""
while band == "":
for line in kal_out.splitlines():
if "Using " in line and " channel " in line:
band = str(line.split()[1])
... | python | def determine_band_channel(kal_out):
"""Return band, channel, target frequency from kal output."""
band = ""
channel = ""
tgt_freq = ""
while band == "":
for line in kal_out.splitlines():
if "Using " in line and " channel " in line:
band = str(line.split()[1])
... | [
"def",
"determine_band_channel",
"(",
"kal_out",
")",
":",
"band",
"=",
"\"\"",
"channel",
"=",
"\"\"",
"tgt_freq",
"=",
"\"\"",
"while",
"band",
"==",
"\"\"",
":",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"\"Using \"",
"in... | Return band, channel, target frequency from kal output. | [
"Return",
"band",
"channel",
"target",
"frequency",
"from",
"kal",
"output",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L140-L154 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | parse_kal_scan | def parse_kal_scan(kal_out):
"""Parse kal band scan output."""
kal_data = []
scan_band = determine_scan_band(kal_out)
scan_gain = determine_scan_gain(kal_out)
scan_device = determine_device(kal_out)
sample_rate = determine_sample_rate(kal_out)
chan_detect_threshold = determine_chan_detect_th... | python | def parse_kal_scan(kal_out):
"""Parse kal band scan output."""
kal_data = []
scan_band = determine_scan_band(kal_out)
scan_gain = determine_scan_gain(kal_out)
scan_device = determine_device(kal_out)
sample_rate = determine_sample_rate(kal_out)
chan_detect_threshold = determine_chan_detect_th... | [
"def",
"parse_kal_scan",
"(",
"kal_out",
")",
":",
"kal_data",
"=",
"[",
"]",
"scan_band",
"=",
"determine_scan_band",
"(",
"kal_out",
")",
"scan_gain",
"=",
"determine_scan_gain",
"(",
"kal_out",
")",
"scan_device",
"=",
"determine_device",
"(",
"kal_out",
")",... | Parse kal band scan output. | [
"Parse",
"kal",
"band",
"scan",
"output",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L157-L189 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | parse_kal_channel | def parse_kal_channel(kal_out):
"""Parse kal channel scan output."""
scan_band, scan_channel, tgt_freq = determine_band_channel(kal_out)
kal_data = {"device": determine_device(kal_out),
"sample_rate": determine_sample_rate(kal_out),
"gain": determine_scan_gain(kal_out),
... | python | def parse_kal_channel(kal_out):
"""Parse kal channel scan output."""
scan_band, scan_channel, tgt_freq = determine_band_channel(kal_out)
kal_data = {"device": determine_device(kal_out),
"sample_rate": determine_sample_rate(kal_out),
"gain": determine_scan_gain(kal_out),
... | [
"def",
"parse_kal_channel",
"(",
"kal_out",
")",
":",
"scan_band",
",",
"scan_channel",
",",
"tgt_freq",
"=",
"determine_band_channel",
"(",
"kal_out",
")",
"kal_data",
"=",
"{",
"\"device\"",
":",
"determine_device",
"(",
"kal_out",
")",
",",
"\"sample_rate\"",
... | Parse kal channel scan output. | [
"Parse",
"kal",
"channel",
"scan",
"output",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L192-L204 | train |
ashmastaflash/kal-wrapper | kalibrate/fn.py | get_measurements_from_kal_scan | def get_measurements_from_kal_scan(kal_out):
"""Return a list of all measurements from kalibrate channel scan."""
result = []
for line in kal_out.splitlines():
if "offset " in line:
p_line = line.split(' ')
result.append(p_line[-1])
return result | python | def get_measurements_from_kal_scan(kal_out):
"""Return a list of all measurements from kalibrate channel scan."""
result = []
for line in kal_out.splitlines():
if "offset " in line:
p_line = line.split(' ')
result.append(p_line[-1])
return result | [
"def",
"get_measurements_from_kal_scan",
"(",
"kal_out",
")",
":",
"result",
"=",
"[",
"]",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"\"offset \"",
"in",
"line",
":",
"p_line",
"=",
"line",
".",
"split",
"(",
"' '",
")",
... | Return a list of all measurements from kalibrate channel scan. | [
"Return",
"a",
"list",
"of",
"all",
"measurements",
"from",
"kalibrate",
"channel",
"scan",
"."
] | 80ee03ab7bd3172ac26b769d6b442960f3424b0e | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L206-L213 | train |
Loudr/pale | pale/fields/base.py | BaseField.render | def render(self, obj, name, context):
"""The default field renderer.
This basic renderer assumes that the object has an attribute with
the same name as the field, unless a different field is specified
as a `property_name`.
The renderer is also passed the context so that it can ... | python | def render(self, obj, name, context):
"""The default field renderer.
This basic renderer assumes that the object has an attribute with
the same name as the field, unless a different field is specified
as a `property_name`.
The renderer is also passed the context so that it can ... | [
"def",
"render",
"(",
"self",
",",
"obj",
",",
"name",
",",
"context",
")",
":",
"if",
"self",
".",
"value_lambda",
"is",
"not",
"None",
":",
"val",
"=",
"self",
".",
"value_lambda",
"(",
"obj",
")",
"else",
":",
"attr_name",
"=",
"name",
"if",
"se... | The default field renderer.
This basic renderer assumes that the object has an attribute with
the same name as the field, unless a different field is specified
as a `property_name`.
The renderer is also passed the context so that it can be
propagated to the `_render_serializabl... | [
"The",
"default",
"field",
"renderer",
"."
] | dc002ee6032c856551143af222ff8f71ed9853fe | https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/fields/base.py#L58-L93 | train |
Loudr/pale | pale/fields/base.py | BaseField.doc_dict | def doc_dict(self):
"""Generate the documentation for this field."""
doc = {
'type': self.value_type,
'description': self.description,
'extended_description': self.details
}
return doc | python | def doc_dict(self):
"""Generate the documentation for this field."""
doc = {
'type': self.value_type,
'description': self.description,
'extended_description': self.details
}
return doc | [
"def",
"doc_dict",
"(",
"self",
")",
":",
"doc",
"=",
"{",
"'type'",
":",
"self",
".",
"value_type",
",",
"'description'",
":",
"self",
".",
"description",
",",
"'extended_description'",
":",
"self",
".",
"details",
"}",
"return",
"doc"
] | Generate the documentation for this field. | [
"Generate",
"the",
"documentation",
"for",
"this",
"field",
"."
] | dc002ee6032c856551143af222ff8f71ed9853fe | https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/fields/base.py#L96-L103 | train |
a1ezzz/wasp-general | wasp_general/capability.py | WCapabilitiesHolder.capability | def capability(self, cap_name):
""" Return capability by its name
:param cap_name: name of a capability to return
:return: bounded method or None (if a capability is not found)
"""
if cap_name in self.__class_capabilities__:
function_name = self.__class_capabilities__[cap_name]
return getattr(self, fun... | python | def capability(self, cap_name):
""" Return capability by its name
:param cap_name: name of a capability to return
:return: bounded method or None (if a capability is not found)
"""
if cap_name in self.__class_capabilities__:
function_name = self.__class_capabilities__[cap_name]
return getattr(self, fun... | [
"def",
"capability",
"(",
"self",
",",
"cap_name",
")",
":",
"if",
"cap_name",
"in",
"self",
".",
"__class_capabilities__",
":",
"function_name",
"=",
"self",
".",
"__class_capabilities__",
"[",
"cap_name",
"]",
"return",
"getattr",
"(",
"self",
",",
"function... | Return capability by its name
:param cap_name: name of a capability to return
:return: bounded method or None (if a capability is not found) | [
"Return",
"capability",
"by",
"its",
"name"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/capability.py#L100-L108 | train |
a1ezzz/wasp-general | wasp_general/capability.py | WCapabilitiesHolder.has_capabilities | def has_capabilities(self, *cap_names):
""" Check if class has all of the specified capabilities
:param cap_names: capabilities names to check
:return: bool
"""
for name in cap_names:
if name not in self.__class_capabilities__:
return False
return True | python | def has_capabilities(self, *cap_names):
""" Check if class has all of the specified capabilities
:param cap_names: capabilities names to check
:return: bool
"""
for name in cap_names:
if name not in self.__class_capabilities__:
return False
return True | [
"def",
"has_capabilities",
"(",
"self",
",",
"*",
"cap_names",
")",
":",
"for",
"name",
"in",
"cap_names",
":",
"if",
"name",
"not",
"in",
"self",
".",
"__class_capabilities__",
":",
"return",
"False",
"return",
"True"
] | Check if class has all of the specified capabilities
:param cap_names: capabilities names to check
:return: bool | [
"Check",
"if",
"class",
"has",
"all",
"of",
"the",
"specified",
"capabilities"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/capability.py#L111-L121 | train |
projectshift/shift-schema | shiftschema/result.py | Result.add_entity_errors | def add_entity_errors(
self,
property_name,
direct_errors=None,
schema_errors=None
):
"""
Attach nested entity errors
Accepts a list errors coming from validators attached directly,
or a dict of errors produced by a nested schema.
:param prope... | python | def add_entity_errors(
self,
property_name,
direct_errors=None,
schema_errors=None
):
"""
Attach nested entity errors
Accepts a list errors coming from validators attached directly,
or a dict of errors produced by a nested schema.
:param prope... | [
"def",
"add_entity_errors",
"(",
"self",
",",
"property_name",
",",
"direct_errors",
"=",
"None",
",",
"schema_errors",
"=",
"None",
")",
":",
"if",
"direct_errors",
"is",
"None",
"and",
"schema_errors",
"is",
"None",
":",
"return",
"self",
"# direct errors",
... | Attach nested entity errors
Accepts a list errors coming from validators attached directly,
or a dict of errors produced by a nested schema.
:param property_name: str, property name
:param direct_errors: list, errors from validators attached directly
:param schema_errors: dict, ... | [
"Attach",
"nested",
"entity",
"errors",
"Accepts",
"a",
"list",
"errors",
"coming",
"from",
"validators",
"attached",
"directly",
"or",
"a",
"dict",
"of",
"errors",
"produced",
"by",
"a",
"nested",
"schema",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L106-L161 | train |
projectshift/shift-schema | shiftschema/result.py | Result.add_collection_errors | def add_collection_errors(
self,
property_name,
direct_errors=None,
collection_errors=None
):
"""
Add collection errors
Accepts a list errors coming from validators attached directly,
or a list of schema results for each item in the collection.
... | python | def add_collection_errors(
self,
property_name,
direct_errors=None,
collection_errors=None
):
"""
Add collection errors
Accepts a list errors coming from validators attached directly,
or a list of schema results for each item in the collection.
... | [
"def",
"add_collection_errors",
"(",
"self",
",",
"property_name",
",",
"direct_errors",
"=",
"None",
",",
"collection_errors",
"=",
"None",
")",
":",
"if",
"direct_errors",
"is",
"None",
"and",
"collection_errors",
"is",
"None",
":",
"return",
"self",
"# direct... | Add collection errors
Accepts a list errors coming from validators attached directly,
or a list of schema results for each item in the collection.
:param property_name: str, property name
:param direct_errors: list, errors from validators attached directly
:param collection_erro... | [
"Add",
"collection",
"errors",
"Accepts",
"a",
"list",
"errors",
"coming",
"from",
"validators",
"attached",
"directly",
"or",
"a",
"list",
"of",
"schema",
"results",
"for",
"each",
"item",
"in",
"the",
"collection",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L163-L220 | train |
projectshift/shift-schema | shiftschema/result.py | Result.merge_errors | def merge_errors(self, errors_local, errors_remote):
"""
Merge errors
Recursively traverses error graph to merge remote errors into local
errors to return a new joined graph.
:param errors_local: dict, local errors, will be updated
:param errors_remote: dict, remote erro... | python | def merge_errors(self, errors_local, errors_remote):
"""
Merge errors
Recursively traverses error graph to merge remote errors into local
errors to return a new joined graph.
:param errors_local: dict, local errors, will be updated
:param errors_remote: dict, remote erro... | [
"def",
"merge_errors",
"(",
"self",
",",
"errors_local",
",",
"errors_remote",
")",
":",
"for",
"prop",
"in",
"errors_remote",
":",
"# create if doesn't exist",
"if",
"prop",
"not",
"in",
"errors_local",
":",
"errors_local",
"[",
"prop",
"]",
"=",
"errors_remote... | Merge errors
Recursively traverses error graph to merge remote errors into local
errors to return a new joined graph.
:param errors_local: dict, local errors, will be updated
:param errors_remote: dict, remote errors, provides updates
:return: dict | [
"Merge",
"errors",
"Recursively",
"traverses",
"error",
"graph",
"to",
"merge",
"remote",
"errors",
"into",
"local",
"errors",
"to",
"return",
"a",
"new",
"joined",
"graph",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L222-L290 | train |
projectshift/shift-schema | shiftschema/result.py | Result.merge | def merge(self, another):
""" Merges another validation result graph into itself"""
if isinstance(another, Result):
another = another.errors
self.errors = self.merge_errors(self.errors, another) | python | def merge(self, another):
""" Merges another validation result graph into itself"""
if isinstance(another, Result):
another = another.errors
self.errors = self.merge_errors(self.errors, another) | [
"def",
"merge",
"(",
"self",
",",
"another",
")",
":",
"if",
"isinstance",
"(",
"another",
",",
"Result",
")",
":",
"another",
"=",
"another",
".",
"errors",
"self",
".",
"errors",
"=",
"self",
".",
"merge_errors",
"(",
"self",
".",
"errors",
",",
"a... | Merges another validation result graph into itself | [
"Merges",
"another",
"validation",
"result",
"graph",
"into",
"itself"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L292-L296 | train |
projectshift/shift-schema | shiftschema/result.py | Result.get_messages | def get_messages(self, locale=None):
""" Get a dictionary of translated messages """
if locale is None:
locale = self.locale
if self.translator:
def translate(error):
return self.translator.translate(error, locale)
else:
def translate(... | python | def get_messages(self, locale=None):
""" Get a dictionary of translated messages """
if locale is None:
locale = self.locale
if self.translator:
def translate(error):
return self.translator.translate(error, locale)
else:
def translate(... | [
"def",
"get_messages",
"(",
"self",
",",
"locale",
"=",
"None",
")",
":",
"if",
"locale",
"is",
"None",
":",
"locale",
"=",
"self",
".",
"locale",
"if",
"self",
".",
"translator",
":",
"def",
"translate",
"(",
"error",
")",
":",
"return",
"self",
"."... | Get a dictionary of translated messages | [
"Get",
"a",
"dictionary",
"of",
"translated",
"messages"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L298-L312 | train |
projectshift/shift-schema | shiftschema/result.py | Result._translate_errors | def _translate_errors(self, errors, translate):
""" Recursively apply translate callback to each error message"""
for prop in errors:
prop_errors = errors[prop]
# state and simple
if type(prop_errors) is list:
for index, error in enumerate(prop_errors... | python | def _translate_errors(self, errors, translate):
""" Recursively apply translate callback to each error message"""
for prop in errors:
prop_errors = errors[prop]
# state and simple
if type(prop_errors) is list:
for index, error in enumerate(prop_errors... | [
"def",
"_translate_errors",
"(",
"self",
",",
"errors",
",",
"translate",
")",
":",
"for",
"prop",
"in",
"errors",
":",
"prop_errors",
"=",
"errors",
"[",
"prop",
"]",
"# state and simple",
"if",
"type",
"(",
"prop_errors",
")",
"is",
"list",
":",
"for",
... | Recursively apply translate callback to each error message | [
"Recursively",
"apply",
"translate",
"callback",
"to",
"each",
"error",
"message"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L314-L350 | train |
sublee/etc | etc/adapters/etcd.py | EtcdAdapter.make_url | def make_url(self, path, api_root=u'/v2/'):
"""Gets a full URL from just path."""
return urljoin(urljoin(self.url, api_root), path) | python | def make_url(self, path, api_root=u'/v2/'):
"""Gets a full URL from just path."""
return urljoin(urljoin(self.url, api_root), path) | [
"def",
"make_url",
"(",
"self",
",",
"path",
",",
"api_root",
"=",
"u'/v2/'",
")",
":",
"return",
"urljoin",
"(",
"urljoin",
"(",
"self",
".",
"url",
",",
"api_root",
")",
",",
"path",
")"
] | Gets a full URL from just path. | [
"Gets",
"a",
"full",
"URL",
"from",
"just",
"path",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L40-L42 | train |
sublee/etc | etc/adapters/etcd.py | EtcdAdapter.make_key_url | def make_key_url(self, key):
"""Gets a URL for a key."""
if type(key) is bytes:
key = key.decode('utf-8')
buf = io.StringIO()
buf.write(u'keys')
if not key.startswith(u'/'):
buf.write(u'/')
buf.write(key)
return self.make_url(buf.getvalue()... | python | def make_key_url(self, key):
"""Gets a URL for a key."""
if type(key) is bytes:
key = key.decode('utf-8')
buf = io.StringIO()
buf.write(u'keys')
if not key.startswith(u'/'):
buf.write(u'/')
buf.write(key)
return self.make_url(buf.getvalue()... | [
"def",
"make_key_url",
"(",
"self",
",",
"key",
")",
":",
"if",
"type",
"(",
"key",
")",
"is",
"bytes",
":",
"key",
"=",
"key",
".",
"decode",
"(",
"'utf-8'",
")",
"buf",
"=",
"io",
".",
"StringIO",
"(",
")",
"buf",
".",
"write",
"(",
"u'keys'",
... | Gets a URL for a key. | [
"Gets",
"a",
"URL",
"for",
"a",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L44-L53 | train |
sublee/etc | etc/adapters/etcd.py | EtcdAdapter.get | def get(self, key, recursive=False, sorted=False, quorum=False,
wait=False, wait_index=None, timeout=None):
"""Requests to get a node by the given key."""
url = self.make_key_url(key)
params = self.build_args({
'recursive': (bool, recursive or None),
'sorted':... | python | def get(self, key, recursive=False, sorted=False, quorum=False,
wait=False, wait_index=None, timeout=None):
"""Requests to get a node by the given key."""
url = self.make_key_url(key)
params = self.build_args({
'recursive': (bool, recursive or None),
'sorted':... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"recursive",
"=",
"False",
",",
"sorted",
"=",
"False",
",",
"quorum",
"=",
"False",
",",
"wait",
"=",
"False",
",",
"wait_index",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"self",
... | Requests to get a node by the given key. | [
"Requests",
"to",
"get",
"a",
"node",
"by",
"the",
"given",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L155-L185 | train |
sublee/etc | etc/adapters/etcd.py | EtcdAdapter.delete | def delete(self, key, dir=False, recursive=False,
prev_value=None, prev_index=None, timeout=None):
"""Requests to delete a node by the given key."""
url = self.make_key_url(key)
params = self.build_args({
'dir': (bool, dir or None),
'recursive': (bool, recu... | python | def delete(self, key, dir=False, recursive=False,
prev_value=None, prev_index=None, timeout=None):
"""Requests to delete a node by the given key."""
url = self.make_key_url(key)
params = self.build_args({
'dir': (bool, dir or None),
'recursive': (bool, recu... | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"dir",
"=",
"False",
",",
"recursive",
"=",
"False",
",",
"prev_value",
"=",
"None",
",",
"prev_index",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"make_key_url",
"(",
... | Requests to delete a node by the given key. | [
"Requests",
"to",
"delete",
"a",
"node",
"by",
"the",
"given",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L220-L234 | train |
AASHE/python-membersuite-api-client | membersuite_api_client/security/services.py | login_to_portal | def login_to_portal(username, password, client, retries=2, delay=0):
"""Log `username` into the MemberSuite Portal.
Returns a PortalUser object if successful, raises
LoginToPortalError if not.
Will retry logging in if a GeneralException occurs, up to `retries`.
Will pause `delay` seconds between r... | python | def login_to_portal(username, password, client, retries=2, delay=0):
"""Log `username` into the MemberSuite Portal.
Returns a PortalUser object if successful, raises
LoginToPortalError if not.
Will retry logging in if a GeneralException occurs, up to `retries`.
Will pause `delay` seconds between r... | [
"def",
"login_to_portal",
"(",
"username",
",",
"password",
",",
"client",
",",
"retries",
"=",
"2",
",",
"delay",
"=",
"0",
")",
":",
"if",
"not",
"client",
".",
"session_id",
":",
"client",
".",
"request_session",
"(",
")",
"concierge_request_header",
"=... | Log `username` into the MemberSuite Portal.
Returns a PortalUser object if successful, raises
LoginToPortalError if not.
Will retry logging in if a GeneralException occurs, up to `retries`.
Will pause `delay` seconds between retries. | [
"Log",
"username",
"into",
"the",
"MemberSuite",
"Portal",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L10-L56 | train |
AASHE/python-membersuite-api-client | membersuite_api_client/security/services.py | logout | def logout(client):
"""Log out the currently logged-in user.
There's a really crappy side-effect here - the session_id
attribute of the `client` passed in will be reset to None if the
logout succeeds, which is going to be almost always, let's hope.
"""
if not client.session_id:
client.... | python | def logout(client):
"""Log out the currently logged-in user.
There's a really crappy side-effect here - the session_id
attribute of the `client` passed in will be reset to None if the
logout succeeds, which is going to be almost always, let's hope.
"""
if not client.session_id:
client.... | [
"def",
"logout",
"(",
"client",
")",
":",
"if",
"not",
"client",
".",
"session_id",
":",
"client",
".",
"request_session",
"(",
")",
"concierge_request_header",
"=",
"client",
".",
"construct_concierge_header",
"(",
"url",
"=",
"(",
"\"http://membersuite.com/contr... | Log out the currently logged-in user.
There's a really crappy side-effect here - the session_id
attribute of the `client` passed in will be reset to None if the
logout succeeds, which is going to be almost always, let's hope. | [
"Log",
"out",
"the",
"currently",
"logged",
"-",
"in",
"user",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L59-L82 | train |
AASHE/python-membersuite-api-client | membersuite_api_client/security/services.py | get_user_for_membersuite_entity | def get_user_for_membersuite_entity(membersuite_entity):
"""Returns a User for `membersuite_entity`.
membersuite_entity is any MemberSuite object that has the fields
membersuite_id, email_address, first_name, and last_name, e.g.,
PortalUser or Individual.
"""
user = None
user_created = Fal... | python | def get_user_for_membersuite_entity(membersuite_entity):
"""Returns a User for `membersuite_entity`.
membersuite_entity is any MemberSuite object that has the fields
membersuite_id, email_address, first_name, and last_name, e.g.,
PortalUser or Individual.
"""
user = None
user_created = Fal... | [
"def",
"get_user_for_membersuite_entity",
"(",
"membersuite_entity",
")",
":",
"user",
"=",
"None",
"user_created",
"=",
"False",
"# First, try to match on username.",
"user_username",
"=",
"generate_username",
"(",
"membersuite_entity",
")",
"try",
":",
"user",
"=",
"U... | Returns a User for `membersuite_entity`.
membersuite_entity is any MemberSuite object that has the fields
membersuite_id, email_address, first_name, and last_name, e.g.,
PortalUser or Individual. | [
"Returns",
"a",
"User",
"for",
"membersuite_entity",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L89-L124 | train |
projectshift/shift-schema | shiftschema/property.py | SimpleProperty.add_validator | def add_validator(self, validator):
"""
Add validator to property
:param validator: object, extending from AbstractValidator
:return: None
"""
if not isinstance(validator, AbstractValidator):
err = 'Validator must be of type {}'.format(AbstractValidator)
... | python | def add_validator(self, validator):
"""
Add validator to property
:param validator: object, extending from AbstractValidator
:return: None
"""
if not isinstance(validator, AbstractValidator):
err = 'Validator must be of type {}'.format(AbstractValidator)
... | [
"def",
"add_validator",
"(",
"self",
",",
"validator",
")",
":",
"if",
"not",
"isinstance",
"(",
"validator",
",",
"AbstractValidator",
")",
":",
"err",
"=",
"'Validator must be of type {}'",
".",
"format",
"(",
"AbstractValidator",
")",
"raise",
"InvalidValidator... | Add validator to property
:param validator: object, extending from AbstractValidator
:return: None | [
"Add",
"validator",
"to",
"property"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L42-L54 | train |
projectshift/shift-schema | shiftschema/property.py | SimpleProperty.filter | def filter(self, value=None, model=None, context=None):
"""
Sequentially applies all the filters to provided value
:param value: a value to filter
:param model: parent entity
:param context: filtering context, usually parent entity
:return: filtered value
"""
... | python | def filter(self, value=None, model=None, context=None):
"""
Sequentially applies all the filters to provided value
:param value: a value to filter
:param model: parent entity
:param context: filtering context, usually parent entity
:return: filtered value
"""
... | [
"def",
"filter",
"(",
"self",
",",
"value",
"=",
"None",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"value",
"for",
"filter_obj",
"in",
"self",
".",
"filters",
":",
"value",
"=",
"f... | Sequentially applies all the filters to provided value
:param value: a value to filter
:param model: parent entity
:param context: filtering context, usually parent entity
:return: filtered value | [
"Sequentially",
"applies",
"all",
"the",
"filters",
"to",
"provided",
"value"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L56-L73 | train |
projectshift/shift-schema | shiftschema/property.py | SimpleProperty.validate | def validate(self, value=None, model=None, context=None):
"""
Sequentially apply each validator to value and collect errors.
:param value: a value to validate
:param model: parent entity
:param context: validation context, usually parent entity
:return: list of errors (i... | python | def validate(self, value=None, model=None, context=None):
"""
Sequentially apply each validator to value and collect errors.
:param value: a value to validate
:param model: parent entity
:param context: validation context, usually parent entity
:return: list of errors (i... | [
"def",
"validate",
"(",
"self",
",",
"value",
"=",
"None",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"validator",
"in",
"self",
".",
"validators",
":",
"if",
"value",
"is",
"None",
"and",
"not... | Sequentially apply each validator to value and collect errors.
:param value: a value to validate
:param model: parent entity
:param context: validation context, usually parent entity
:return: list of errors (if any) | [
"Sequentially",
"apply",
"each",
"validator",
"to",
"value",
"and",
"collect",
"errors",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L75-L97 | train |
projectshift/shift-schema | shiftschema/property.py | EntityProperty.filter_with_schema | def filter_with_schema(self, model=None, context=None):
""" Perform model filtering with schema """
if model is None or self.schema is None:
return
self._schema.filter(
model=model,
context=context if self.use_context else None
) | python | def filter_with_schema(self, model=None, context=None):
""" Perform model filtering with schema """
if model is None or self.schema is None:
return
self._schema.filter(
model=model,
context=context if self.use_context else None
) | [
"def",
"filter_with_schema",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
"or",
"self",
".",
"schema",
"is",
"None",
":",
"return",
"self",
".",
"_schema",
".",
"filter",
"(",
"model",
"=... | Perform model filtering with schema | [
"Perform",
"model",
"filtering",
"with",
"schema"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L125-L133 | train |
projectshift/shift-schema | shiftschema/property.py | EntityProperty.validate_with_schema | def validate_with_schema(self, model=None, context=None):
""" Perform model validation with schema"""
if self._schema is None or model is None:
return
result = self._schema.validate(
model=model,
context=context if self.use_context else None
)
... | python | def validate_with_schema(self, model=None, context=None):
""" Perform model validation with schema"""
if self._schema is None or model is None:
return
result = self._schema.validate(
model=model,
context=context if self.use_context else None
)
... | [
"def",
"validate_with_schema",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"self",
".",
"_schema",
"is",
"None",
"or",
"model",
"is",
"None",
":",
"return",
"result",
"=",
"self",
".",
"_schema",
".",
"validate"... | Perform model validation with schema | [
"Perform",
"model",
"validation",
"with",
"schema"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L135-L144 | train |
projectshift/shift-schema | shiftschema/property.py | CollectionProperty.filter_with_schema | def filter_with_schema(self, collection=None, context=None):
""" Perform collection items filtering with schema """
if collection is None or self.schema is None:
return
try:
for item in collection:
self._schema.filter(
model=item,
... | python | def filter_with_schema(self, collection=None, context=None):
""" Perform collection items filtering with schema """
if collection is None or self.schema is None:
return
try:
for item in collection:
self._schema.filter(
model=item,
... | [
"def",
"filter_with_schema",
"(",
"self",
",",
"collection",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"collection",
"is",
"None",
"or",
"self",
".",
"schema",
"is",
"None",
":",
"return",
"try",
":",
"for",
"item",
"in",
"collection",
... | Perform collection items filtering with schema | [
"Perform",
"collection",
"items",
"filtering",
"with",
"schema"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L155-L167 | train |
projectshift/shift-schema | shiftschema/property.py | CollectionProperty.validate_with_schema | def validate_with_schema(self, collection=None, context=None):
""" Validate each item in collection with our schema"""
if self._schema is None or not collection:
return
result = []
try:
for index, item in enumerate(collection):
item_result = self.... | python | def validate_with_schema(self, collection=None, context=None):
""" Validate each item in collection with our schema"""
if self._schema is None or not collection:
return
result = []
try:
for index, item in enumerate(collection):
item_result = self.... | [
"def",
"validate_with_schema",
"(",
"self",
",",
"collection",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"self",
".",
"_schema",
"is",
"None",
"or",
"not",
"collection",
":",
"return",
"result",
"=",
"[",
"]",
"try",
":",
"for",
"index"... | Validate each item in collection with our schema | [
"Validate",
"each",
"item",
"in",
"collection",
"with",
"our",
"schema"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L169-L185 | train |
shaypal5/strct | strct/hash/_hash.py | json_based_stable_hash | def json_based_stable_hash(obj):
"""Computes a cross-kernel stable hash value for the given object.
The supported data structure are the built-in list, tuple and dict types.
Any included tuple or list, whether outer or nested, may only contain
values of the following built-in types: bool, int, float, ... | python | def json_based_stable_hash(obj):
"""Computes a cross-kernel stable hash value for the given object.
The supported data structure are the built-in list, tuple and dict types.
Any included tuple or list, whether outer or nested, may only contain
values of the following built-in types: bool, int, float, ... | [
"def",
"json_based_stable_hash",
"(",
"obj",
")",
":",
"encoded_str",
"=",
"json",
".",
"dumps",
"(",
"obj",
"=",
"obj",
",",
"skipkeys",
"=",
"False",
",",
"ensure_ascii",
"=",
"False",
",",
"check_circular",
"=",
"True",
",",
"allow_nan",
"=",
"True",
... | Computes a cross-kernel stable hash value for the given object.
The supported data structure are the built-in list, tuple and dict types.
Any included tuple or list, whether outer or nested, may only contain
values of the following built-in types: bool, int, float, complex, str,
list, tuple and dict.
... | [
"Computes",
"a",
"cross",
"-",
"kernel",
"stable",
"hash",
"value",
"for",
"the",
"given",
"object",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/hash/_hash.py#L86-L122 | train |
a1ezzz/wasp-general | wasp_general/network/web/session.py | WWebSessionBase.read_request_line | def read_request_line(self, request_line):
""" Read HTTP-request line
:param request_line: line to parse
for HTTP/0.9 is GET <Request-URI>
for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0
or 1.1.
for HTTP/2: binary headers are used
"""
request = self.__... | python | def read_request_line(self, request_line):
""" Read HTTP-request line
:param request_line: line to parse
for HTTP/0.9 is GET <Request-URI>
for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0
or 1.1.
for HTTP/2: binary headers are used
"""
request = self.__... | [
"def",
"read_request_line",
"(",
"self",
",",
"request_line",
")",
":",
"request",
"=",
"self",
".",
"__request_cls",
".",
"parse_request_line",
"(",
"self",
",",
"request_line",
")",
"protocol_version",
"=",
"self",
".",
"protocol_version",
"(",
")",
"if",
"p... | Read HTTP-request line
:param request_line: line to parse
for HTTP/0.9 is GET <Request-URI>
for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0
or 1.1.
for HTTP/2: binary headers are used | [
"Read",
"HTTP",
"-",
"request",
"line"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/session.py#L67-L88 | train |
contains-io/typet | typet/meta.py | metaclass | def metaclass(*metaclasses):
# type: (*type) -> Callable[[type], type]
"""Create the class using all metaclasses.
Args:
metaclasses: A tuple of metaclasses that will be used to generate and
replace a specified class.
Returns:
A decorator that will recreate the class using t... | python | def metaclass(*metaclasses):
# type: (*type) -> Callable[[type], type]
"""Create the class using all metaclasses.
Args:
metaclasses: A tuple of metaclasses that will be used to generate and
replace a specified class.
Returns:
A decorator that will recreate the class using t... | [
"def",
"metaclass",
"(",
"*",
"metaclasses",
")",
":",
"# type: (*type) -> Callable[[type], type]",
"def",
"_inner",
"(",
"cls",
")",
":",
"# pragma pylint: disable=unused-variable",
"metabases",
"=",
"tuple",
"(",
"collections",
".",
"OrderedDict",
"(",
"# noqa: F841",... | Create the class using all metaclasses.
Args:
metaclasses: A tuple of metaclasses that will be used to generate and
replace a specified class.
Returns:
A decorator that will recreate the class using the specified
metaclasses. | [
"Create",
"the",
"class",
"using",
"all",
"metaclasses",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/meta.py#L38-L67 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/interventions.py | ITN.get_attrition_in_years | def get_attrition_in_years(self):
"""
Function for the Basic UI
"""
attrition_of_nets = self.itn.find("attritionOfNets")
function = attrition_of_nets.attrib["function"]
if function != "step":
return None
L = attrition_of_nets.attrib["L"]
return... | python | def get_attrition_in_years(self):
"""
Function for the Basic UI
"""
attrition_of_nets = self.itn.find("attritionOfNets")
function = attrition_of_nets.attrib["function"]
if function != "step":
return None
L = attrition_of_nets.attrib["L"]
return... | [
"def",
"get_attrition_in_years",
"(",
"self",
")",
":",
"attrition_of_nets",
"=",
"self",
".",
"itn",
".",
"find",
"(",
"\"attritionOfNets\"",
")",
"function",
"=",
"attrition_of_nets",
".",
"attrib",
"[",
"\"function\"",
"]",
"if",
"function",
"!=",
"\"step\"",... | Function for the Basic UI | [
"Function",
"for",
"the",
"Basic",
"UI"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L374-L383 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/interventions.py | VectorPop.add | def add(self, intervention, name=None):
"""
Add an intervention to vectorPop section.
intervention is either ElementTree or xml snippet
"""
if self.et is None:
return
assert isinstance(intervention, six.string_types)
et = ElementTree.fromstring(interv... | python | def add(self, intervention, name=None):
"""
Add an intervention to vectorPop section.
intervention is either ElementTree or xml snippet
"""
if self.et is None:
return
assert isinstance(intervention, six.string_types)
et = ElementTree.fromstring(interv... | [
"def",
"add",
"(",
"self",
",",
"intervention",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"et",
"is",
"None",
":",
"return",
"assert",
"isinstance",
"(",
"intervention",
",",
"six",
".",
"string_types",
")",
"et",
"=",
"ElementTree",
".",
... | Add an intervention to vectorPop section.
intervention is either ElementTree or xml snippet | [
"Add",
"an",
"intervention",
"to",
"vectorPop",
"section",
".",
"intervention",
"is",
"either",
"ElementTree",
"or",
"xml",
"snippet"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L1046-L1065 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleHistory.add | def add(self, value):
""" Add new record to history. Record will be added to the end
:param value: new record
:return: int record position in history
"""
index = len(self.__history)
self.__history.append(value)
return index | python | def add(self, value):
""" Add new record to history. Record will be added to the end
:param value: new record
:return: int record position in history
"""
index = len(self.__history)
self.__history.append(value)
return index | [
"def",
"add",
"(",
"self",
",",
"value",
")",
":",
"index",
"=",
"len",
"(",
"self",
".",
"__history",
")",
"self",
".",
"__history",
".",
"append",
"(",
"value",
")",
"return",
"index"
] | Add new record to history. Record will be added to the end
:param value: new record
:return: int record position in history | [
"Add",
"new",
"record",
"to",
"history",
".",
"Record",
"will",
"be",
"added",
"to",
"the",
"end"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L69-L77 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleProto.start_session | def start_session(self):
""" Start new session and prepare environment for new row editing process
:return: None
"""
self.__current_row = ''
self.__history_mode = False
self.__editable_history = deepcopy(self.__history)
self.__prompt_show = True
self.refresh_window() | python | def start_session(self):
""" Start new session and prepare environment for new row editing process
:return: None
"""
self.__current_row = ''
self.__history_mode = False
self.__editable_history = deepcopy(self.__history)
self.__prompt_show = True
self.refresh_window() | [
"def",
"start_session",
"(",
"self",
")",
":",
"self",
".",
"__current_row",
"=",
"''",
"self",
".",
"__history_mode",
"=",
"False",
"self",
".",
"__editable_history",
"=",
"deepcopy",
"(",
"self",
".",
"__history",
")",
"self",
".",
"__prompt_show",
"=",
... | Start new session and prepare environment for new row editing process
:return: None | [
"Start",
"new",
"session",
"and",
"prepare",
"environment",
"for",
"new",
"row",
"editing",
"process"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L139-L148 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleProto.fin_session | def fin_session(self):
""" Finalize current session
:return: None
"""
self.__prompt_show = False
self.__history.add(self.row())
self.exec(self.row()) | python | def fin_session(self):
""" Finalize current session
:return: None
"""
self.__prompt_show = False
self.__history.add(self.row())
self.exec(self.row()) | [
"def",
"fin_session",
"(",
"self",
")",
":",
"self",
".",
"__prompt_show",
"=",
"False",
"self",
".",
"__history",
".",
"add",
"(",
"self",
".",
"row",
"(",
")",
")",
"self",
".",
"exec",
"(",
"self",
".",
"row",
"(",
")",
")"
] | Finalize current session
:return: None | [
"Finalize",
"current",
"session"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L150-L157 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleWindowProto.data | def data(
self, previous_data=False, prompt=False, console_row=False,
console_row_to_cursor=False, console_row_from_cursor=False
):
""" Return output data. Flags specifies what data to append. If no flags was specified
nul-length string returned
:param previous_data: If True, then previous output appends
... | python | def data(
self, previous_data=False, prompt=False, console_row=False,
console_row_to_cursor=False, console_row_from_cursor=False
):
""" Return output data. Flags specifies what data to append. If no flags was specified
nul-length string returned
:param previous_data: If True, then previous output appends
... | [
"def",
"data",
"(",
"self",
",",
"previous_data",
"=",
"False",
",",
"prompt",
"=",
"False",
",",
"console_row",
"=",
"False",
",",
"console_row_to_cursor",
"=",
"False",
",",
"console_row_from_cursor",
"=",
"False",
")",
":",
"result",
"=",
"''",
"if",
"p... | Return output data. Flags specifies what data to append. If no flags was specified
nul-length string returned
:param previous_data: If True, then previous output appends
:param prompt: If True, then console prompt appends. If console_row or console_row_to_cursor is True, \
then this value is omitted
:param c... | [
"Return",
"output",
"data",
".",
"Flags",
"specifies",
"what",
"data",
"to",
"append",
".",
"If",
"no",
"flags",
"was",
"specified",
"nul",
"-",
"length",
"string",
"returned"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L299-L332 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleWindowProto.write_data | def write_data(self, data, start_position=0):
""" Write data from the specified line
:param data: string to write, each one on new line
:param start_position: starting line
:return:
"""
if len(data) > self.height():
raise ValueError('Data too long (too many strings)')
for i in range(len(data)):
se... | python | def write_data(self, data, start_position=0):
""" Write data from the specified line
:param data: string to write, each one on new line
:param start_position: starting line
:return:
"""
if len(data) > self.height():
raise ValueError('Data too long (too many strings)')
for i in range(len(data)):
se... | [
"def",
"write_data",
"(",
"self",
",",
"data",
",",
"start_position",
"=",
"0",
")",
":",
"if",
"len",
"(",
"data",
")",
">",
"self",
".",
"height",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Data too long (too many strings)'",
")",
"for",
"i",
"in",
... | Write data from the specified line
:param data: string to write, each one on new line
:param start_position: starting line
:return: | [
"Write",
"data",
"from",
"the",
"specified",
"line"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L359-L370 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleWindowProto.write_feedback | def write_feedback(self, feedback, cr=True):
""" Store feedback. Keep specified feedback as previous output
:param feedback: data to store
:param cr: whether to write carriage return to the end or not
:return: None
"""
self.__previous_data += feedback
if cr is True:
self.__previous_data += '\n' | python | def write_feedback(self, feedback, cr=True):
""" Store feedback. Keep specified feedback as previous output
:param feedback: data to store
:param cr: whether to write carriage return to the end or not
:return: None
"""
self.__previous_data += feedback
if cr is True:
self.__previous_data += '\n' | [
"def",
"write_feedback",
"(",
"self",
",",
"feedback",
",",
"cr",
"=",
"True",
")",
":",
"self",
".",
"__previous_data",
"+=",
"feedback",
"if",
"cr",
"is",
"True",
":",
"self",
".",
"__previous_data",
"+=",
"'\\n'"
] | Store feedback. Keep specified feedback as previous output
:param feedback: data to store
:param cr: whether to write carriage return to the end or not
:return: None | [
"Store",
"feedback",
".",
"Keep",
"specified",
"feedback",
"as",
"previous",
"output"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L421-L430 | train |
a1ezzz/wasp-general | wasp_general/cli/cli.py | WConsoleWindowBase.refresh | def refresh(self, prompt_show=True):
""" Refresh current window. Clear current window and redraw it with one of drawers
:param prompt_show: flag, that specifies, whether to show prompt and current row at the
windows end, or not
:return: None
"""
self.clear()
for drawer in self.__drawers:
if drawer.su... | python | def refresh(self, prompt_show=True):
""" Refresh current window. Clear current window and redraw it with one of drawers
:param prompt_show: flag, that specifies, whether to show prompt and current row at the
windows end, or not
:return: None
"""
self.clear()
for drawer in self.__drawers:
if drawer.su... | [
"def",
"refresh",
"(",
"self",
",",
"prompt_show",
"=",
"True",
")",
":",
"self",
".",
"clear",
"(",
")",
"for",
"drawer",
"in",
"self",
".",
"__drawers",
":",
"if",
"drawer",
".",
"suitable",
"(",
"self",
",",
"prompt_show",
"=",
"prompt_show",
")",
... | Refresh current window. Clear current window and redraw it with one of drawers
:param prompt_show: flag, that specifies, whether to show prompt and current row at the
windows end, or not
:return: None | [
"Refresh",
"current",
"window",
".",
"Clear",
"current",
"window",
"and",
"redraw",
"it",
"with",
"one",
"of",
"drawers"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L484-L498 | train |
contains-io/typet | typet/path.py | is_dir | def is_dir(path):
"""Determine if a Path or string is a directory on the file system."""
try:
return path.expanduser().absolute().is_dir()
except AttributeError:
return os.path.isdir(os.path.abspath(os.path.expanduser(str(path)))) | python | def is_dir(path):
"""Determine if a Path or string is a directory on the file system."""
try:
return path.expanduser().absolute().is_dir()
except AttributeError:
return os.path.isdir(os.path.abspath(os.path.expanduser(str(path)))) | [
"def",
"is_dir",
"(",
"path",
")",
":",
"try",
":",
"return",
"path",
".",
"expanduser",
"(",
")",
".",
"absolute",
"(",
")",
".",
"is_dir",
"(",
")",
"except",
"AttributeError",
":",
"return",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path... | Determine if a Path or string is a directory on the file system. | [
"Determine",
"if",
"a",
"Path",
"or",
"string",
"is",
"a",
"directory",
"on",
"the",
"file",
"system",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L30-L35 | train |
contains-io/typet | typet/path.py | is_file | def is_file(path):
"""Determine if a Path or string is a file on the file system."""
try:
return path.expanduser().absolute().is_file()
except AttributeError:
return os.path.isfile(os.path.abspath(os.path.expanduser(str(path)))) | python | def is_file(path):
"""Determine if a Path or string is a file on the file system."""
try:
return path.expanduser().absolute().is_file()
except AttributeError:
return os.path.isfile(os.path.abspath(os.path.expanduser(str(path)))) | [
"def",
"is_file",
"(",
"path",
")",
":",
"try",
":",
"return",
"path",
".",
"expanduser",
"(",
")",
".",
"absolute",
"(",
")",
".",
"is_file",
"(",
")",
"except",
"AttributeError",
":",
"return",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"p... | Determine if a Path or string is a file on the file system. | [
"Determine",
"if",
"a",
"Path",
"or",
"string",
"is",
"a",
"file",
"on",
"the",
"file",
"system",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L38-L43 | train |
contains-io/typet | typet/path.py | exists | def exists(path):
"""Determine if a Path or string is an existing path on the file system."""
try:
return path.expanduser().absolute().exists()
except AttributeError:
return os.path.exists(os.path.abspath(os.path.expanduser(str(path)))) | python | def exists(path):
"""Determine if a Path or string is an existing path on the file system."""
try:
return path.expanduser().absolute().exists()
except AttributeError:
return os.path.exists(os.path.abspath(os.path.expanduser(str(path)))) | [
"def",
"exists",
"(",
"path",
")",
":",
"try",
":",
"return",
"path",
".",
"expanduser",
"(",
")",
".",
"absolute",
"(",
")",
".",
"exists",
"(",
")",
"except",
"AttributeError",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"pat... | Determine if a Path or string is an existing path on the file system. | [
"Determine",
"if",
"a",
"Path",
"or",
"string",
"is",
"an",
"existing",
"path",
"on",
"the",
"file",
"system",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L46-L51 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacstextedit_macros.py | YankPop.enableHook | def enableHook(self, msgObj):
"""
Enable yank-pop.
This method is connected to the 'yank-qtmacs_text_edit' hook
(triggered by the yank macro) to ensure that yank-pop only
gets activated afterwards.
"""
self.killListIdx = len(qte_global.kill_list) - 2
self... | python | def enableHook(self, msgObj):
"""
Enable yank-pop.
This method is connected to the 'yank-qtmacs_text_edit' hook
(triggered by the yank macro) to ensure that yank-pop only
gets activated afterwards.
"""
self.killListIdx = len(qte_global.kill_list) - 2
self... | [
"def",
"enableHook",
"(",
"self",
",",
"msgObj",
")",
":",
"self",
".",
"killListIdx",
"=",
"len",
"(",
"qte_global",
".",
"kill_list",
")",
"-",
"2",
"self",
".",
"qteMain",
".",
"qtesigKeyseqComplete",
".",
"connect",
"(",
"self",
".",
"disableHook",
"... | Enable yank-pop.
This method is connected to the 'yank-qtmacs_text_edit' hook
(triggered by the yank macro) to ensure that yank-pop only
gets activated afterwards. | [
"Enable",
"yank",
"-",
"pop",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L483-L492 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacstextedit_macros.py | BracketMatching.cursorPositionChangedEvent | def cursorPositionChangedEvent(self):
"""
Update the highlighting.
This is an overloaded version of the native Qt slot of
``QTextEdit``.
In this class, the purpose of this slot is to check if the
character to the right of the cursor needs highlighting,
assuming ... | python | def cursorPositionChangedEvent(self):
"""
Update the highlighting.
This is an overloaded version of the native Qt slot of
``QTextEdit``.
In this class, the purpose of this slot is to check if the
character to the right of the cursor needs highlighting,
assuming ... | [
"def",
"cursorPositionChangedEvent",
"(",
"self",
")",
":",
"# Determine the sender and cursor position.",
"qteWidget",
"=",
"self",
".",
"sender",
"(",
")",
"tc",
"=",
"qteWidget",
".",
"textCursor",
"(",
")",
"origin",
"=",
"tc",
".",
"position",
"(",
")",
"... | Update the highlighting.
This is an overloaded version of the native Qt slot of
``QTextEdit``.
In this class, the purpose of this slot is to check if the
character to the right of the cursor needs highlighting,
assuming there is a second character to pair with it.
|Arg... | [
"Update",
"the",
"highlighting",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L899-L991 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacstextedit_macros.py | BracketMatching.qteRemoveHighlighting | def qteRemoveHighlighting(self, widgetObj):
"""
Remove the highlighting from previously highlighted characters.
The method access instance variables to determine which
characters are currently highlighted and have to be converted
to non-highlighted ones.
|Args|
... | python | def qteRemoveHighlighting(self, widgetObj):
"""
Remove the highlighting from previously highlighted characters.
The method access instance variables to determine which
characters are currently highlighted and have to be converted
to non-highlighted ones.
|Args|
... | [
"def",
"qteRemoveHighlighting",
"(",
"self",
",",
"widgetObj",
")",
":",
"# Retrieve the widget specific macro data.",
"data",
"=",
"self",
".",
"qteMacroData",
"(",
"widgetObj",
")",
"if",
"not",
"data",
":",
"return",
"# If the data structure is empty then no previously... | Remove the highlighting from previously highlighted characters.
The method access instance variables to determine which
characters are currently highlighted and have to be converted
to non-highlighted ones.
|Args|
* ``widgetObj`` (**QWidget**): the ``QTextEdit`` to use.
... | [
"Remove",
"the",
"highlighting",
"from",
"previously",
"highlighted",
"characters",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L993-L1034 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacstextedit_macros.py | BracketMatching.highlightCharacters | def highlightCharacters(self, widgetObj, setPos, colorCode,
fontWeight, charFormat=None):
"""
Change the character format of one or more characters.
If ``charFormat`` is **None** then only the color and font
weight of the characters are changed to ``colorCode... | python | def highlightCharacters(self, widgetObj, setPos, colorCode,
fontWeight, charFormat=None):
"""
Change the character format of one or more characters.
If ``charFormat`` is **None** then only the color and font
weight of the characters are changed to ``colorCode... | [
"def",
"highlightCharacters",
"(",
"self",
",",
"widgetObj",
",",
"setPos",
",",
"colorCode",
",",
"fontWeight",
",",
"charFormat",
"=",
"None",
")",
":",
"# Get the text cursor and character format.",
"textCursor",
"=",
"widgetObj",
".",
"textCursor",
"(",
")",
"... | Change the character format of one or more characters.
If ``charFormat`` is **None** then only the color and font
weight of the characters are changed to ``colorCode`` and
``fontWeight``, respectively.
|Args|
* ``widgetObj`` (**QWidget**): the ``QTextEdit`` holding
t... | [
"Change",
"the",
"character",
"format",
"of",
"one",
"or",
"more",
"characters",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L1036-L1122 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/experiment.py | ExperimentSpecification.scenarios | def scenarios(self, generate_seed=False):
"""
Generator function. Spits out scenarios for this experiment
"""
seed = prime_numbers(1000)
sweeps_all = self.experiment["sweeps"].keys()
if "combinations" in self.experiment:
if isinstance(self.experiment["combinat... | python | def scenarios(self, generate_seed=False):
"""
Generator function. Spits out scenarios for this experiment
"""
seed = prime_numbers(1000)
sweeps_all = self.experiment["sweeps"].keys()
if "combinations" in self.experiment:
if isinstance(self.experiment["combinat... | [
"def",
"scenarios",
"(",
"self",
",",
"generate_seed",
"=",
"False",
")",
":",
"seed",
"=",
"prime_numbers",
"(",
"1000",
")",
"sweeps_all",
"=",
"self",
".",
"experiment",
"[",
"\"sweeps\"",
"]",
".",
"keys",
"(",
")",
"if",
"\"combinations\"",
"in",
"s... | Generator function. Spits out scenarios for this experiment | [
"Generator",
"function",
".",
"Spits",
"out",
"scenarios",
"for",
"this",
"experiment"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/experiment.py#L99-L177 | train |
a1ezzz/wasp-general | wasp_general/os/linux/lvm.py | WLVMInfoCommand.lvm_info | def lvm_info(self, name=None):
""" Call a program
:param name: if specified - program will return information for that lvm-entity only. otherwise -
all available entries are returned
:return: tuple of str (fields)
"""
cmd = [] if self.sudo() is False else ['sudo']
cmd.extend([self.command(), '-c'])
if... | python | def lvm_info(self, name=None):
""" Call a program
:param name: if specified - program will return information for that lvm-entity only. otherwise -
all available entries are returned
:return: tuple of str (fields)
"""
cmd = [] if self.sudo() is False else ['sudo']
cmd.extend([self.command(), '-c'])
if... | [
"def",
"lvm_info",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"]",
"if",
"self",
".",
"sudo",
"(",
")",
"is",
"False",
"else",
"[",
"'sudo'",
"]",
"cmd",
".",
"extend",
"(",
"[",
"self",
".",
"command",
"(",
")",
",",
"... | Call a program
:param name: if specified - program will return information for that lvm-entity only. otherwise -
all available entries are returned
:return: tuple of str (fields) | [
"Call",
"a",
"program"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L95-L119 | train |
a1ezzz/wasp-general | wasp_general/os/linux/lvm.py | WLogicalVolume.uuid | def uuid(self):
""" Return UUID of logical volume
:return: str
"""
uuid_file = '/sys/block/%s/dm/uuid' % os.path.basename(os.path.realpath(self.volume_path()))
lv_uuid = open(uuid_file).read().strip()
if lv_uuid.startswith('LVM-') is True:
return lv_uuid[4:]
return lv_uuid | python | def uuid(self):
""" Return UUID of logical volume
:return: str
"""
uuid_file = '/sys/block/%s/dm/uuid' % os.path.basename(os.path.realpath(self.volume_path()))
lv_uuid = open(uuid_file).read().strip()
if lv_uuid.startswith('LVM-') is True:
return lv_uuid[4:]
return lv_uuid | [
"def",
"uuid",
"(",
"self",
")",
":",
"uuid_file",
"=",
"'/sys/block/%s/dm/uuid'",
"%",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"self",
".",
"volume_path",
"(",
")",
")",
")",
"lv_uuid",
"=",
"open",
"(",
"uu... | Return UUID of logical volume
:return: str | [
"Return",
"UUID",
"of",
"logical",
"volume"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L457-L466 | train |
a1ezzz/wasp-general | wasp_general/os/linux/lvm.py | WLogicalVolume.create_snapshot | def create_snapshot(self, snapshot_size, snapshot_suffix):
""" Create snapshot for this logical volume.
:param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \
logical volume space (of this logical volume)
:param snapshot_suffix: suffix for logical volume name (base... | python | def create_snapshot(self, snapshot_size, snapshot_suffix):
""" Create snapshot for this logical volume.
:param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \
logical volume space (of this logical volume)
:param snapshot_suffix: suffix for logical volume name (base... | [
"def",
"create_snapshot",
"(",
"self",
",",
"snapshot_size",
",",
"snapshot_suffix",
")",
":",
"size_extent",
"=",
"math",
".",
"ceil",
"(",
"self",
".",
"extents_count",
"(",
")",
"*",
"snapshot_size",
")",
"size_kb",
"=",
"self",
".",
"volume_group",
"(",
... | Create snapshot for this logical volume.
:param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \
logical volume space (of this logical volume)
:param snapshot_suffix: suffix for logical volume name (base part is the same as the original volume \
name)
:return: WL... | [
"Create",
"snapshot",
"for",
"this",
"logical",
"volume",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L470-L490 | train |
a1ezzz/wasp-general | wasp_general/os/linux/lvm.py | WLogicalVolume.remove_volume | def remove_volume(self):
""" Remove this volume
:return: None
"""
lvremove_cmd = ['sudo'] if self.lvm_command().sudo() is True else []
lvremove_cmd.extend(['lvremove', '-f', self.volume_path()])
subprocess.check_output(lvremove_cmd, timeout=self.__class__.__lvm_snapshot_remove_cmd_timeout__) | python | def remove_volume(self):
""" Remove this volume
:return: None
"""
lvremove_cmd = ['sudo'] if self.lvm_command().sudo() is True else []
lvremove_cmd.extend(['lvremove', '-f', self.volume_path()])
subprocess.check_output(lvremove_cmd, timeout=self.__class__.__lvm_snapshot_remove_cmd_timeout__) | [
"def",
"remove_volume",
"(",
"self",
")",
":",
"lvremove_cmd",
"=",
"[",
"'sudo'",
"]",
"if",
"self",
".",
"lvm_command",
"(",
")",
".",
"sudo",
"(",
")",
"is",
"True",
"else",
"[",
"]",
"lvremove_cmd",
".",
"extend",
"(",
"[",
"'lvremove'",
",",
"'-... | Remove this volume
:return: None | [
"Remove",
"this",
"volume"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L492-L499 | train |
a1ezzz/wasp-general | wasp_general/os/linux/lvm.py | WLogicalVolume.logical_volume | def logical_volume(cls, file_path, sudo=False):
""" Return logical volume that stores the given path
:param file_path: target path to search
:param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__`
:return: WLogicalVolume or None (if file path is outside current mount points)
"""
mp = WMountPoint.mo... | python | def logical_volume(cls, file_path, sudo=False):
""" Return logical volume that stores the given path
:param file_path: target path to search
:param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__`
:return: WLogicalVolume or None (if file path is outside current mount points)
"""
mp = WMountPoint.mo... | [
"def",
"logical_volume",
"(",
"cls",
",",
"file_path",
",",
"sudo",
"=",
"False",
")",
":",
"mp",
"=",
"WMountPoint",
".",
"mount_point",
"(",
"file_path",
")",
"if",
"mp",
"is",
"not",
"None",
":",
"name_file",
"=",
"'/sys/block/%s/dm/name'",
"%",
"mp",
... | Return logical volume that stores the given path
:param file_path: target path to search
:param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__`
:return: WLogicalVolume or None (if file path is outside current mount points) | [
"Return",
"logical",
"volume",
"that",
"stores",
"the",
"given",
"path"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L524-L536 | train |
a1ezzz/wasp-general | wasp_general/io.py | WAESWriter.write | def write(self, b):
""" Encrypt and write data
:param b: data to encrypt and write
:return: None
"""
self.__buffer += bytes(b)
bytes_written = 0
while len(self.__buffer) >= self.__cipher_block_size:
io.BufferedWriter.write(self, self.__cipher.encrypt_block(self.__buffer[:self.__cipher_block_size]))
... | python | def write(self, b):
""" Encrypt and write data
:param b: data to encrypt and write
:return: None
"""
self.__buffer += bytes(b)
bytes_written = 0
while len(self.__buffer) >= self.__cipher_block_size:
io.BufferedWriter.write(self, self.__cipher.encrypt_block(self.__buffer[:self.__cipher_block_size]))
... | [
"def",
"write",
"(",
"self",
",",
"b",
")",
":",
"self",
".",
"__buffer",
"+=",
"bytes",
"(",
"b",
")",
"bytes_written",
"=",
"0",
"while",
"len",
"(",
"self",
".",
"__buffer",
")",
">=",
"self",
".",
"__cipher_block_size",
":",
"io",
".",
"BufferedW... | Encrypt and write data
:param b: data to encrypt and write
:return: None | [
"Encrypt",
"and",
"write",
"data"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/io.py#L205-L218 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURI.reset_component | def reset_component(self, component):
""" Unset component in this URI
:param component: component name (or component type) to reset
:return: None
"""
if isinstance(component, str) is True:
component = WURI.Component(component)
self.__components[component] = None | python | def reset_component(self, component):
""" Unset component in this URI
:param component: component name (or component type) to reset
:return: None
"""
if isinstance(component, str) is True:
component = WURI.Component(component)
self.__components[component] = None | [
"def",
"reset_component",
"(",
"self",
",",
"component",
")",
":",
"if",
"isinstance",
"(",
"component",
",",
"str",
")",
"is",
"True",
":",
"component",
"=",
"WURI",
".",
"Component",
"(",
"component",
")",
"self",
".",
"__components",
"[",
"component",
... | Unset component in this URI
:param component: component name (or component type) to reset
:return: None | [
"Unset",
"component",
"in",
"this",
"URI"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L137-L146 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURI.parse | def parse(cls, uri):
""" Parse URI-string and return WURI object
:param uri: string to parse
:return: WURI
"""
uri_components = urlsplit(uri)
adapter_fn = lambda x: x if x is not None and (isinstance(x, str) is False or len(x)) > 0 else None
return cls(
scheme=adapter_fn(uri_components.scheme),
us... | python | def parse(cls, uri):
""" Parse URI-string and return WURI object
:param uri: string to parse
:return: WURI
"""
uri_components = urlsplit(uri)
adapter_fn = lambda x: x if x is not None and (isinstance(x, str) is False or len(x)) > 0 else None
return cls(
scheme=adapter_fn(uri_components.scheme),
us... | [
"def",
"parse",
"(",
"cls",
",",
"uri",
")",
":",
"uri_components",
"=",
"urlsplit",
"(",
"uri",
")",
"adapter_fn",
"=",
"lambda",
"x",
":",
"x",
"if",
"x",
"is",
"not",
"None",
"and",
"(",
"isinstance",
"(",
"x",
",",
"str",
")",
"is",
"False",
... | Parse URI-string and return WURI object
:param uri: string to parse
:return: WURI | [
"Parse",
"URI",
"-",
"string",
"and",
"return",
"WURI",
"object"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L150-L168 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURIQuery.add_parameter | def add_parameter(self, name, value=None):
""" Add new parameter value to this query. New value will be appended to previously added values.
:param name: parameter name
:param value: value to add (None to set null-value)
:return: None
"""
if name not in self.__query:
self.__query[name] = [value]
else:... | python | def add_parameter(self, name, value=None):
""" Add new parameter value to this query. New value will be appended to previously added values.
:param name: parameter name
:param value: value to add (None to set null-value)
:return: None
"""
if name not in self.__query:
self.__query[name] = [value]
else:... | [
"def",
"add_parameter",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"__query",
":",
"self",
".",
"__query",
"[",
"name",
"]",
"=",
"[",
"value",
"]",
"else",
":",
"self",
".",
"__query",
... | Add new parameter value to this query. New value will be appended to previously added values.
:param name: parameter name
:param value: value to add (None to set null-value)
:return: None | [
"Add",
"new",
"parameter",
"value",
"to",
"this",
"query",
".",
"New",
"value",
"will",
"be",
"appended",
"to",
"previously",
"added",
"values",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L202-L212 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURIQuery.remove_parameter | def remove_parameter(self, name):
""" Remove the specified parameter from this query
:param name: name of a parameter to remove
:return: None
"""
if name in self.__query:
self.__query.pop(name) | python | def remove_parameter(self, name):
""" Remove the specified parameter from this query
:param name: name of a parameter to remove
:return: None
"""
if name in self.__query:
self.__query.pop(name) | [
"def",
"remove_parameter",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"__query",
":",
"self",
".",
"__query",
".",
"pop",
"(",
"name",
")"
] | Remove the specified parameter from this query
:param name: name of a parameter to remove
:return: None | [
"Remove",
"the",
"specified",
"parameter",
"from",
"this",
"query"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L215-L222 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURIQuery.parse | def parse(cls, query_str):
""" Parse string that represent query component from URI
:param query_str: string without '?'-sign
:return: WURIQuery
"""
parsed_query = parse_qs(query_str, keep_blank_values=True, strict_parsing=True)
result = cls()
for parameter_name in parsed_query.keys():
for parameter_v... | python | def parse(cls, query_str):
""" Parse string that represent query component from URI
:param query_str: string without '?'-sign
:return: WURIQuery
"""
parsed_query = parse_qs(query_str, keep_blank_values=True, strict_parsing=True)
result = cls()
for parameter_name in parsed_query.keys():
for parameter_v... | [
"def",
"parse",
"(",
"cls",
",",
"query_str",
")",
":",
"parsed_query",
"=",
"parse_qs",
"(",
"query_str",
",",
"keep_blank_values",
"=",
"True",
",",
"strict_parsing",
"=",
"True",
")",
"result",
"=",
"cls",
"(",
")",
"for",
"parameter_name",
"in",
"parse... | Parse string that represent query component from URI
:param query_str: string without '?'-sign
:return: WURIQuery | [
"Parse",
"string",
"that",
"represent",
"query",
"component",
"from",
"URI"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L261-L275 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WStrictURIQuery.add_specification | def add_specification(self, specification):
""" Add a new query parameter specification. If this object already has a specification for the
specified parameter - exception is raised. No checks for the specified or any parameter are made
regarding specification appending
:param specification: new specification ... | python | def add_specification(self, specification):
""" Add a new query parameter specification. If this object already has a specification for the
specified parameter - exception is raised. No checks for the specified or any parameter are made
regarding specification appending
:param specification: new specification ... | [
"def",
"add_specification",
"(",
"self",
",",
"specification",
")",
":",
"name",
"=",
"specification",
".",
"name",
"(",
")",
"if",
"name",
"in",
"self",
".",
"__specs",
":",
"raise",
"ValueError",
"(",
"'WStrictURIQuery object already has specification for paramete... | Add a new query parameter specification. If this object already has a specification for the
specified parameter - exception is raised. No checks for the specified or any parameter are made
regarding specification appending
:param specification: new specification that will be added
:return: None | [
"Add",
"a",
"new",
"query",
"parameter",
"specification",
".",
"If",
"this",
"object",
"already",
"has",
"a",
"specification",
"for",
"the",
"specified",
"parameter",
"-",
"exception",
"is",
"raised",
".",
"No",
"checks",
"for",
"the",
"specified",
"or",
"an... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L380-L391 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WStrictURIQuery.remove_specification | def remove_specification(self, name):
""" Remove a specification that matches a query parameter. No checks for the specified or any parameter
are made regarding specification removing
:param name: parameter name to remove
:return: None
"""
if name in self.__specs:
self.__specs.pop(name) | python | def remove_specification(self, name):
""" Remove a specification that matches a query parameter. No checks for the specified or any parameter
are made regarding specification removing
:param name: parameter name to remove
:return: None
"""
if name in self.__specs:
self.__specs.pop(name) | [
"def",
"remove_specification",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"__specs",
":",
"self",
".",
"__specs",
".",
"pop",
"(",
"name",
")"
] | Remove a specification that matches a query parameter. No checks for the specified or any parameter
are made regarding specification removing
:param name: parameter name to remove
:return: None | [
"Remove",
"a",
"specification",
"that",
"matches",
"a",
"query",
"parameter",
".",
"No",
"checks",
"for",
"the",
"specified",
"or",
"any",
"parameter",
"are",
"made",
"regarding",
"specification",
"removing"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L394-L402 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WStrictURIQuery.replace_parameter | def replace_parameter(self, name, value=None):
""" Replace a query parameter values with a new value. If a new value does not match current
specifications, then exception is raised
:param name: parameter name to replace
:param value: new parameter value. None is for empty (null) value
:return: None
"""
s... | python | def replace_parameter(self, name, value=None):
""" Replace a query parameter values with a new value. If a new value does not match current
specifications, then exception is raised
:param name: parameter name to replace
:param value: new parameter value. None is for empty (null) value
:return: None
"""
s... | [
"def",
"replace_parameter",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"spec",
"=",
"self",
".",
"__specs",
"[",
"name",
"]",
"if",
"name",
"in",
"self",
".",
"__specs",
"else",
"None",
"if",
"self",
".",
"extra_parameters",
"(",
... | Replace a query parameter values with a new value. If a new value does not match current
specifications, then exception is raised
:param name: parameter name to replace
:param value: new parameter value. None is for empty (null) value
:return: None | [
"Replace",
"a",
"query",
"parameter",
"values",
"with",
"a",
"new",
"value",
".",
"If",
"a",
"new",
"value",
"does",
"not",
"match",
"current",
"specifications",
"then",
"exception",
"is",
"raised"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L405-L425 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WStrictURIQuery.remove_parameter | def remove_parameter(self, name):
""" Remove parameter from this query. If a parameter is mandatory, then exception is raised
:param name: parameter name to remove
:return: None
"""
spec = self.__specs[name] if name in self.__specs else None
if spec is not None and spec.optional() is False:
raise ValueE... | python | def remove_parameter(self, name):
""" Remove parameter from this query. If a parameter is mandatory, then exception is raised
:param name: parameter name to remove
:return: None
"""
spec = self.__specs[name] if name in self.__specs else None
if spec is not None and spec.optional() is False:
raise ValueE... | [
"def",
"remove_parameter",
"(",
"self",
",",
"name",
")",
":",
"spec",
"=",
"self",
".",
"__specs",
"[",
"name",
"]",
"if",
"name",
"in",
"self",
".",
"__specs",
"else",
"None",
"if",
"spec",
"is",
"not",
"None",
"and",
"spec",
".",
"optional",
"(",
... | Remove parameter from this query. If a parameter is mandatory, then exception is raised
:param name: parameter name to remove
:return: None | [
"Remove",
"parameter",
"from",
"this",
"query",
".",
"If",
"a",
"parameter",
"is",
"mandatory",
"then",
"exception",
"is",
"raised"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L454-L464 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURIComponentVerifier.validate | def validate(self, uri):
""" Check an URI for compatibility with this specification. Return True if the URI is compatible.
:param uri: an URI to check
:return: bool
"""
requirement = self.requirement()
uri_component = uri.component(self.component())
if uri_component is None:
return requirement != WU... | python | def validate(self, uri):
""" Check an URI for compatibility with this specification. Return True if the URI is compatible.
:param uri: an URI to check
:return: bool
"""
requirement = self.requirement()
uri_component = uri.component(self.component())
if uri_component is None:
return requirement != WU... | [
"def",
"validate",
"(",
"self",
",",
"uri",
")",
":",
"requirement",
"=",
"self",
".",
"requirement",
"(",
")",
"uri_component",
"=",
"uri",
".",
"component",
"(",
"self",
".",
"component",
"(",
")",
")",
"if",
"uri_component",
"is",
"None",
":",
"retu... | Check an URI for compatibility with this specification. Return True if the URI is compatible.
:param uri: an URI to check
:return: bool | [
"Check",
"an",
"URI",
"for",
"compatibility",
"with",
"this",
"specification",
".",
"Return",
"True",
"if",
"the",
"URI",
"is",
"compatible",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L537-L555 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WURIQueryVerifier.validate | def validate(self, uri):
""" Check that an query part of an URI is compatible with this descriptor. Return True if the URI is
compatible.
:param uri: an URI to check
:return: bool
"""
if WURIComponentVerifier.validate(self, uri) is False:
return False
try:
WStrictURIQuery(
WURIQuery.parse(uri.... | python | def validate(self, uri):
""" Check that an query part of an URI is compatible with this descriptor. Return True if the URI is
compatible.
:param uri: an URI to check
:return: bool
"""
if WURIComponentVerifier.validate(self, uri) is False:
return False
try:
WStrictURIQuery(
WURIQuery.parse(uri.... | [
"def",
"validate",
"(",
"self",
",",
"uri",
")",
":",
"if",
"WURIComponentVerifier",
".",
"validate",
"(",
"self",
",",
"uri",
")",
"is",
"False",
":",
"return",
"False",
"try",
":",
"WStrictURIQuery",
"(",
"WURIQuery",
".",
"parse",
"(",
"uri",
".",
"... | Check that an query part of an URI is compatible with this descriptor. Return True if the URI is
compatible.
:param uri: an URI to check
:return: bool | [
"Check",
"that",
"an",
"query",
"part",
"of",
"an",
"URI",
"is",
"compatible",
"with",
"this",
"descriptor",
".",
"Return",
"True",
"if",
"the",
"URI",
"is",
"compatible",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L576-L594 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WSchemeSpecification.is_compatible | def is_compatible(self, uri):
""" Check if URI is compatible with this specification. Compatible URI has scheme name that matches
specification scheme name, has all of the required components, does not have unsupported components
and may have optional components
:param uri: URI to check
:return: bool
"""
... | python | def is_compatible(self, uri):
""" Check if URI is compatible with this specification. Compatible URI has scheme name that matches
specification scheme name, has all of the required components, does not have unsupported components
and may have optional components
:param uri: URI to check
:return: bool
"""
... | [
"def",
"is_compatible",
"(",
"self",
",",
"uri",
")",
":",
"for",
"component",
",",
"component_value",
"in",
"uri",
":",
"if",
"self",
".",
"verifier",
"(",
"component",
")",
".",
"validate",
"(",
"uri",
")",
"is",
"False",
":",
"return",
"False",
"ret... | Check if URI is compatible with this specification. Compatible URI has scheme name that matches
specification scheme name, has all of the required components, does not have unsupported components
and may have optional components
:param uri: URI to check
:return: bool | [
"Check",
"if",
"URI",
"is",
"compatible",
"with",
"this",
"specification",
".",
"Compatible",
"URI",
"has",
"scheme",
"name",
"that",
"matches",
"specification",
"scheme",
"name",
"has",
"all",
"of",
"the",
"required",
"components",
"does",
"not",
"have",
"uns... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L658-L670 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WSchemeCollection.handler | def handler(self, scheme_name=None):
""" Return handler which scheme name matches the specified one
:param scheme_name: scheme name to search for
:return: WSchemeHandler class or None (if matching handler was not found)
"""
if scheme_name is None:
return self.__default_handler_cls
for handler in self.__... | python | def handler(self, scheme_name=None):
""" Return handler which scheme name matches the specified one
:param scheme_name: scheme name to search for
:return: WSchemeHandler class or None (if matching handler was not found)
"""
if scheme_name is None:
return self.__default_handler_cls
for handler in self.__... | [
"def",
"handler",
"(",
"self",
",",
"scheme_name",
"=",
"None",
")",
":",
"if",
"scheme_name",
"is",
"None",
":",
"return",
"self",
".",
"__default_handler_cls",
"for",
"handler",
"in",
"self",
".",
"__handlers_cls",
":",
"if",
"handler",
".",
"scheme_specif... | Return handler which scheme name matches the specified one
:param scheme_name: scheme name to search for
:return: WSchemeHandler class or None (if matching handler was not found) | [
"Return",
"handler",
"which",
"scheme",
"name",
"matches",
"the",
"specified",
"one"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L752-L762 | train |
a1ezzz/wasp-general | wasp_general/uri.py | WSchemeCollection.open | def open(self, uri, **kwargs):
""" Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and
WSchemeCollection.SchemeIncompatible may be raised.
:param uri: URI to search handler for
:param kwargs: additional arguments that may be used by a handler specialization
:return: W... | python | def open(self, uri, **kwargs):
""" Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and
WSchemeCollection.SchemeIncompatible may be raised.
:param uri: URI to search handler for
:param kwargs: additional arguments that may be used by a handler specialization
:return: W... | [
"def",
"open",
"(",
"self",
",",
"uri",
",",
"*",
"*",
"kwargs",
")",
":",
"handler",
"=",
"self",
".",
"handler",
"(",
"uri",
".",
"scheme",
"(",
")",
")",
"if",
"handler",
"is",
"None",
":",
"raise",
"WSchemeCollection",
".",
"NoHandlerFound",
"(",... | Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and
WSchemeCollection.SchemeIncompatible may be raised.
:param uri: URI to search handler for
:param kwargs: additional arguments that may be used by a handler specialization
:return: WSchemeHandler | [
"Return",
"handler",
"instance",
"that",
"matches",
"the",
"specified",
"URI",
".",
"WSchemeCollection",
".",
"NoHandlerFound",
"and",
"WSchemeCollection",
".",
"SchemeIncompatible",
"may",
"be",
"raised",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L765-L783 | train |
olitheolix/qtmacs | qtmacs/applets/webbrowser.py | WebBrowser.loadFile | def loadFile(self, fileName):
"""
Load the URL ``fileName``.
"""
self.fileName = fileName
self.qteWeb.load(QtCore.QUrl(fileName)) | python | def loadFile(self, fileName):
"""
Load the URL ``fileName``.
"""
self.fileName = fileName
self.qteWeb.load(QtCore.QUrl(fileName)) | [
"def",
"loadFile",
"(",
"self",
",",
"fileName",
")",
":",
"self",
".",
"fileName",
"=",
"fileName",
"self",
".",
"qteWeb",
".",
"load",
"(",
"QtCore",
".",
"QUrl",
"(",
"fileName",
")",
")"
] | Load the URL ``fileName``. | [
"Load",
"the",
"URL",
"fileName",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/webbrowser.py#L85-L90 | train |
weijia/djangoautoconf | djangoautoconf/class_based_views/ajax_views.py | AjaxableViewMixin.render_to_response | def render_to_response(self, context, **response_kwargs):
"""
Returns a response with a template rendered with the given context.
"""
context["ajax_form_id"] = self.ajax_form_id
# context["base_template"] = "towel_bootstrap/modal.html"
return self.response_class(
... | python | def render_to_response(self, context, **response_kwargs):
"""
Returns a response with a template rendered with the given context.
"""
context["ajax_form_id"] = self.ajax_form_id
# context["base_template"] = "towel_bootstrap/modal.html"
return self.response_class(
... | [
"def",
"render_to_response",
"(",
"self",
",",
"context",
",",
"*",
"*",
"response_kwargs",
")",
":",
"context",
"[",
"\"ajax_form_id\"",
"]",
"=",
"self",
".",
"ajax_form_id",
"# context[\"base_template\"] = \"towel_bootstrap/modal.html\"",
"return",
"self",
".",
"re... | Returns a response with a template rendered with the given context. | [
"Returns",
"a",
"response",
"with",
"a",
"template",
"rendered",
"with",
"the",
"given",
"context",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/ajax_views.py#L47-L58 | train |
consbio/restle | restle/fields.py | TextField.to_python | def to_python(self, value, resource):
"""Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode"""
if value is None:
return self._transform(value)
if isinstance(value, six.text_type):
return self._transform(value)
i... | python | def to_python(self, value, resource):
"""Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode"""
if value is None:
return self._transform(value)
if isinstance(value, six.text_type):
return self._transform(value)
i... | [
"def",
"to_python",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"self",
".",
"_transform",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"return",
"s... | Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode | [
"Converts",
"to",
"unicode",
"if",
"self",
".",
"encoding",
"!",
"=",
"None",
"otherwise",
"returns",
"input",
"without",
"attempting",
"to",
"decode"
] | 60d100da034c612d4910f4f79eaa57a76eb3dcc6 | https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L72-L87 | train |
consbio/restle | restle/fields.py | ObjectField.to_python | def to_python(self, value, resource):
"""Dictionary to Python object"""
if isinstance(value, dict):
d = {
self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v
for k, v in six.iteritems(value)
}
retu... | python | def to_python(self, value, resource):
"""Dictionary to Python object"""
if isinstance(value, dict):
d = {
self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v
for k, v in six.iteritems(value)
}
retu... | [
"def",
"to_python",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"d",
"=",
"{",
"self",
".",
"aliases",
".",
"get",
"(",
"k",
",",
"k",
")",
":",
"self",
".",
"to_python",
"(",
"... | Dictionary to Python object | [
"Dictionary",
"to",
"Python",
"object"
] | 60d100da034c612d4910f4f79eaa57a76eb3dcc6 | https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L145-L157 | train |
consbio/restle | restle/fields.py | ObjectField.to_value | def to_value(self, obj, resource, visited=set()):
"""Python object to dictionary"""
if id(obj) in visited:
raise ValueError('Circular reference detected when attempting to serialize object')
if isinstance(obj, (list, tuple, set)):
return [self.to_value(x, resource) if h... | python | def to_value(self, obj, resource, visited=set()):
"""Python object to dictionary"""
if id(obj) in visited:
raise ValueError('Circular reference detected when attempting to serialize object')
if isinstance(obj, (list, tuple, set)):
return [self.to_value(x, resource) if h... | [
"def",
"to_value",
"(",
"self",
",",
"obj",
",",
"resource",
",",
"visited",
"=",
"set",
"(",
")",
")",
":",
"if",
"id",
"(",
"obj",
")",
"in",
"visited",
":",
"raise",
"ValueError",
"(",
"'Circular reference detected when attempting to serialize object'",
")"... | Python object to dictionary | [
"Python",
"object",
"to",
"dictionary"
] | 60d100da034c612d4910f4f79eaa57a76eb3dcc6 | https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L159-L179 | train |
a1ezzz/wasp-general | wasp_general/network/beacon/messenger.py | WBeaconGouverneurMessenger.hello_message | def hello_message(self, invert_hello=False):
""" Return message header.
:param invert_hello: whether to return the original header (in case of False value) or reversed \
one (in case of True value).
:return: bytes
"""
if invert_hello is False:
return self.__gouverneur_message
hello_message = []
for... | python | def hello_message(self, invert_hello=False):
""" Return message header.
:param invert_hello: whether to return the original header (in case of False value) or reversed \
one (in case of True value).
:return: bytes
"""
if invert_hello is False:
return self.__gouverneur_message
hello_message = []
for... | [
"def",
"hello_message",
"(",
"self",
",",
"invert_hello",
"=",
"False",
")",
":",
"if",
"invert_hello",
"is",
"False",
":",
"return",
"self",
".",
"__gouverneur_message",
"hello_message",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
... | Return message header.
:param invert_hello: whether to return the original header (in case of False value) or reversed \
one (in case of True value).
:return: bytes | [
"Return",
"message",
"header",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L200-L213 | train |
a1ezzz/wasp-general | wasp_general/network/beacon/messenger.py | WBeaconGouverneurMessenger._message_address_parse | def _message_address_parse(self, message, invert_hello=False):
""" Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns
:param message: message to parse
:param invert_hello: defines whether message header is the original one or reversed.
:return: WIPV4SocketInfo
... | python | def _message_address_parse(self, message, invert_hello=False):
""" Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns
:param message: message to parse
:param invert_hello: defines whether message header is the original one or reversed.
:return: WIPV4SocketInfo
... | [
"def",
"_message_address_parse",
"(",
"self",
",",
"message",
",",
"invert_hello",
"=",
"False",
")",
":",
"message_header",
"=",
"self",
".",
"hello_message",
"(",
"invert_hello",
"=",
"invert_hello",
")",
"if",
"message",
"[",
":",
"len",
"(",
"message_heade... | Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns
:param message: message to parse
:param invert_hello: defines whether message header is the original one or reversed.
:return: WIPV4SocketInfo | [
"Read",
"address",
"from",
"beacon",
"message",
".",
"If",
"no",
"address",
"is",
"specified",
"then",
"nullable",
"WIPV4SocketInfo",
"returns"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L254-L280 | train |
a1ezzz/wasp-general | wasp_general/crypto/aes.py | WAES.cipher | def cipher(self):
""" Generate AES-cipher
:return: Crypto.Cipher.AES.AESCipher
"""
#cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs())
cipher = Cipher(*self.mode().aes_args(), **self.mode().aes_kwargs())
return WAES.WAESCipher(cipher) | python | def cipher(self):
""" Generate AES-cipher
:return: Crypto.Cipher.AES.AESCipher
"""
#cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs())
cipher = Cipher(*self.mode().aes_args(), **self.mode().aes_kwargs())
return WAES.WAESCipher(cipher) | [
"def",
"cipher",
"(",
"self",
")",
":",
"#cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs())",
"cipher",
"=",
"Cipher",
"(",
"*",
"self",
".",
"mode",
"(",
")",
".",
"aes_args",
"(",
")",
",",
"*",
"*",
"self",
".",
"mode",
"(",
")",
"."... | Generate AES-cipher
:return: Crypto.Cipher.AES.AESCipher | [
"Generate",
"AES",
"-",
"cipher"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L491-L498 | train |
a1ezzz/wasp-general | wasp_general/crypto/aes.py | WAES.encrypt | def encrypt(self, data):
""" Encrypt the given data with cipher that is got from AES.cipher call.
:param data: data to encrypt
:return: bytes
"""
padding = self.mode().padding()
if padding is not None:
data = padding.pad(data, WAESMode.__data_padding_length__)
return self.cipher().encrypt_block(data) | python | def encrypt(self, data):
""" Encrypt the given data with cipher that is got from AES.cipher call.
:param data: data to encrypt
:return: bytes
"""
padding = self.mode().padding()
if padding is not None:
data = padding.pad(data, WAESMode.__data_padding_length__)
return self.cipher().encrypt_block(data) | [
"def",
"encrypt",
"(",
"self",
",",
"data",
")",
":",
"padding",
"=",
"self",
".",
"mode",
"(",
")",
".",
"padding",
"(",
")",
"if",
"padding",
"is",
"not",
"None",
":",
"data",
"=",
"padding",
".",
"pad",
"(",
"data",
",",
"WAESMode",
".",
"__da... | Encrypt the given data with cipher that is got from AES.cipher call.
:param data: data to encrypt
:return: bytes | [
"Encrypt",
"the",
"given",
"data",
"with",
"cipher",
"that",
"is",
"got",
"from",
"AES",
".",
"cipher",
"call",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L501-L511 | train |
a1ezzz/wasp-general | wasp_general/crypto/aes.py | WAES.decrypt | def decrypt(self, data, decode=False):
""" Decrypt the given data with cipher that is got from AES.cipher call.
:param data: data to decrypt
:param decode: whether to decode bytes to str or not
:return: bytes or str (depends on decode flag)
"""
#result = self.cipher().decrypt(data)
result = self.cipher(... | python | def decrypt(self, data, decode=False):
""" Decrypt the given data with cipher that is got from AES.cipher call.
:param data: data to decrypt
:param decode: whether to decode bytes to str or not
:return: bytes or str (depends on decode flag)
"""
#result = self.cipher().decrypt(data)
result = self.cipher(... | [
"def",
"decrypt",
"(",
"self",
",",
"data",
",",
"decode",
"=",
"False",
")",
":",
"#result = self.cipher().decrypt(data)",
"result",
"=",
"self",
".",
"cipher",
"(",
")",
".",
"decrypt_block",
"(",
"data",
")",
"padding",
"=",
"self",
".",
"mode",
"(",
... | Decrypt the given data with cipher that is got from AES.cipher call.
:param data: data to decrypt
:param decode: whether to decode bytes to str or not
:return: bytes or str (depends on decode flag) | [
"Decrypt",
"the",
"given",
"data",
"with",
"cipher",
"that",
"is",
"got",
"from",
"AES",
".",
"cipher",
"call",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L515-L530 | train |
a1ezzz/wasp-general | wasp_general/task/thread_tracker.py | WThreadTracker.thread_tracker_exception | def thread_tracker_exception(self, raised_exception):
""" Method is called whenever an exception is raised during registering a event
:param raised_exception: raised exception
:return: None
"""
print('Thread tracker execution was stopped by the exception. Exception: %s' % str(raised_exception))
print('Tra... | python | def thread_tracker_exception(self, raised_exception):
""" Method is called whenever an exception is raised during registering a event
:param raised_exception: raised exception
:return: None
"""
print('Thread tracker execution was stopped by the exception. Exception: %s' % str(raised_exception))
print('Tra... | [
"def",
"thread_tracker_exception",
"(",
"self",
",",
"raised_exception",
")",
":",
"print",
"(",
"'Thread tracker execution was stopped by the exception. Exception: %s'",
"%",
"str",
"(",
"raised_exception",
")",
")",
"print",
"(",
"'Traceback:'",
")",
"print",
"(",
"tr... | Method is called whenever an exception is raised during registering a event
:param raised_exception: raised exception
:return: None | [
"Method",
"is",
"called",
"whenever",
"an",
"exception",
"is",
"raised",
"during",
"registering",
"a",
"event"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L278-L287 | train |
a1ezzz/wasp-general | wasp_general/task/thread_tracker.py | WSimpleTrackerStorage.__store_record | def __store_record(self, record):
""" Save record in a internal storage
:param record: record to save
:return: None
"""
if isinstance(record, WSimpleTrackerStorage.Record) is False:
raise TypeError('Invalid record type was')
limit = self.record_limit()
if limit is not None and len(self.__registry) >=... | python | def __store_record(self, record):
""" Save record in a internal storage
:param record: record to save
:return: None
"""
if isinstance(record, WSimpleTrackerStorage.Record) is False:
raise TypeError('Invalid record type was')
limit = self.record_limit()
if limit is not None and len(self.__registry) >=... | [
"def",
"__store_record",
"(",
"self",
",",
"record",
")",
":",
"if",
"isinstance",
"(",
"record",
",",
"WSimpleTrackerStorage",
".",
"Record",
")",
"is",
"False",
":",
"raise",
"TypeError",
"(",
"'Invalid record type was'",
")",
"limit",
"=",
"self",
".",
"r... | Save record in a internal storage
:param record: record to save
:return: None | [
"Save",
"record",
"in",
"a",
"internal",
"storage"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L461-L473 | train |
shaypal5/strct | strct/dicts/_dict.py | put_nested_val | def put_nested_val(dict_obj, key_tuple, value):
"""Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting,... | python | def put_nested_val(dict_obj, key_tuple, value):
"""Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting,... | [
"def",
"put_nested_val",
"(",
"dict_obj",
",",
"key_tuple",
",",
"value",
")",
":",
"current_dict",
"=",
"dict_obj",
"for",
"key",
"in",
"key_tuple",
"[",
":",
"-",
"1",
"]",
":",
"try",
":",
"current_dict",
"=",
"current_dict",
"[",
"key",
"]",
"except"... | Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting, in order.
value : object
The value to put.... | [
"Put",
"a",
"value",
"into",
"nested",
"dicts",
"by",
"the",
"order",
"of",
"the",
"given",
"keys",
"tuple",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L131-L168 | train |
shaypal5/strct | strct/dicts/_dict.py | get_alternative_nested_val | def get_alternative_nested_val(key_tuple, dict_obj):
"""Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
----... | python | def get_alternative_nested_val(key_tuple, dict_obj):
"""Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
----... | [
"def",
"get_alternative_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
")",
":",
"# print('key_tuple: {}'.format(key_tuple))",
"# print('dict_obj: {}'.format(dict_obj))",
"top_keys",
"=",
"key_tuple",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"key_tuple",
"[",
"0",
"]",
... | Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
-------
value : object
The extracted value, if exist... | [
"Return",
"a",
"value",
"from",
"nested",
"dicts",
"by",
"any",
"path",
"in",
"the",
"given",
"keys",
"tuple",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L198-L230 | train |
shaypal5/strct | strct/dicts/_dict.py | subdict_by_keys | def subdict_by_keys(dict_obj, keys):
"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
... | python | def subdict_by_keys(dict_obj, keys):
"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
... | [
"def",
"subdict_by_keys",
"(",
"dict_obj",
",",
"keys",
")",
":",
"return",
"{",
"k",
":",
"dict_obj",
"[",
"k",
"]",
"for",
"k",
"in",
"set",
"(",
"keys",
")",
".",
"intersection",
"(",
"dict_obj",
".",
"keys",
"(",
")",
")",
"}"
] | Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
Returns
-------
dict
A su... | [
"Returns",
"a",
"sub",
"-",
"dict",
"composed",
"solely",
"of",
"the",
"given",
"keys",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L289-L312 | train |
shaypal5/strct | strct/dicts/_dict.py | add_to_dict_val_set | def add_to_dict_val_set(dict_obj, key, val):
"""Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1... | python | def add_to_dict_val_set(dict_obj, key, val):
"""Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1... | [
"def",
"add_to_dict_val_set",
"(",
"dict_obj",
",",
"key",
",",
"val",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"add",
"(",
"val",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"set",
"(",
"[",
"val",
"]",
")"
] | Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1, 2}
>>> add_to_dict_val_set(dict_obj, 'a', 3)
... | [
"Adds",
"the",
"given",
"val",
"to",
"the",
"set",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L386-L403 | train |
shaypal5/strct | strct/dicts/_dict.py | add_many_to_dict_val_set | def add_many_to_dict_val_set(dict_obj, key, val_list):
"""Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> ... | python | def add_many_to_dict_val_set(dict_obj, key, val_list):
"""Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> ... | [
"def",
"add_many_to_dict_val_set",
"(",
"dict_obj",
",",
"key",
",",
"val_list",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"update",
"(",
"val_list",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"set",
"(",
"val_list",
... | Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> print(dict_obj['a'])
{1, 2, 3}
>>> add_many_to_dict_va... | [
"Adds",
"the",
"given",
"value",
"list",
"to",
"the",
"set",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L406-L423 | train |
shaypal5/strct | strct/dicts/_dict.py | add_many_to_dict_val_list | def add_many_to_dict_val_list(dict_obj, key, val_list):
"""Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> pr... | python | def add_many_to_dict_val_list(dict_obj, key, val_list):
"""Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> pr... | [
"def",
"add_many_to_dict_val_list",
"(",
"dict_obj",
",",
"key",
",",
"val_list",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"extend",
"(",
"val_list",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"list",
"(",
"val_list"... | Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> print(dict_obj['a'])
[1, 2, 2, 3]
>>> add_many_to_dict_va... | [
"Adds",
"the",
"given",
"value",
"list",
"to",
"the",
"list",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L426-L443 | train |
shaypal5/strct | strct/dicts/_dict.py | get_keys_of_max_n | def get_keys_of_max_n(dict_obj, n):
"""Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c']
"""
return sorted([
item[0]
for item in sorted(
d... | python | def get_keys_of_max_n(dict_obj, n):
"""Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c']
"""
return sorted([
item[0]
for item in sorted(
d... | [
"def",
"get_keys_of_max_n",
"(",
"dict_obj",
",",
"n",
")",
":",
"return",
"sorted",
"(",
"[",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"sorted",
"(",
"dict_obj",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"item",
":",
"item",
"[",
"1",
... | Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c'] | [
"Returns",
"the",
"keys",
"that",
"maps",
"to",
"the",
"top",
"n",
"max",
"values",
"in",
"the",
"given",
"dict",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L459-L473 | train |
shaypal5/strct | strct/dicts/_dict.py | deep_merge_dict | def deep_merge_dict(base, priority):
"""Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in t... | python | def deep_merge_dict(base, priority):
"""Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in t... | [
"def",
"deep_merge_dict",
"(",
"base",
",",
"priority",
")",
":",
"if",
"not",
"isinstance",
"(",
"base",
",",
"dict",
")",
"or",
"not",
"isinstance",
"(",
"priority",
",",
"dict",
")",
":",
"return",
"priority",
"result",
"=",
"copy",
".",
"deepcopy",
... | Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in the result.
2. Subtrees of base are overw... | [
"Recursively",
"merges",
"the",
"two",
"given",
"dicts",
"into",
"a",
"single",
"dict",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L539-L578 | train |
shaypal5/strct | strct/dicts/_dict.py | norm_int_dict | def norm_int_dict(int_dict):
"""Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dic... | python | def norm_int_dict(int_dict):
"""Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dic... | [
"def",
"norm_int_dict",
"(",
"int_dict",
")",
":",
"norm_dict",
"=",
"int_dict",
".",
"copy",
"(",
")",
"val_sum",
"=",
"sum",
"(",
"norm_dict",
".",
"values",
"(",
")",
")",
"for",
"key",
"in",
"norm_dict",
":",
"norm_dict",
"[",
"key",
"]",
"=",
"n... | Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dict values.
Example
-------
... | [
"Normalizes",
"values",
"in",
"the",
"given",
"dict",
"with",
"int",
"values",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L581-L606 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.