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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
KE-works/pykechain | pykechain/utils.py | parse_datetime | def parse_datetime(value):
"""
Convert datetime string to datetime object.
Helper function to convert a datetime string found in json responses to a datetime object with timezone information.
The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When
... | python | def parse_datetime(value):
"""
Convert datetime string to datetime object.
Helper function to convert a datetime string found in json responses to a datetime object with timezone information.
The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When
... | [
"def",
"parse_datetime",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"def",
"_get_fixed_timezone",
"(",
"offset",
")",
":",
"if",
"isinstance",
"(",
"offset",
",",
"timedelta",
")",
":",
"offset",
"=",
"offset",
".",
"seco... | Convert datetime string to datetime object.
Helper function to convert a datetime string found in json responses to a datetime object with timezone information.
The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When
the input contains one, the output u... | [
"Convert",
"datetime",
"string",
"to",
"datetime",
"object",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/utils.py#L86-L144 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization._save_customization | def _save_customization(self, widgets):
"""
Save the complete customization to the activity.
:param widgets: The complete set of widgets to be customized
"""
if len(widgets) > 0:
# Get the current customization and only replace the 'ext' part of it
custom... | python | def _save_customization(self, widgets):
"""
Save the complete customization to the activity.
:param widgets: The complete set of widgets to be customized
"""
if len(widgets) > 0:
# Get the current customization and only replace the 'ext' part of it
custom... | [
"def",
"_save_customization",
"(",
"self",
",",
"widgets",
")",
":",
"if",
"len",
"(",
"widgets",
")",
">",
"0",
":",
"customization",
"=",
"self",
".",
"activity",
".",
"_json_data",
".",
"get",
"(",
"'customization'",
",",
"dict",
"(",
")",
")",
"if"... | Save the complete customization to the activity.
:param widgets: The complete set of widgets to be customized | [
"Save",
"the",
"complete",
"customization",
"to",
"the",
"activity",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L96-L126 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization._add_widget | def _add_widget(self, widget):
"""
Add a widget to the customization.
Will save the widget to KE-chain.
:param widget: The widget (specific json dict) to be added
:type widget: dict
"""
widgets = self.widgets()
widgets += [widget]
self._save_cust... | python | def _add_widget(self, widget):
"""
Add a widget to the customization.
Will save the widget to KE-chain.
:param widget: The widget (specific json dict) to be added
:type widget: dict
"""
widgets = self.widgets()
widgets += [widget]
self._save_cust... | [
"def",
"_add_widget",
"(",
"self",
",",
"widget",
")",
":",
"widgets",
"=",
"self",
".",
"widgets",
"(",
")",
"widgets",
"+=",
"[",
"widget",
"]",
"self",
".",
"_save_customization",
"(",
"widgets",
")"
] | Add a widget to the customization.
Will save the widget to KE-chain.
:param widget: The widget (specific json dict) to be added
:type widget: dict | [
"Add",
"a",
"widget",
"to",
"the",
"customization",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L128-L139 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization.widgets | def widgets(self):
"""
Get the Ext JS specific customization from the activity.
:return: The Ext JS specific customization in `list(dict)` form
"""
customization = self.activity._json_data.get('customization')
if customization and "ext" in customization.keys():
... | python | def widgets(self):
"""
Get the Ext JS specific customization from the activity.
:return: The Ext JS specific customization in `list(dict)` form
"""
customization = self.activity._json_data.get('customization')
if customization and "ext" in customization.keys():
... | [
"def",
"widgets",
"(",
"self",
")",
":",
"customization",
"=",
"self",
".",
"activity",
".",
"_json_data",
".",
"get",
"(",
"'customization'",
")",
"if",
"customization",
"and",
"\"ext\"",
"in",
"customization",
".",
"keys",
"(",
")",
":",
"return",
"custo... | Get the Ext JS specific customization from the activity.
:return: The Ext JS specific customization in `list(dict)` form | [
"Get",
"the",
"Ext",
"JS",
"specific",
"customization",
"from",
"the",
"activity",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L141-L152 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization.delete_widget | def delete_widget(self, index):
"""
Delete widgets by index.
The widgets are saved to KE-chain.
:param index: The index of the widget to be deleted in the self.widgets
:type index: int
:raises ValueError: if the customization has no widgets
"""
widgets =... | python | def delete_widget(self, index):
"""
Delete widgets by index.
The widgets are saved to KE-chain.
:param index: The index of the widget to be deleted in the self.widgets
:type index: int
:raises ValueError: if the customization has no widgets
"""
widgets =... | [
"def",
"delete_widget",
"(",
"self",
",",
"index",
")",
":",
"widgets",
"=",
"self",
".",
"widgets",
"(",
")",
"if",
"len",
"(",
"widgets",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"This customization has no widgets\"",
")",
"widgets",
".",
"pop"... | Delete widgets by index.
The widgets are saved to KE-chain.
:param index: The index of the widget to be deleted in the self.widgets
:type index: int
:raises ValueError: if the customization has no widgets | [
"Delete",
"widgets",
"by",
"index",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L154-L168 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization.add_json_widget | def add_json_widget(self, config):
"""
Add an Ext Json Widget to the customization.
The configuration json provided must be interpretable by KE-chain. The json will be validated
against the widget json schema.
The widget will be saved to KE-chain.
:param config: The js... | python | def add_json_widget(self, config):
"""
Add an Ext Json Widget to the customization.
The configuration json provided must be interpretable by KE-chain. The json will be validated
against the widget json schema.
The widget will be saved to KE-chain.
:param config: The js... | [
"def",
"add_json_widget",
"(",
"self",
",",
"config",
")",
":",
"validate",
"(",
"config",
",",
"component_jsonwidget_schema",
")",
"self",
".",
"_add_widget",
"(",
"dict",
"(",
"config",
"=",
"config",
",",
"name",
"=",
"WidgetNames",
".",
"JSONWIDGET",
")"... | Add an Ext Json Widget to the customization.
The configuration json provided must be interpretable by KE-chain. The json will be validated
against the widget json schema.
The widget will be saved to KE-chain.
:param config: The json configuration of the widget
:type config: di... | [
"Add",
"an",
"Ext",
"Json",
"Widget",
"to",
"the",
"customization",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L177-L190 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization.add_property_grid_widget | def add_property_grid_widget(self, part_instance, max_height=None, custom_title=False, show_headers=True,
show_columns=None):
"""
Add a KE-chain Property Grid widget to the customization.
The widget will be saved to KE-chain.
:param part_instance: The p... | python | def add_property_grid_widget(self, part_instance, max_height=None, custom_title=False, show_headers=True,
show_columns=None):
"""
Add a KE-chain Property Grid widget to the customization.
The widget will be saved to KE-chain.
:param part_instance: The p... | [
"def",
"add_property_grid_widget",
"(",
"self",
",",
"part_instance",
",",
"max_height",
"=",
"None",
",",
"custom_title",
"=",
"False",
",",
"show_headers",
"=",
"True",
",",
"show_columns",
"=",
"None",
")",
":",
"height",
"=",
"max_height",
"if",
"isinstanc... | Add a KE-chain Property Grid widget to the customization.
The widget will be saved to KE-chain.
:param part_instance: The part instance on which the property grid will be based
:type part_instance: :class:`Part` or UUID
:param max_height: The max height of the property grid in pixels
... | [
"Add",
"a",
"KE",
"-",
"chain",
"Property",
"Grid",
"widget",
"to",
"the",
"customization",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L360-L450 | train |
KE-works/pykechain | pykechain/models/customization.py | ExtCustomization.add_text_widget | def add_text_widget(self, text=None, custom_title=None, collapsible=True, collapsed=False):
"""
Add a KE-chain Text widget to the customization.
The widget will be saved to KE-chain.
:param text: The text that will be shown by the widget.
:type text: basestring or None
... | python | def add_text_widget(self, text=None, custom_title=None, collapsible=True, collapsed=False):
"""
Add a KE-chain Text widget to the customization.
The widget will be saved to KE-chain.
:param text: The text that will be shown by the widget.
:type text: basestring or None
... | [
"def",
"add_text_widget",
"(",
"self",
",",
"text",
"=",
"None",
",",
"custom_title",
"=",
"None",
",",
"collapsible",
"=",
"True",
",",
"collapsed",
"=",
"False",
")",
":",
"config",
"=",
"{",
"\"xtype\"",
":",
"ComponentXType",
".",
"HTMLPANEL",
",",
"... | Add a KE-chain Text widget to the customization.
The widget will be saved to KE-chain.
:param text: The text that will be shown by the widget.
:type text: basestring or None
:param custom_title: A custom title for the text panel::
* None (default): No title
* St... | [
"Add",
"a",
"KE",
"-",
"chain",
"Text",
"widget",
"to",
"the",
"customization",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L452-L504 | train |
lobocv/crashreporter | crashreporter/process.py | enable_mp_crash_reporting | def enable_mp_crash_reporting():
"""
Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess.
Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead.
This function must be called before any imports to mulitprocessing in order for the mon... | python | def enable_mp_crash_reporting():
"""
Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess.
Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead.
This function must be called before any imports to mulitprocessing in order for the mon... | [
"def",
"enable_mp_crash_reporting",
"(",
")",
":",
"global",
"mp_crash_reporting_enabled",
"multiprocessing",
".",
"Process",
"=",
"multiprocessing",
".",
"process",
".",
"Process",
"=",
"CrashReportingProcess",
"mp_crash_reporting_enabled",
"=",
"True"
] | Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess.
Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead.
This function must be called before any imports to mulitprocessing in order for the monkey-patching to work. | [
"Monkey",
"-",
"patch",
"the",
"multiprocessing",
".",
"Process",
"class",
"with",
"our",
"own",
"CrashReportingProcess",
".",
"Any",
"subsequent",
"imports",
"of",
"multiprocessing",
".",
"Process",
"will",
"reference",
"CrashReportingProcess",
"instead",
"."
] | a5bbb3f37977dc64bc865dfedafc365fd5469ef8 | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/process.py#L11-L20 | train |
thomasdelaet/python-velbus | velbus/parser.py | VelbusParser.feed | def feed(self, data):
"""
Add new incoming data to buffer and try to process
"""
self.buffer += data
while len(self.buffer) >= 6:
self.next_packet() | python | def feed(self, data):
"""
Add new incoming data to buffer and try to process
"""
self.buffer += data
while len(self.buffer) >= 6:
self.next_packet() | [
"def",
"feed",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"buffer",
"+=",
"data",
"while",
"len",
"(",
"self",
".",
"buffer",
")",
">=",
"6",
":",
"self",
".",
"next_packet",
"(",
")"
] | Add new incoming data to buffer and try to process | [
"Add",
"new",
"incoming",
"data",
"to",
"buffer",
"and",
"try",
"to",
"process"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L26-L32 | train |
thomasdelaet/python-velbus | velbus/parser.py | VelbusParser.valid_header_waiting | def valid_header_waiting(self):
"""
Check if a valid header is waiting in buffer
"""
if len(self.buffer) < 4:
self.logger.debug("Buffer does not yet contain full header")
result = False
else:
result = True
result = result and self.b... | python | def valid_header_waiting(self):
"""
Check if a valid header is waiting in buffer
"""
if len(self.buffer) < 4:
self.logger.debug("Buffer does not yet contain full header")
result = False
else:
result = True
result = result and self.b... | [
"def",
"valid_header_waiting",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"buffer",
")",
"<",
"4",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Buffer does not yet contain full header\"",
")",
"result",
"=",
"False",
"else",
":",
"result",
... | Check if a valid header is waiting in buffer | [
"Check",
"if",
"a",
"valid",
"header",
"is",
"waiting",
"in",
"buffer"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L34-L53 | train |
thomasdelaet/python-velbus | velbus/parser.py | VelbusParser.valid_body_waiting | def valid_body_waiting(self):
"""
Check if a valid body is waiting in buffer
"""
# 0f f8 be 04 00 08 00 00 2f 04
packet_size = velbus.MINIMUM_MESSAGE_SIZE + \
(self.buffer[3] & 0x0F)
if len(self.buffer) < packet_size:
self.logger.debug("Buffer does... | python | def valid_body_waiting(self):
"""
Check if a valid body is waiting in buffer
"""
# 0f f8 be 04 00 08 00 00 2f 04
packet_size = velbus.MINIMUM_MESSAGE_SIZE + \
(self.buffer[3] & 0x0F)
if len(self.buffer) < packet_size:
self.logger.debug("Buffer does... | [
"def",
"valid_body_waiting",
"(",
"self",
")",
":",
"packet_size",
"=",
"velbus",
".",
"MINIMUM_MESSAGE_SIZE",
"+",
"(",
"self",
".",
"buffer",
"[",
"3",
"]",
"&",
"0x0F",
")",
"if",
"len",
"(",
"self",
".",
"buffer",
")",
"<",
"packet_size",
":",
"sel... | Check if a valid body is waiting in buffer | [
"Check",
"if",
"a",
"valid",
"body",
"is",
"waiting",
"in",
"buffer"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L55-L75 | train |
thomasdelaet/python-velbus | velbus/parser.py | VelbusParser.next_packet | def next_packet(self):
"""
Process next packet if present
"""
try:
start_byte_index = self.buffer.index(velbus.START_BYTE)
except ValueError:
self.buffer = bytes([])
return
if start_byte_index >= 0:
self.buffer = self.buffer... | python | def next_packet(self):
"""
Process next packet if present
"""
try:
start_byte_index = self.buffer.index(velbus.START_BYTE)
except ValueError:
self.buffer = bytes([])
return
if start_byte_index >= 0:
self.buffer = self.buffer... | [
"def",
"next_packet",
"(",
"self",
")",
":",
"try",
":",
"start_byte_index",
"=",
"self",
".",
"buffer",
".",
"index",
"(",
"velbus",
".",
"START_BYTE",
")",
"except",
"ValueError",
":",
"self",
".",
"buffer",
"=",
"bytes",
"(",
"[",
"]",
")",
"return"... | Process next packet if present | [
"Process",
"next",
"packet",
"if",
"present"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L77-L93 | train |
thomasdelaet/python-velbus | velbus/parser.py | VelbusParser.extract_packet | def extract_packet(self):
"""
Extract packet from buffer
"""
packet_size = velbus.MINIMUM_MESSAGE_SIZE + \
(self.buffer[3] & 0x0F)
packet = self.buffer[0:packet_size]
return packet | python | def extract_packet(self):
"""
Extract packet from buffer
"""
packet_size = velbus.MINIMUM_MESSAGE_SIZE + \
(self.buffer[3] & 0x0F)
packet = self.buffer[0:packet_size]
return packet | [
"def",
"extract_packet",
"(",
"self",
")",
":",
"packet_size",
"=",
"velbus",
".",
"MINIMUM_MESSAGE_SIZE",
"+",
"(",
"self",
".",
"buffer",
"[",
"3",
"]",
"&",
"0x0F",
")",
"packet",
"=",
"self",
".",
"buffer",
"[",
"0",
":",
"packet_size",
"]",
"retur... | Extract packet from buffer | [
"Extract",
"packet",
"from",
"buffer"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L95-L102 | train |
pytroll/trollsift | trollsift/parser.py | _get_number_from_fmt | def _get_number_from_fmt(fmt):
"""
Helper function for extract_values,
figures out string length from format string.
"""
if '%' in fmt:
# its datetime
return len(("{0:" + fmt + "}").format(dt.datetime.now()))
else:
# its something else
fmt = fmt.lstrip('0')
... | python | def _get_number_from_fmt(fmt):
"""
Helper function for extract_values,
figures out string length from format string.
"""
if '%' in fmt:
# its datetime
return len(("{0:" + fmt + "}").format(dt.datetime.now()))
else:
# its something else
fmt = fmt.lstrip('0')
... | [
"def",
"_get_number_from_fmt",
"(",
"fmt",
")",
":",
"if",
"'%'",
"in",
"fmt",
":",
"return",
"len",
"(",
"(",
"\"{0:\"",
"+",
"fmt",
"+",
"\"}\"",
")",
".",
"format",
"(",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
")",
")",
"else",
":",
"fmt"... | Helper function for extract_values,
figures out string length from format string. | [
"Helper",
"function",
"for",
"extract_values",
"figures",
"out",
"string",
"length",
"from",
"format",
"string",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L309-L320 | train |
pytroll/trollsift | trollsift/parser.py | get_convert_dict | def get_convert_dict(fmt):
"""Retrieve parse definition from the format string `fmt`."""
convdef = {}
for literal_text, field_name, format_spec, conversion in formatter.parse(fmt):
if field_name is None:
continue
# XXX: Do I need to include 'conversion'?
convdef[field_nam... | python | def get_convert_dict(fmt):
"""Retrieve parse definition from the format string `fmt`."""
convdef = {}
for literal_text, field_name, format_spec, conversion in formatter.parse(fmt):
if field_name is None:
continue
# XXX: Do I need to include 'conversion'?
convdef[field_nam... | [
"def",
"get_convert_dict",
"(",
"fmt",
")",
":",
"convdef",
"=",
"{",
"}",
"for",
"literal_text",
",",
"field_name",
",",
"format_spec",
",",
"conversion",
"in",
"formatter",
".",
"parse",
"(",
"fmt",
")",
":",
"if",
"field_name",
"is",
"None",
":",
"con... | Retrieve parse definition from the format string `fmt`. | [
"Retrieve",
"parse",
"definition",
"from",
"the",
"format",
"string",
"fmt",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L354-L362 | train |
pytroll/trollsift | trollsift/parser.py | _generate_data_for_format | def _generate_data_for_format(fmt):
"""Generate a fake data dictionary to fill in the provided format string."""
# finally try some data, create some random data for the fmt.
data = {}
# keep track of how many "free_size" (wildcard) parameters we have
# if we get two in a row then we know the patter... | python | def _generate_data_for_format(fmt):
"""Generate a fake data dictionary to fill in the provided format string."""
# finally try some data, create some random data for the fmt.
data = {}
# keep track of how many "free_size" (wildcard) parameters we have
# if we get two in a row then we know the patter... | [
"def",
"_generate_data_for_format",
"(",
"fmt",
")",
":",
"data",
"=",
"{",
"}",
"free_size_start",
"=",
"False",
"for",
"literal_text",
",",
"field_name",
",",
"format_spec",
",",
"conversion",
"in",
"formatter",
".",
"parse",
"(",
"fmt",
")",
":",
"if",
... | Generate a fake data dictionary to fill in the provided format string. | [
"Generate",
"a",
"fake",
"data",
"dictionary",
"to",
"fill",
"in",
"the",
"provided",
"format",
"string",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L472-L524 | train |
pytroll/trollsift | trollsift/parser.py | is_one2one | def is_one2one(fmt):
"""
Runs a check to evaluate if the format string has a
one to one correspondence. I.e. that successive composing and
parsing opperations will result in the original data.
In other words, that input data maps to a string,
which then maps back to the original data without an... | python | def is_one2one(fmt):
"""
Runs a check to evaluate if the format string has a
one to one correspondence. I.e. that successive composing and
parsing opperations will result in the original data.
In other words, that input data maps to a string,
which then maps back to the original data without an... | [
"def",
"is_one2one",
"(",
"fmt",
")",
":",
"data",
"=",
"_generate_data_for_format",
"(",
"fmt",
")",
"if",
"data",
"is",
"None",
":",
"return",
"False",
"stri",
"=",
"compose",
"(",
"fmt",
",",
"data",
")",
"data2",
"=",
"parse",
"(",
"fmt",
",",
"s... | Runs a check to evaluate if the format string has a
one to one correspondence. I.e. that successive composing and
parsing opperations will result in the original data.
In other words, that input data maps to a string,
which then maps back to the original data without any change
or loss in informati... | [
"Runs",
"a",
"check",
"to",
"evaluate",
"if",
"the",
"format",
"string",
"has",
"a",
"one",
"to",
"one",
"correspondence",
".",
"I",
".",
"e",
".",
"that",
"successive",
"composing",
"and",
"parsing",
"opperations",
"will",
"result",
"in",
"the",
"original... | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L527-L558 | train |
pytroll/trollsift | trollsift/parser.py | StringFormatter.convert_field | def convert_field(self, value, conversion):
"""Apply conversions mentioned above."""
func = self.CONV_FUNCS.get(conversion)
if func is not None:
value = getattr(value, func)()
elif conversion not in ['R']:
# default conversion ('r', 's')
return super(S... | python | def convert_field(self, value, conversion):
"""Apply conversions mentioned above."""
func = self.CONV_FUNCS.get(conversion)
if func is not None:
value = getattr(value, func)()
elif conversion not in ['R']:
# default conversion ('r', 's')
return super(S... | [
"def",
"convert_field",
"(",
"self",
",",
"value",
",",
"conversion",
")",
":",
"func",
"=",
"self",
".",
"CONV_FUNCS",
".",
"get",
"(",
"conversion",
")",
"if",
"func",
"is",
"not",
"None",
":",
"value",
"=",
"getattr",
"(",
"value",
",",
"func",
")... | Apply conversions mentioned above. | [
"Apply",
"conversions",
"mentioned",
"above",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L123-L134 | train |
pytroll/trollsift | trollsift/parser.py | RegexFormatter._escape | def _escape(self, s):
"""Escape bad characters for regular expressions.
Similar to `re.escape` but allows '%' to pass through.
"""
for ch, r_ch in self.ESCAPE_SETS:
s = s.replace(ch, r_ch)
return s | python | def _escape(self, s):
"""Escape bad characters for regular expressions.
Similar to `re.escape` but allows '%' to pass through.
"""
for ch, r_ch in self.ESCAPE_SETS:
s = s.replace(ch, r_ch)
return s | [
"def",
"_escape",
"(",
"self",
",",
"s",
")",
":",
"for",
"ch",
",",
"r_ch",
"in",
"self",
".",
"ESCAPE_SETS",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"ch",
",",
"r_ch",
")",
"return",
"s"
] | Escape bad characters for regular expressions.
Similar to `re.escape` but allows '%' to pass through. | [
"Escape",
"bad",
"characters",
"for",
"regular",
"expressions",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L196-L204 | train |
pytroll/trollsift | trollsift/parser.py | RegexFormatter.format_spec_to_regex | def format_spec_to_regex(field_name, format_spec):
"""Make an attempt at converting a format spec to a regular expression."""
# NOTE: remove escaped backslashes so regex matches
regex_match = fmt_spec_regex.match(format_spec.replace('\\', ''))
if regex_match is None:
raise Va... | python | def format_spec_to_regex(field_name, format_spec):
"""Make an attempt at converting a format spec to a regular expression."""
# NOTE: remove escaped backslashes so regex matches
regex_match = fmt_spec_regex.match(format_spec.replace('\\', ''))
if regex_match is None:
raise Va... | [
"def",
"format_spec_to_regex",
"(",
"field_name",
",",
"format_spec",
")",
":",
"regex_match",
"=",
"fmt_spec_regex",
".",
"match",
"(",
"format_spec",
".",
"replace",
"(",
"'\\\\'",
",",
"''",
")",
")",
"if",
"regex_match",
"is",
"None",
":",
"raise",
"Valu... | Make an attempt at converting a format spec to a regular expression. | [
"Make",
"an",
"attempt",
"at",
"converting",
"a",
"format",
"spec",
"to",
"a",
"regular",
"expression",
"."
] | d0e5b6006e248974d806d0dd8e20cc6641d778fb | https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L235-L271 | train |
thomasdelaet/python-velbus | velbus/controller.py | Controller.feed_parser | def feed_parser(self, data):
"""
Feed parser with new data
:return: None
"""
assert isinstance(data, bytes)
self.parser.feed(data) | python | def feed_parser(self, data):
"""
Feed parser with new data
:return: None
"""
assert isinstance(data, bytes)
self.parser.feed(data) | [
"def",
"feed_parser",
"(",
"self",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"self",
".",
"parser",
".",
"feed",
"(",
"data",
")"
] | Feed parser with new data
:return: None | [
"Feed",
"parser",
"with",
"new",
"data"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L49-L56 | train |
thomasdelaet/python-velbus | velbus/controller.py | Controller.scan | def scan(self, callback=None):
"""
Scan the bus and call the callback when a new module is discovered
:return: None
"""
def scan_finished():
"""
Callback when scan is finished
"""
time.sleep(3)
logging.info('Scan finish... | python | def scan(self, callback=None):
"""
Scan the bus and call the callback when a new module is discovered
:return: None
"""
def scan_finished():
"""
Callback when scan is finished
"""
time.sleep(3)
logging.info('Scan finish... | [
"def",
"scan",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"def",
"scan_finished",
"(",
")",
":",
"time",
".",
"sleep",
"(",
"3",
")",
"logging",
".",
"info",
"(",
"'Scan finished'",
")",
"self",
".",
"_nb_of_modules_loaded",
"=",
"0",
"def",
... | Scan the bus and call the callback when a new module is discovered
:return: None | [
"Scan",
"the",
"bus",
"and",
"call",
"the",
"callback",
"when",
"a",
"new",
"module",
"is",
"discovered"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L96-L121 | train |
thomasdelaet/python-velbus | velbus/controller.py | Controller.sync_clock | def sync_clock(self):
"""
This will send all the needed messages to sync the cloc
"""
self.send(velbus.SetRealtimeClock())
self.send(velbus.SetDate())
self.send(velbus.SetDaylightSaving()) | python | def sync_clock(self):
"""
This will send all the needed messages to sync the cloc
"""
self.send(velbus.SetRealtimeClock())
self.send(velbus.SetDate())
self.send(velbus.SetDaylightSaving()) | [
"def",
"sync_clock",
"(",
"self",
")",
":",
"self",
".",
"send",
"(",
"velbus",
".",
"SetRealtimeClock",
"(",
")",
")",
"self",
".",
"send",
"(",
"velbus",
".",
"SetDate",
"(",
")",
")",
"self",
".",
"send",
"(",
"velbus",
".",
"SetDaylightSaving",
"... | This will send all the needed messages to sync the cloc | [
"This",
"will",
"send",
"all",
"the",
"needed",
"messages",
"to",
"sync",
"the",
"cloc"
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L167-L173 | train |
lobocv/crashreporter | crashreporter/tools.py | string_variable_lookup | def string_variable_lookup(tb, s):
"""
Look up the value of an object in a traceback by a dot-lookup string.
ie. "self.crashreporter.application_name"
Returns ValueError if value was not found in the scope of the traceback.
:param tb: traceback
:param s: lookup string
:return: value of the... | python | def string_variable_lookup(tb, s):
"""
Look up the value of an object in a traceback by a dot-lookup string.
ie. "self.crashreporter.application_name"
Returns ValueError if value was not found in the scope of the traceback.
:param tb: traceback
:param s: lookup string
:return: value of the... | [
"def",
"string_variable_lookup",
"(",
"tb",
",",
"s",
")",
":",
"refs",
"=",
"[",
"]",
"dot_refs",
"=",
"s",
".",
"split",
"(",
"'.'",
")",
"DOT_LOOKUP",
"=",
"0",
"DICT_LOOKUP",
"=",
"1",
"for",
"ii",
",",
"ref",
"in",
"enumerate",
"(",
"dot_refs",
... | Look up the value of an object in a traceback by a dot-lookup string.
ie. "self.crashreporter.application_name"
Returns ValueError if value was not found in the scope of the traceback.
:param tb: traceback
:param s: lookup string
:return: value of the | [
"Look",
"up",
"the",
"value",
"of",
"an",
"object",
"in",
"a",
"traceback",
"by",
"a",
"dot",
"-",
"lookup",
"string",
".",
"ie",
".",
"self",
".",
"crashreporter",
".",
"application_name"
] | a5bbb3f37977dc64bc865dfedafc365fd5469ef8 | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L28-L70 | train |
lobocv/crashreporter | crashreporter/tools.py | get_object_references | def get_object_references(tb, source, max_string_length=1000):
"""
Find the values of referenced attributes of objects within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value)
"""
global obj_ref_regex
referenced_attr = set()
for line in ... | python | def get_object_references(tb, source, max_string_length=1000):
"""
Find the values of referenced attributes of objects within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value)
"""
global obj_ref_regex
referenced_attr = set()
for line in ... | [
"def",
"get_object_references",
"(",
"tb",
",",
"source",
",",
"max_string_length",
"=",
"1000",
")",
":",
"global",
"obj_ref_regex",
"referenced_attr",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"source",
".",
"split",
"(",
"'\\n'",
")",
":",
"referenced_at... | Find the values of referenced attributes of objects within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value) | [
"Find",
"the",
"values",
"of",
"referenced",
"attributes",
"of",
"objects",
"within",
"the",
"traceback",
"scope",
"."
] | a5bbb3f37977dc64bc865dfedafc365fd5469ef8 | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L73-L91 | train |
lobocv/crashreporter | crashreporter/tools.py | get_local_references | def get_local_references(tb, max_string_length=1000):
"""
Find the values of the local variables within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value)
"""
if 'self' in tb.tb_frame.f_locals:
_locals = [('self', repr(tb.tb_frame.f_local... | python | def get_local_references(tb, max_string_length=1000):
"""
Find the values of the local variables within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value)
"""
if 'self' in tb.tb_frame.f_locals:
_locals = [('self', repr(tb.tb_frame.f_local... | [
"def",
"get_local_references",
"(",
"tb",
",",
"max_string_length",
"=",
"1000",
")",
":",
"if",
"'self'",
"in",
"tb",
".",
"tb_frame",
".",
"f_locals",
":",
"_locals",
"=",
"[",
"(",
"'self'",
",",
"repr",
"(",
"tb",
".",
"tb_frame",
".",
"f_locals",
... | Find the values of the local variables within the traceback scope.
:param tb: traceback
:return: list of tuples containing (variable name, value) | [
"Find",
"the",
"values",
"of",
"the",
"local",
"variables",
"within",
"the",
"traceback",
"scope",
"."
] | a5bbb3f37977dc64bc865dfedafc365fd5469ef8 | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L94-L113 | train |
lobocv/crashreporter | crashreporter/tools.py | analyze_traceback | def analyze_traceback(tb, inspection_level=None, limit=None):
"""
Extract trace back information into a list of dictionaries.
:param tb: traceback
:return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks
"""
info = []
tb_level = tb
e... | python | def analyze_traceback(tb, inspection_level=None, limit=None):
"""
Extract trace back information into a list of dictionaries.
:param tb: traceback
:return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks
"""
info = []
tb_level = tb
e... | [
"def",
"analyze_traceback",
"(",
"tb",
",",
"inspection_level",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"info",
"=",
"[",
"]",
"tb_level",
"=",
"tb",
"extracted_tb",
"=",
"traceback",
".",
"extract_tb",
"(",
"tb",
",",
"limit",
"=",
"limit",
... | Extract trace back information into a list of dictionaries.
:param tb: traceback
:return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks | [
"Extract",
"trace",
"back",
"information",
"into",
"a",
"list",
"of",
"dictionaries",
"."
] | a5bbb3f37977dc64bc865dfedafc365fd5469ef8 | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L155-L183 | train |
kytos/kytos-utils | kytos/utils/config.py | KytosConfig.log_configs | def log_configs(self):
"""Log the read configs if debug is enabled."""
for sec in self.config.sections():
LOG.debug(' %s: %s', sec, self.config.options(sec)) | python | def log_configs(self):
"""Log the read configs if debug is enabled."""
for sec in self.config.sections():
LOG.debug(' %s: %s', sec, self.config.options(sec)) | [
"def",
"log_configs",
"(",
"self",
")",
":",
"for",
"sec",
"in",
"self",
".",
"config",
".",
"sections",
"(",
")",
":",
"LOG",
".",
"debug",
"(",
"' %s: %s'",
",",
"sec",
",",
"self",
".",
"config",
".",
"options",
"(",
"sec",
")",
")"
] | Log the read configs if debug is enabled. | [
"Log",
"the",
"read",
"configs",
"if",
"debug",
"is",
"enabled",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L51-L54 | train |
kytos/kytos-utils | kytos/utils/config.py | KytosConfig.set_env_or_defaults | def set_env_or_defaults(self):
"""Read some environment variables and set them on the config.
If no environment variable is found and the config section/key is
empty, then set some default values.
"""
option = namedtuple('Option', ['section', 'name', 'env_var',
... | python | def set_env_or_defaults(self):
"""Read some environment variables and set them on the config.
If no environment variable is found and the config section/key is
empty, then set some default values.
"""
option = namedtuple('Option', ['section', 'name', 'env_var',
... | [
"def",
"set_env_or_defaults",
"(",
"self",
")",
":",
"option",
"=",
"namedtuple",
"(",
"'Option'",
",",
"[",
"'section'",
",",
"'name'",
",",
"'env_var'",
",",
"'default_value'",
"]",
")",
"options",
"=",
"[",
"option",
"(",
"'auth'",
",",
"'user'",
",",
... | Read some environment variables and set them on the config.
If no environment variable is found and the config section/key is
empty, then set some default values. | [
"Read",
"some",
"environment",
"variables",
"and",
"set",
"them",
"on",
"the",
"config",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L56-L81 | train |
kytos/kytos-utils | kytos/utils/config.py | KytosConfig.check_sections | def check_sections(config):
"""Create a empty config file."""
default_sections = ['global', 'auth', 'napps', 'kytos']
for section in default_sections:
if not config.has_section(section):
config.add_section(section) | python | def check_sections(config):
"""Create a empty config file."""
default_sections = ['global', 'auth', 'napps', 'kytos']
for section in default_sections:
if not config.has_section(section):
config.add_section(section) | [
"def",
"check_sections",
"(",
"config",
")",
":",
"default_sections",
"=",
"[",
"'global'",
",",
"'auth'",
",",
"'napps'",
",",
"'kytos'",
"]",
"for",
"section",
"in",
"default_sections",
":",
"if",
"not",
"config",
".",
"has_section",
"(",
"section",
")",
... | Create a empty config file. | [
"Create",
"a",
"empty",
"config",
"file",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L84-L89 | train |
kytos/kytos-utils | kytos/utils/config.py | KytosConfig.save_token | def save_token(self, user, token):
"""Save the token on the config file."""
self.config.set('auth', 'user', user)
self.config.set('auth', 'token', token)
# allow_no_value=True is used to keep the comments on the config file.
new_config = ConfigParser(allow_no_value=True)
... | python | def save_token(self, user, token):
"""Save the token on the config file."""
self.config.set('auth', 'user', user)
self.config.set('auth', 'token', token)
# allow_no_value=True is used to keep the comments on the config file.
new_config = ConfigParser(allow_no_value=True)
... | [
"def",
"save_token",
"(",
"self",
",",
"user",
",",
"token",
")",
":",
"self",
".",
"config",
".",
"set",
"(",
"'auth'",
",",
"'user'",
",",
"user",
")",
"self",
".",
"config",
".",
"set",
"(",
"'auth'",
",",
"'token'",
",",
"token",
")",
"new_conf... | Save the token on the config file. | [
"Save",
"the",
"token",
"on",
"the",
"config",
"file",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L91-L108 | train |
kytos/kytos-utils | kytos/utils/config.py | KytosConfig.clear_token | def clear_token(self):
"""Clear Token information on config file."""
# allow_no_value=True is used to keep the comments on the config file.
new_config = ConfigParser(allow_no_value=True)
# Parse the config file. If no config file was found, then create some
# default sections on... | python | def clear_token(self):
"""Clear Token information on config file."""
# allow_no_value=True is used to keep the comments on the config file.
new_config = ConfigParser(allow_no_value=True)
# Parse the config file. If no config file was found, then create some
# default sections on... | [
"def",
"clear_token",
"(",
"self",
")",
":",
"new_config",
"=",
"ConfigParser",
"(",
"allow_no_value",
"=",
"True",
")",
"new_config",
".",
"read",
"(",
"self",
".",
"config_file",
")",
"self",
".",
"check_sections",
"(",
"new_config",
")",
"new_config",
"."... | Clear Token information on config file. | [
"Clear",
"Token",
"information",
"on",
"config",
"file",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L110-L125 | train |
KE-works/pykechain | pykechain/extra_utils.py | relocate_model | def relocate_model(part, target_parent, name=None, include_children=True):
"""
Move the `Part` model to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:type ta... | python | def relocate_model(part, target_parent, name=None, include_children=True):
"""
Move the `Part` model to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:type ta... | [
"def",
"relocate_model",
"(",
"part",
",",
"target_parent",
",",
"name",
"=",
"None",
",",
"include_children",
"=",
"True",
")",
":",
"if",
"target_parent",
".",
"id",
"in",
"get_illegal_targets",
"(",
"part",
",",
"include",
"=",
"{",
"part",
".",
"id",
... | Move the `Part` model to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:type target_parent: :class:`Part`
:param name: how the moved top-level `Part` should be ca... | [
"Move",
"the",
"Part",
"model",
"to",
"target",
"parent",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L42-L117 | train |
KE-works/pykechain | pykechain/extra_utils.py | relocate_instance | def relocate_instance(part, target_parent, name=None, include_children=True):
"""
Move the `Part` instance to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:t... | python | def relocate_instance(part, target_parent, name=None, include_children=True):
"""
Move the `Part` instance to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:t... | [
"def",
"relocate_instance",
"(",
"part",
",",
"target_parent",
",",
"name",
"=",
"None",
",",
"include_children",
"=",
"True",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"\"CLONE - {}\"",
".",
"format",
"(",
"part",
".",
"name",
")",
"part_model",
... | Move the `Part` instance to target parent.
.. versionadded:: 2.3
:param part: `Part` object to be moved
:type part: :class:`Part`
:param target_parent: `Part` object under which the desired `Part` is moved
:type target_parent: :class:`Part`
:param name: how the moved top-level `Part` should be... | [
"Move",
"the",
"Part",
"instance",
"to",
"target",
"parent",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L137-L172 | train |
KE-works/pykechain | pykechain/extra_utils.py | move_part_instance | def move_part_instance(part_instance, target_parent, part_model, name=None, include_children=True):
"""
Move the `Part` instance to target parent and updates the properties based on the original part instance.
.. versionadded:: 2.3
:param part_instance: `Part` object to be moved
:type part_instanc... | python | def move_part_instance(part_instance, target_parent, part_model, name=None, include_children=True):
"""
Move the `Part` instance to target parent and updates the properties based on the original part instance.
.. versionadded:: 2.3
:param part_instance: `Part` object to be moved
:type part_instanc... | [
"def",
"move_part_instance",
"(",
"part_instance",
",",
"target_parent",
",",
"part_model",
",",
"name",
"=",
"None",
",",
"include_children",
"=",
"True",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"part_instance",
".",
"name",
"moved_model",
"=",
"ge... | Move the `Part` instance to target parent and updates the properties based on the original part instance.
.. versionadded:: 2.3
:param part_instance: `Part` object to be moved
:type part_instance: :class:`Part`
:param part_model: `Part` object representing the model of part_instance
:type part_mod... | [
"Move",
"the",
"Part",
"instance",
"to",
"target",
"parent",
"and",
"updates",
"the",
"properties",
"based",
"on",
"the",
"original",
"part",
"instance",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L175-L235 | train |
KE-works/pykechain | pykechain/extra_utils.py | update_part_with_properties | def update_part_with_properties(part_instance, moved_instance, name=None):
"""
Update the newly created part and its properties based on the original one.
:param part_instance: `Part` object to be copied
:type part_instance: :class:`Part`
:param moved_instance: `Part` object copied
:type moved_... | python | def update_part_with_properties(part_instance, moved_instance, name=None):
"""
Update the newly created part and its properties based on the original one.
:param part_instance: `Part` object to be copied
:type part_instance: :class:`Part`
:param moved_instance: `Part` object copied
:type moved_... | [
"def",
"update_part_with_properties",
"(",
"part_instance",
",",
"moved_instance",
",",
"name",
"=",
"None",
")",
":",
"properties_id_dict",
"=",
"dict",
"(",
")",
"for",
"prop_instance",
"in",
"part_instance",
".",
"properties",
":",
"if",
"prop_instance",
".",
... | Update the newly created part and its properties based on the original one.
:param part_instance: `Part` object to be copied
:type part_instance: :class:`Part`
:param moved_instance: `Part` object copied
:type moved_instance: :class:`Part`
:param name: Name of the updated part
:type name: bases... | [
"Update",
"the",
"newly",
"created",
"part",
"and",
"its",
"properties",
"based",
"on",
"the",
"original",
"one",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L238-L276 | train |
KE-works/pykechain | pykechain/extra_utils.py | map_property_instances | def map_property_instances(original_part, new_part):
"""
Map the id of the original part with the `Part` object of the newly created one.
Updated the singleton `mapping dictionary` with the new mapping table values.
:param original_part: `Part` object to be copied/moved
:type original_part: :class... | python | def map_property_instances(original_part, new_part):
"""
Map the id of the original part with the `Part` object of the newly created one.
Updated the singleton `mapping dictionary` with the new mapping table values.
:param original_part: `Part` object to be copied/moved
:type original_part: :class... | [
"def",
"map_property_instances",
"(",
"original_part",
",",
"new_part",
")",
":",
"get_mapping_dictionary",
"(",
")",
"[",
"original_part",
".",
"id",
"]",
"=",
"new_part",
"for",
"prop_original",
"in",
"original_part",
".",
"properties",
":",
"get_mapping_dictionar... | Map the id of the original part with the `Part` object of the newly created one.
Updated the singleton `mapping dictionary` with the new mapping table values.
:param original_part: `Part` object to be copied/moved
:type original_part: :class:`Part`
:param new_part: `Part` object copied/moved
:type... | [
"Map",
"the",
"id",
"of",
"the",
"original",
"part",
"with",
"the",
"Part",
"object",
"of",
"the",
"newly",
"created",
"one",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L279-L298 | train |
kytos/kytos-utils | kytos/utils/users.py | UsersManager.ask_question | def ask_question(self, field_name, pattern=NAME_PATTERN, is_required=False,
password=False):
"""Ask a question and get the input values.
This method will validade the input values.
Args:
field_name(string): Field name used to ask for input value.
pat... | python | def ask_question(self, field_name, pattern=NAME_PATTERN, is_required=False,
password=False):
"""Ask a question and get the input values.
This method will validade the input values.
Args:
field_name(string): Field name used to ask for input value.
pat... | [
"def",
"ask_question",
"(",
"self",
",",
"field_name",
",",
"pattern",
"=",
"NAME_PATTERN",
",",
"is_required",
"=",
"False",
",",
"password",
"=",
"False",
")",
":",
"input_value",
"=",
"\"\"",
"question",
"=",
"(",
"\"Insert the field using the pattern below:\""... | Ask a question and get the input values.
This method will validade the input values.
Args:
field_name(string): Field name used to ask for input value.
pattern(tuple): Pattern to validate the input value.
is_required(bool): Boolean value if the input value is required... | [
"Ask",
"a",
"question",
"and",
"get",
"the",
"input",
"values",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/users.py#L81-L116 | train |
samuelcolvin/grablib | grablib/cli.py | cli | def cli(action, config_file, debug, verbose):
"""
Static asset management in python.
Called with no arguments grablib will download, then build. You can also choose to only download or build.
See `grablib -h` and https://github.com/samuelcolvin/grablib for more help.
"""
if verbose is True:
... | python | def cli(action, config_file, debug, verbose):
"""
Static asset management in python.
Called with no arguments grablib will download, then build. You can also choose to only download or build.
See `grablib -h` and https://github.com/samuelcolvin/grablib for more help.
"""
if verbose is True:
... | [
"def",
"cli",
"(",
"action",
",",
"config_file",
",",
"debug",
",",
"verbose",
")",
":",
"if",
"verbose",
"is",
"True",
":",
"log_level",
"=",
"'DEBUG'",
"elif",
"verbose",
"is",
"False",
":",
"log_level",
"=",
"'WARNING'",
"else",
":",
"assert",
"verbos... | Static asset management in python.
Called with no arguments grablib will download, then build. You can also choose to only download or build.
See `grablib -h` and https://github.com/samuelcolvin/grablib for more help. | [
"Static",
"asset",
"management",
"in",
"python",
"."
] | 2fca8a3950f29fb2a97a7bd75c0839060a91cedf | https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/cli.py#L18-L43 | train |
KE-works/pykechain | pykechain/models/property.py | Property.part | def part(self):
"""Retrieve the part that holds this Property.
:returns: The :class:`Part` associated to this property
:raises APIError: if the `Part` is not found
"""
part_id = self._json_data['part']
return self._client.part(pk=part_id, category=self._json_data['categ... | python | def part(self):
"""Retrieve the part that holds this Property.
:returns: The :class:`Part` associated to this property
:raises APIError: if the `Part` is not found
"""
part_id = self._json_data['part']
return self._client.part(pk=part_id, category=self._json_data['categ... | [
"def",
"part",
"(",
"self",
")",
":",
"part_id",
"=",
"self",
".",
"_json_data",
"[",
"'part'",
"]",
"return",
"self",
".",
"_client",
".",
"part",
"(",
"pk",
"=",
"part_id",
",",
"category",
"=",
"self",
".",
"_json_data",
"[",
"'category'",
"]",
")... | Retrieve the part that holds this Property.
:returns: The :class:`Part` associated to this property
:raises APIError: if the `Part` is not found | [
"Retrieve",
"the",
"part",
"that",
"holds",
"this",
"Property",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L110-L118 | train |
KE-works/pykechain | pykechain/models/property.py | Property.delete | def delete(self):
# type () -> ()
"""Delete this property.
:return: None
:raises APIError: if delete was not successful
"""
r = self._client._request('DELETE', self._client._build_url('property', property_id=self.id))
if r.status_code != requests.codes.no_conten... | python | def delete(self):
# type () -> ()
"""Delete this property.
:return: None
:raises APIError: if delete was not successful
"""
r = self._client._request('DELETE', self._client._build_url('property', property_id=self.id))
if r.status_code != requests.codes.no_conten... | [
"def",
"delete",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"_request",
"(",
"'DELETE'",
",",
"self",
".",
"_client",
".",
"_build_url",
"(",
"'property'",
",",
"property_id",
"=",
"self",
".",
"id",
")",
")",
"if",
"r",
".",
"st... | Delete this property.
:return: None
:raises APIError: if delete was not successful | [
"Delete",
"this",
"property",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L120-L130 | train |
KE-works/pykechain | pykechain/models/property.py | Property.create | def create(cls, json, **kwargs):
# type: (dict, **Any) -> Property
"""Create a property based on the json data.
This method will attach the right class to a property, enabling the use of type-specific methods.
It does not create a property object in KE-chain. But a pseudo :class:`Prope... | python | def create(cls, json, **kwargs):
# type: (dict, **Any) -> Property
"""Create a property based on the json data.
This method will attach the right class to a property, enabling the use of type-specific methods.
It does not create a property object in KE-chain. But a pseudo :class:`Prope... | [
"def",
"create",
"(",
"cls",
",",
"json",
",",
"**",
"kwargs",
")",
":",
"property_type",
"=",
"json",
".",
"get",
"(",
"'property_type'",
")",
"if",
"property_type",
"==",
"PropertyType",
".",
"ATTACHMENT_VALUE",
":",
"from",
".",
"property_attachment",
"im... | Create a property based on the json data.
This method will attach the right class to a property, enabling the use of type-specific methods.
It does not create a property object in KE-chain. But a pseudo :class:`Property` object.
:param json: the json from which the :class:`Property` object to... | [
"Create",
"a",
"property",
"based",
"on",
"the",
"json",
"data",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L143-L170 | train |
KE-works/pykechain | pykechain/models/property.py | Property.__parse_validators | def __parse_validators(self):
"""Parse the validator in the options to validators."""
self._validators = []
validators_json = self._options.get('validators')
for validator_json in validators_json:
self._validators.append(PropertyValidator.parse(json=validator_json)) | python | def __parse_validators(self):
"""Parse the validator in the options to validators."""
self._validators = []
validators_json = self._options.get('validators')
for validator_json in validators_json:
self._validators.append(PropertyValidator.parse(json=validator_json)) | [
"def",
"__parse_validators",
"(",
"self",
")",
":",
"self",
".",
"_validators",
"=",
"[",
"]",
"validators_json",
"=",
"self",
".",
"_options",
".",
"get",
"(",
"'validators'",
")",
"for",
"validator_json",
"in",
"validators_json",
":",
"self",
".",
"_valida... | Parse the validator in the options to validators. | [
"Parse",
"the",
"validator",
"in",
"the",
"options",
"to",
"validators",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L242-L247 | train |
KE-works/pykechain | pykechain/models/property.py | Property.__dump_validators | def __dump_validators(self):
"""Dump the validators as json inside the _options dictionary with the key `validators`."""
if hasattr(self, '_validators'):
validators_json = []
for validator in self._validators:
if isinstance(validator, PropertyValidator):
... | python | def __dump_validators(self):
"""Dump the validators as json inside the _options dictionary with the key `validators`."""
if hasattr(self, '_validators'):
validators_json = []
for validator in self._validators:
if isinstance(validator, PropertyValidator):
... | [
"def",
"__dump_validators",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_validators'",
")",
":",
"validators_json",
"=",
"[",
"]",
"for",
"validator",
"in",
"self",
".",
"_validators",
":",
"if",
"isinstance",
"(",
"validator",
",",
"Proper... | Dump the validators as json inside the _options dictionary with the key `validators`. | [
"Dump",
"the",
"validators",
"as",
"json",
"inside",
"the",
"_options",
"dictionary",
"with",
"the",
"key",
"validators",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L249-L265 | train |
KE-works/pykechain | pykechain/models/property.py | Property.is_valid | def is_valid(self):
# type: () -> Union[bool, None]
"""Determine if the value in the property is valid.
If the value of the property is validated as 'valid', than returns a True, otherwise a False.
When no validators are configured, returns a None. It checks against all configured valid... | python | def is_valid(self):
# type: () -> Union[bool, None]
"""Determine if the value in the property is valid.
If the value of the property is validated as 'valid', than returns a True, otherwise a False.
When no validators are configured, returns a None. It checks against all configured valid... | [
"def",
"is_valid",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_validators'",
")",
":",
"return",
"None",
"else",
":",
"self",
".",
"validate",
"(",
"reason",
"=",
"False",
")",
"if",
"all",
"(",
"[",
"vr",
"is",
"None",
"for... | Determine if the value in the property is valid.
If the value of the property is validated as 'valid', than returns a True, otherwise a False.
When no validators are configured, returns a None. It checks against all configured validators
and returns a single boolean outcome.
:returns: ... | [
"Determine",
"if",
"the",
"value",
"in",
"the",
"property",
"is",
"valid",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property.py#L268-L286 | train |
fprimex/zdeskcfg | zdeskcfg.py | get_ini_config | def get_ini_config(config=os.path.join(os.path.expanduser('~'), '.zdeskcfg'),
default_section=None, section=None):
"""This is a convenience function for getting the zdesk configuration
from an ini file without the need to decorate and call your own function.
Handy when using zdesk and zdeskcfg from ... | python | def get_ini_config(config=os.path.join(os.path.expanduser('~'), '.zdeskcfg'),
default_section=None, section=None):
"""This is a convenience function for getting the zdesk configuration
from an ini file without the need to decorate and call your own function.
Handy when using zdesk and zdeskcfg from ... | [
"def",
"get_ini_config",
"(",
"config",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
",",
"'.zdeskcfg'",
")",
",",
"default_section",
"=",
"None",
",",
"section",
"=",
"None",
")",
":",
"plac_ini",
... | This is a convenience function for getting the zdesk configuration
from an ini file without the need to decorate and call your own function.
Handy when using zdesk and zdeskcfg from the interactive prompt. | [
"This",
"is",
"a",
"convenience",
"function",
"for",
"getting",
"the",
"zdesk",
"configuration",
"from",
"an",
"ini",
"file",
"without",
"the",
"need",
"to",
"decorate",
"and",
"call",
"your",
"own",
"function",
".",
"Handy",
"when",
"using",
"zdesk",
"and",... | 4283733123a62c0ab7679ca8aba0d4b02e6bb8d7 | https://github.com/fprimex/zdeskcfg/blob/4283733123a62c0ab7679ca8aba0d4b02e6bb8d7/zdeskcfg.py#L165-L171 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _ecg_band_pass_filter | def _ecg_band_pass_filter(data, sample_rate):
"""
Bandpass filter with a bandpass setting of 5 to 15 Hz
----------
Parameters
----------
data : list
List with the ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
------... | python | def _ecg_band_pass_filter(data, sample_rate):
"""
Bandpass filter with a bandpass setting of 5 to 15 Hz
----------
Parameters
----------
data : list
List with the ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
------... | [
"def",
"_ecg_band_pass_filter",
"(",
"data",
",",
"sample_rate",
")",
":",
"nyquist_sample_rate",
"=",
"sample_rate",
"/",
"2.",
"normalized_cut_offs",
"=",
"[",
"5",
"/",
"nyquist_sample_rate",
",",
"15",
"/",
"nyquist_sample_rate",
"]",
"b_coeff",
",",
"a_coeff"... | Bandpass filter with a bandpass setting of 5 to 15 Hz
----------
Parameters
----------
data : list
List with the ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
-------
out : list
Filtered signal. | [
"Bandpass",
"filter",
"with",
"a",
"bandpass",
"setting",
"of",
"5",
"to",
"15",
"Hz"
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L365-L385 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _integration | def _integration(data, sample_rate):
"""
Moving window integration. N is the number of samples in the width of the integration
window
----------
Parameters
----------
data : ndarray
Samples of the signal where a moving window integration will be applied.
sample_rate : int
... | python | def _integration(data, sample_rate):
"""
Moving window integration. N is the number of samples in the width of the integration
window
----------
Parameters
----------
data : ndarray
Samples of the signal where a moving window integration will be applied.
sample_rate : int
... | [
"def",
"_integration",
"(",
"data",
",",
"sample_rate",
")",
":",
"wind_size",
"=",
"int",
"(",
"0.080",
"*",
"sample_rate",
")",
"int_ecg",
"=",
"numpy",
".",
"zeros_like",
"(",
"data",
")",
"cum_sum",
"=",
"data",
".",
"cumsum",
"(",
")",
"int_ecg",
... | Moving window integration. N is the number of samples in the width of the integration
window
----------
Parameters
----------
data : ndarray
Samples of the signal where a moving window integration will be applied.
sample_rate : int
Sampling rate at which the acquisition took pla... | [
"Moving",
"window",
"integration",
".",
"N",
"is",
"the",
"number",
"of",
"samples",
"in",
"the",
"width",
"of",
"the",
"integration",
"window"
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L428-L452 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _buffer_ini | def _buffer_ini(data, sample_rate):
"""
Initializes the buffer with eight 1s intervals
----------
Parameters
----------
data : ndarray
Pre-processed ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
-------
rr_buffe... | python | def _buffer_ini(data, sample_rate):
"""
Initializes the buffer with eight 1s intervals
----------
Parameters
----------
data : ndarray
Pre-processed ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
-------
rr_buffe... | [
"def",
"_buffer_ini",
"(",
"data",
",",
"sample_rate",
")",
":",
"rr_buffer",
"=",
"[",
"1",
"]",
"*",
"8",
"spk1",
"=",
"max",
"(",
"data",
"[",
"sample_rate",
":",
"2",
"*",
"sample_rate",
"]",
")",
"npk1",
"=",
"0",
"threshold",
"=",
"_buffer_upda... | Initializes the buffer with eight 1s intervals
----------
Parameters
----------
data : ndarray
Pre-processed ECG signal samples.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
-------
rr_buffer : list
Data structure that stores eigh... | [
"Initializes",
"the",
"buffer",
"with",
"eight",
"1s",
"intervals"
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L455-L493 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _detects_peaks | def _detects_peaks(ecg_integrated, sample_rate):
"""
Detects peaks from local maximum
----------
Parameters
----------
ecg_integrated : ndarray
Array that contains the samples of the integrated signal.
sample_rate : int
Sampling rate at which the acquisition took place.
... | python | def _detects_peaks(ecg_integrated, sample_rate):
"""
Detects peaks from local maximum
----------
Parameters
----------
ecg_integrated : ndarray
Array that contains the samples of the integrated signal.
sample_rate : int
Sampling rate at which the acquisition took place.
... | [
"def",
"_detects_peaks",
"(",
"ecg_integrated",
",",
"sample_rate",
")",
":",
"min_rr",
"=",
"(",
"sample_rate",
"/",
"1000",
")",
"*",
"200",
"possible_peaks",
"=",
"[",
"i",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"ecg_integrated",
")",
... | Detects peaks from local maximum
----------
Parameters
----------
ecg_integrated : ndarray
Array that contains the samples of the integrated signal.
sample_rate : int
Sampling rate at which the acquisition took place.
Returns
-------
choosen_peaks : list
List of... | [
"Detects",
"peaks",
"from",
"local",
"maximum"
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L521-L570 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _checkup | def _checkup(peaks, ecg_integrated, sample_rate, rr_buffer, spk1, npk1, threshold):
"""
Check each peak according to thresholds
----------
Parameters
----------
peaks : list
List of local maximums that pass the first stage of conditions needed to be considered as
an R peak.
... | python | def _checkup(peaks, ecg_integrated, sample_rate, rr_buffer, spk1, npk1, threshold):
"""
Check each peak according to thresholds
----------
Parameters
----------
peaks : list
List of local maximums that pass the first stage of conditions needed to be considered as
an R peak.
... | [
"def",
"_checkup",
"(",
"peaks",
",",
"ecg_integrated",
",",
"sample_rate",
",",
"rr_buffer",
",",
"spk1",
",",
"npk1",
",",
"threshold",
")",
":",
"peaks_amp",
"=",
"[",
"ecg_integrated",
"[",
"peak",
"]",
"for",
"peak",
"in",
"peaks",
"]",
"definitive_pe... | Check each peak according to thresholds
----------
Parameters
----------
peaks : list
List of local maximums that pass the first stage of conditions needed to be considered as
an R peak.
ecg_integrated : ndarray
Array that contains the samples of the integrated signal.
s... | [
"Check",
"each",
"peak",
"according",
"to",
"thresholds"
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L573-L638 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | _acceptpeak | def _acceptpeak(peak, amp, definitive_peaks, spk1, rr_buffer):
"""
Private function intended to insert a new RR interval in the buffer.
----------
Parameters
----------
peak : int
Sample where the peak under analysis is located.
amp : int
Amplitude of the peak under analysis... | python | def _acceptpeak(peak, amp, definitive_peaks, spk1, rr_buffer):
"""
Private function intended to insert a new RR interval in the buffer.
----------
Parameters
----------
peak : int
Sample where the peak under analysis is located.
amp : int
Amplitude of the peak under analysis... | [
"def",
"_acceptpeak",
"(",
"peak",
",",
"amp",
",",
"definitive_peaks",
",",
"spk1",
",",
"rr_buffer",
")",
":",
"definitive_peaks_out",
"=",
"definitive_peaks",
"definitive_peaks_out",
"=",
"numpy",
".",
"append",
"(",
"definitive_peaks_out",
",",
"peak",
")",
... | Private function intended to insert a new RR interval in the buffer.
----------
Parameters
----------
peak : int
Sample where the peak under analysis is located.
amp : int
Amplitude of the peak under analysis.
definitive_peaks : list
List with the definitive_peaks stored... | [
"Private",
"function",
"intended",
"to",
"insert",
"a",
"new",
"RR",
"interval",
"in",
"the",
"buffer",
"."
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L641-L678 | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | tachogram | def tachogram(data, sample_rate, signal=False, in_seconds=False, out_seconds=False):
"""
Function for generation of ECG Tachogram.
----------
Parameters
----------
data : list
ECG signal or R peak list. When the input is a raw signal the input flag signal should be
True.
sa... | python | def tachogram(data, sample_rate, signal=False, in_seconds=False, out_seconds=False):
"""
Function for generation of ECG Tachogram.
----------
Parameters
----------
data : list
ECG signal or R peak list. When the input is a raw signal the input flag signal should be
True.
sa... | [
"def",
"tachogram",
"(",
"data",
",",
"sample_rate",
",",
"signal",
"=",
"False",
",",
"in_seconds",
"=",
"False",
",",
"out_seconds",
"=",
"False",
")",
":",
"if",
"signal",
"is",
"False",
":",
"data_copy",
"=",
"data",
"time_axis",
"=",
"numpy",
".",
... | Function for generation of ECG Tachogram.
----------
Parameters
----------
data : list
ECG signal or R peak list. When the input is a raw signal the input flag signal should be
True.
sample_rate : int
Sampling frequency.
signal : boolean
If True, then the data ... | [
"Function",
"for",
"generation",
"of",
"ECG",
"Tachogram",
"."
] | aaa01d4125180b3a34f1e26e0d3ff08c23f666d3 | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L704-L750 | train |
thomasdelaet/python-velbus | velbus/connections/serial.py | VelbusUSBConnection.stop | def stop(self):
"""Close serial port."""
self.logger.warning("Stop executed")
try:
self._reader.close()
except serial.serialutil.SerialException:
self.logger.error("Error while closing device")
raise VelbusException("Error while closing device")
... | python | def stop(self):
"""Close serial port."""
self.logger.warning("Stop executed")
try:
self._reader.close()
except serial.serialutil.SerialException:
self.logger.error("Error while closing device")
raise VelbusException("Error while closing device")
... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"Stop executed\"",
")",
"try",
":",
"self",
".",
"_reader",
".",
"close",
"(",
")",
"except",
"serial",
".",
"serialutil",
".",
"SerialException",
":",
"self",
".",
"lo... | Close serial port. | [
"Close",
"serial",
"port",
"."
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/serial.py#L77-L85 | train |
thomasdelaet/python-velbus | velbus/connections/serial.py | VelbusUSBConnection.feed_parser | def feed_parser(self, data):
"""Parse received message."""
assert isinstance(data, bytes)
self.controller.feed_parser(data) | python | def feed_parser(self, data):
"""Parse received message."""
assert isinstance(data, bytes)
self.controller.feed_parser(data) | [
"def",
"feed_parser",
"(",
"self",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"self",
".",
"controller",
".",
"feed_parser",
"(",
"data",
")"
] | Parse received message. | [
"Parse",
"received",
"message",
"."
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/serial.py#L87-L90 | train |
thomasdelaet/python-velbus | velbus/connections/serial.py | VelbusUSBConnection.send | def send(self, message, callback=None):
"""Add message to write queue."""
assert isinstance(message, velbus.Message)
self._write_queue.put_nowait((message, callback)) | python | def send(self, message, callback=None):
"""Add message to write queue."""
assert isinstance(message, velbus.Message)
self._write_queue.put_nowait((message, callback)) | [
"def",
"send",
"(",
"self",
",",
"message",
",",
"callback",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"message",
",",
"velbus",
".",
"Message",
")",
"self",
".",
"_write_queue",
".",
"put_nowait",
"(",
"(",
"message",
",",
"callback",
")",
"... | Add message to write queue. | [
"Add",
"message",
"to",
"write",
"queue",
"."
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/serial.py#L92-L95 | train |
thomasdelaet/python-velbus | velbus/connections/serial.py | VelbusUSBConnection.write_daemon | def write_daemon(self):
"""Write thread."""
while True:
(message, callback) = self._write_queue.get(block=True)
self.logger.info("Sending message on USB bus: %s", str(message))
self.logger.debug("Sending binary message: %s", str(message.to_binary()))
self... | python | def write_daemon(self):
"""Write thread."""
while True:
(message, callback) = self._write_queue.get(block=True)
self.logger.info("Sending message on USB bus: %s", str(message))
self.logger.debug("Sending binary message: %s", str(message.to_binary()))
self... | [
"def",
"write_daemon",
"(",
"self",
")",
":",
"while",
"True",
":",
"(",
"message",
",",
"callback",
")",
"=",
"self",
".",
"_write_queue",
".",
"get",
"(",
"block",
"=",
"True",
")",
"self",
".",
"logger",
".",
"info",
"(",
"\"Sending message on USB bus... | Write thread. | [
"Write",
"thread",
"."
] | af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/serial.py#L97-L106 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.__require_kytos_config | def __require_kytos_config(self):
"""Set path locations from kytosd API.
It should not be called directly, but from properties that require a
running kytosd instance.
"""
if self.__enabled is None:
uri = self._kytos_api + 'api/kytos/core/config/'
try:
... | python | def __require_kytos_config(self):
"""Set path locations from kytosd API.
It should not be called directly, but from properties that require a
running kytosd instance.
"""
if self.__enabled is None:
uri = self._kytos_api + 'api/kytos/core/config/'
try:
... | [
"def",
"__require_kytos_config",
"(",
"self",
")",
":",
"if",
"self",
".",
"__enabled",
"is",
"None",
":",
"uri",
"=",
"self",
".",
"_kytos_api",
"+",
"'api/kytos/core/config/'",
"try",
":",
"options",
"=",
"json",
".",
"loads",
"(",
"urllib",
".",
"reques... | Set path locations from kytosd API.
It should not be called directly, but from properties that require a
running kytosd instance. | [
"Set",
"path",
"locations",
"from",
"kytosd",
"API",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L69-L83 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.set_napp | def set_napp(self, user, napp, version=None):
"""Set info about NApp.
Args:
user (str): NApps Server username.
napp (str): NApp name.
version (str): NApp version.
"""
self.user = user
self.napp = napp
self.version = version or 'latest' | python | def set_napp(self, user, napp, version=None):
"""Set info about NApp.
Args:
user (str): NApps Server username.
napp (str): NApp name.
version (str): NApp version.
"""
self.user = user
self.napp = napp
self.version = version or 'latest' | [
"def",
"set_napp",
"(",
"self",
",",
"user",
",",
"napp",
",",
"version",
"=",
"None",
")",
":",
"self",
".",
"user",
"=",
"user",
"self",
".",
"napp",
"=",
"napp",
"self",
".",
"version",
"=",
"version",
"or",
"'latest'"
] | Set info about NApp.
Args:
user (str): NApps Server username.
napp (str): NApp name.
version (str): NApp version. | [
"Set",
"info",
"about",
"NApp",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L85-L95 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.dependencies | def dependencies(self, user=None, napp=None):
"""Get napp_dependencies from install NApp.
Args:
user(string) A Username.
napp(string): A NApp name.
Returns:
napps(list): List with tuples with Username and NApp name.
e.g. [('kytos'/'o... | python | def dependencies(self, user=None, napp=None):
"""Get napp_dependencies from install NApp.
Args:
user(string) A Username.
napp(string): A NApp name.
Returns:
napps(list): List with tuples with Username and NApp name.
e.g. [('kytos'/'o... | [
"def",
"dependencies",
"(",
"self",
",",
"user",
"=",
"None",
",",
"napp",
"=",
"None",
")",
":",
"napps",
"=",
"self",
".",
"_get_napp_key",
"(",
"'napp_dependencies'",
",",
"user",
",",
"napp",
")",
"return",
"[",
"tuple",
"(",
"napp",
".",
"split",
... | Get napp_dependencies from install NApp.
Args:
user(string) A Username.
napp(string): A NApp name.
Returns:
napps(list): List with tuples with Username and NApp name.
e.g. [('kytos'/'of_core'), ('kytos/of_l2ls')] | [
"Get",
"napp_dependencies",
"from",
"install",
"NApp",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L129-L141 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager._get_napp_key | def _get_napp_key(self, key, user=None, napp=None):
"""Return a value from kytos.json.
Args:
user (string): A Username.
napp (string): A NApp name
key (string): Key used to get the value within kytos.json.
Returns:
meta (object): Value stored in ... | python | def _get_napp_key(self, key, user=None, napp=None):
"""Return a value from kytos.json.
Args:
user (string): A Username.
napp (string): A NApp name
key (string): Key used to get the value within kytos.json.
Returns:
meta (object): Value stored in ... | [
"def",
"_get_napp_key",
"(",
"self",
",",
"key",
",",
"user",
"=",
"None",
",",
"napp",
"=",
"None",
")",
":",
"if",
"user",
"is",
"None",
":",
"user",
"=",
"self",
".",
"user",
"if",
"napp",
"is",
"None",
":",
"napp",
"=",
"self",
".",
"napp",
... | Return a value from kytos.json.
Args:
user (string): A Username.
napp (string): A NApp name
key (string): Key used to get the value within kytos.json.
Returns:
meta (object): Value stored in kytos.json. | [
"Return",
"a",
"value",
"from",
"kytos",
".",
"json",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L151-L173 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.disable | def disable(self):
"""Disable a NApp if it is enabled."""
core_napps_manager = CoreNAppsManager(base_path=self._enabled)
core_napps_manager.disable(self.user, self.napp) | python | def disable(self):
"""Disable a NApp if it is enabled."""
core_napps_manager = CoreNAppsManager(base_path=self._enabled)
core_napps_manager.disable(self.user, self.napp) | [
"def",
"disable",
"(",
"self",
")",
":",
"core_napps_manager",
"=",
"CoreNAppsManager",
"(",
"base_path",
"=",
"self",
".",
"_enabled",
")",
"core_napps_manager",
".",
"disable",
"(",
"self",
".",
"user",
",",
"self",
".",
"napp",
")"
] | Disable a NApp if it is enabled. | [
"Disable",
"a",
"NApp",
"if",
"it",
"is",
"enabled",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L175-L178 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.enable | def enable(self):
"""Enable a NApp if not already enabled.
Raises:
FileNotFoundError: If NApp is not installed.
PermissionError: No filesystem permission to enable NApp.
"""
core_napps_manager = CoreNAppsManager(base_path=self._enabled)
core_napps_manage... | python | def enable(self):
"""Enable a NApp if not already enabled.
Raises:
FileNotFoundError: If NApp is not installed.
PermissionError: No filesystem permission to enable NApp.
"""
core_napps_manager = CoreNAppsManager(base_path=self._enabled)
core_napps_manage... | [
"def",
"enable",
"(",
"self",
")",
":",
"core_napps_manager",
"=",
"CoreNAppsManager",
"(",
"base_path",
"=",
"self",
".",
"_enabled",
")",
"core_napps_manager",
".",
"enable",
"(",
"self",
".",
"user",
",",
"self",
".",
"napp",
")"
] | Enable a NApp if not already enabled.
Raises:
FileNotFoundError: If NApp is not installed.
PermissionError: No filesystem permission to enable NApp. | [
"Enable",
"a",
"NApp",
"if",
"not",
"already",
"enabled",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L188-L197 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.uninstall | def uninstall(self):
"""Delete code inside NApp directory, if existent."""
if self.is_installed():
installed = self.installed_dir()
if installed.is_symlink():
installed.unlink()
else:
shutil.rmtree(str(installed)) | python | def uninstall(self):
"""Delete code inside NApp directory, if existent."""
if self.is_installed():
installed = self.installed_dir()
if installed.is_symlink():
installed.unlink()
else:
shutil.rmtree(str(installed)) | [
"def",
"uninstall",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_installed",
"(",
")",
":",
"installed",
"=",
"self",
".",
"installed_dir",
"(",
")",
"if",
"installed",
".",
"is_symlink",
"(",
")",
":",
"installed",
".",
"unlink",
"(",
")",
"else",
... | Delete code inside NApp directory, if existent. | [
"Delete",
"code",
"inside",
"NApp",
"directory",
"if",
"existent",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L203-L210 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.render_template | def render_template(templates_path, template_filename, context):
"""Render Jinja2 template for a NApp structure."""
template_env = Environment(
autoescape=False, trim_blocks=False,
loader=FileSystemLoader(str(templates_path)))
return template_env.get_template(str(template... | python | def render_template(templates_path, template_filename, context):
"""Render Jinja2 template for a NApp structure."""
template_env = Environment(
autoescape=False, trim_blocks=False,
loader=FileSystemLoader(str(templates_path)))
return template_env.get_template(str(template... | [
"def",
"render_template",
"(",
"templates_path",
",",
"template_filename",
",",
"context",
")",
":",
"template_env",
"=",
"Environment",
"(",
"autoescape",
"=",
"False",
",",
"trim_blocks",
"=",
"False",
",",
"loader",
"=",
"FileSystemLoader",
"(",
"str",
"(",
... | Render Jinja2 template for a NApp structure. | [
"Render",
"Jinja2",
"template",
"for",
"a",
"NApp",
"structure",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L223-L229 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.search | def search(pattern):
"""Search all server NApps matching pattern.
Args:
pattern (str): Python regular expression.
"""
def match(napp):
"""Whether a NApp metadata matches the pattern."""
# WARNING: This will change for future versions, when 'author' wi... | python | def search(pattern):
"""Search all server NApps matching pattern.
Args:
pattern (str): Python regular expression.
"""
def match(napp):
"""Whether a NApp metadata matches the pattern."""
# WARNING: This will change for future versions, when 'author' wi... | [
"def",
"search",
"(",
"pattern",
")",
":",
"def",
"match",
"(",
"napp",
")",
":",
"username",
"=",
"napp",
".",
"get",
"(",
"'username'",
",",
"napp",
".",
"get",
"(",
"'author'",
")",
")",
"strings",
"=",
"[",
"'{}/{}'",
".",
"format",
"(",
"usern... | Search all server NApps matching pattern.
Args:
pattern (str): Python regular expression. | [
"Search",
"all",
"server",
"NApps",
"matching",
"pattern",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L232-L249 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.install_local | def install_local(self):
"""Make a symlink in install folder to a local NApp.
Raises:
FileNotFoundError: If NApp is not found.
"""
folder = self._get_local_folder()
installed = self.installed_dir()
self._check_module(installed.parent)
installed.symli... | python | def install_local(self):
"""Make a symlink in install folder to a local NApp.
Raises:
FileNotFoundError: If NApp is not found.
"""
folder = self._get_local_folder()
installed = self.installed_dir()
self._check_module(installed.parent)
installed.symli... | [
"def",
"install_local",
"(",
"self",
")",
":",
"folder",
"=",
"self",
".",
"_get_local_folder",
"(",
")",
"installed",
"=",
"self",
".",
"installed_dir",
"(",
")",
"self",
".",
"_check_module",
"(",
"installed",
".",
"parent",
")",
"installed",
".",
"symli... | Make a symlink in install folder to a local NApp.
Raises:
FileNotFoundError: If NApp is not found. | [
"Make",
"a",
"symlink",
"in",
"install",
"folder",
"to",
"a",
"local",
"NApp",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L251-L261 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager._get_local_folder | def _get_local_folder(self, root=None):
"""Return local NApp root folder.
Search for kytos.json in _./_ folder and _./user/napp_.
Args:
root (pathlib.Path): Where to begin searching.
Return:
pathlib.Path: NApp root folder.
Raises:
FileNotFo... | python | def _get_local_folder(self, root=None):
"""Return local NApp root folder.
Search for kytos.json in _./_ folder and _./user/napp_.
Args:
root (pathlib.Path): Where to begin searching.
Return:
pathlib.Path: NApp root folder.
Raises:
FileNotFo... | [
"def",
"_get_local_folder",
"(",
"self",
",",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"None",
":",
"root",
"=",
"Path",
"(",
")",
"for",
"folders",
"in",
"[",
"'.'",
"]",
",",
"[",
"self",
".",
"user",
",",
"self",
".",
"napp",
"]",
... | Return local NApp root folder.
Search for kytos.json in _./_ folder and _./user/napp_.
Args:
root (pathlib.Path): Where to begin searching.
Return:
pathlib.Path: NApp root folder.
Raises:
FileNotFoundError: If there is no such local NApp. | [
"Return",
"local",
"NApp",
"root",
"folder",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L263-L290 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.install_remote | def install_remote(self):
"""Download, extract and install NApp."""
package, pkg_folder = None, None
try:
package = self._download()
pkg_folder = self._extract(package)
napp_folder = self._get_local_folder(pkg_folder)
dst = self._installed / self.u... | python | def install_remote(self):
"""Download, extract and install NApp."""
package, pkg_folder = None, None
try:
package = self._download()
pkg_folder = self._extract(package)
napp_folder = self._get_local_folder(pkg_folder)
dst = self._installed / self.u... | [
"def",
"install_remote",
"(",
"self",
")",
":",
"package",
",",
"pkg_folder",
"=",
"None",
",",
"None",
"try",
":",
"package",
"=",
"self",
".",
"_download",
"(",
")",
"pkg_folder",
"=",
"self",
".",
"_extract",
"(",
"package",
")",
"napp_folder",
"=",
... | Download, extract and install NApp. | [
"Download",
"extract",
"and",
"install",
"NApp",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L292-L307 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager._download | def _download(self):
"""Download NApp package from server.
Return:
str: Downloaded temp filename.
Raises:
urllib.error.HTTPError: If download is not successful.
"""
repo = self._config.get('napps', 'repo')
napp_id = '{}/{}-{}.napp'.format(self.u... | python | def _download(self):
"""Download NApp package from server.
Return:
str: Downloaded temp filename.
Raises:
urllib.error.HTTPError: If download is not successful.
"""
repo = self._config.get('napps', 'repo')
napp_id = '{}/{}-{}.napp'.format(self.u... | [
"def",
"_download",
"(",
"self",
")",
":",
"repo",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'napps'",
",",
"'repo'",
")",
"napp_id",
"=",
"'{}/{}-{}.napp'",
".",
"format",
"(",
"self",
".",
"user",
",",
"self",
".",
"napp",
",",
"self",
".",
... | Download NApp package from server.
Return:
str: Downloaded temp filename.
Raises:
urllib.error.HTTPError: If download is not successful. | [
"Download",
"NApp",
"package",
"from",
"server",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L309-L322 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager._extract | def _extract(filename):
"""Extract package to a temporary folder.
Return:
pathlib.Path: Temp dir with package contents.
"""
random_string = '{:0d}'.format(randint(0, 10**6))
tmp = '/tmp/kytos-napp-' + Path(filename).stem + '-' + random_string
os.mkdir(tmp)
... | python | def _extract(filename):
"""Extract package to a temporary folder.
Return:
pathlib.Path: Temp dir with package contents.
"""
random_string = '{:0d}'.format(randint(0, 10**6))
tmp = '/tmp/kytos-napp-' + Path(filename).stem + '-' + random_string
os.mkdir(tmp)
... | [
"def",
"_extract",
"(",
"filename",
")",
":",
"random_string",
"=",
"'{:0d}'",
".",
"format",
"(",
"randint",
"(",
"0",
",",
"10",
"**",
"6",
")",
")",
"tmp",
"=",
"'/tmp/kytos-napp-'",
"+",
"Path",
"(",
"filename",
")",
".",
"stem",
"+",
"'-'",
"+",... | Extract package to a temporary folder.
Return:
pathlib.Path: Temp dir with package contents. | [
"Extract",
"package",
"to",
"a",
"temporary",
"folder",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L325-L337 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.create_napp | def create_napp(cls, meta_package=False):
"""Bootstrap a basic NApp structure for you to develop your NApp.
This will create, on the current folder, a clean structure of a NAPP,
filling some contents on this structure.
"""
templates_path = SKEL_PATH / 'napp-structure/username/na... | python | def create_napp(cls, meta_package=False):
"""Bootstrap a basic NApp structure for you to develop your NApp.
This will create, on the current folder, a clean structure of a NAPP,
filling some contents on this structure.
"""
templates_path = SKEL_PATH / 'napp-structure/username/na... | [
"def",
"create_napp",
"(",
"cls",
",",
"meta_package",
"=",
"False",
")",
":",
"templates_path",
"=",
"SKEL_PATH",
"/",
"'napp-structure/username/napp'",
"ui_templates_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"templates_path",
",",
"'ui'",
")",
"username... | Bootstrap a basic NApp structure for you to develop your NApp.
This will create, on the current folder, a clean structure of a NAPP,
filling some contents on this structure. | [
"Bootstrap",
"a",
"basic",
"NApp",
"structure",
"for",
"you",
"to",
"develop",
"your",
"NApp",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L340-L412 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.create_ui_structure | def create_ui_structure(cls, username, napp_name, ui_templates_path,
context):
"""Create the ui directory structure."""
for section in ['k-info-panel', 'k-toolbar', 'k-action-menu']:
os.makedirs(os.path.join(username, napp_name, 'ui', section))
templates ... | python | def create_ui_structure(cls, username, napp_name, ui_templates_path,
context):
"""Create the ui directory structure."""
for section in ['k-info-panel', 'k-toolbar', 'k-action-menu']:
os.makedirs(os.path.join(username, napp_name, 'ui', section))
templates ... | [
"def",
"create_ui_structure",
"(",
"cls",
",",
"username",
",",
"napp_name",
",",
"ui_templates_path",
",",
"context",
")",
":",
"for",
"section",
"in",
"[",
"'k-info-panel'",
",",
"'k-toolbar'",
",",
"'k-action-menu'",
"]",
":",
"os",
".",
"makedirs",
"(",
... | Create the ui directory structure. | [
"Create",
"the",
"ui",
"directory",
"structure",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L415-L430 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.build_napp_package | def build_napp_package(napp_name):
"""Build the .napp file to be sent to the napps server.
Args:
napp_identifier (str): Identifier formatted as
<username>/<napp_name>
Return:
file_payload (binary): The binary representation of the napp
pa... | python | def build_napp_package(napp_name):
"""Build the .napp file to be sent to the napps server.
Args:
napp_identifier (str): Identifier formatted as
<username>/<napp_name>
Return:
file_payload (binary): The binary representation of the napp
pa... | [
"def",
"build_napp_package",
"(",
"napp_name",
")",
":",
"ignored_extensions",
"=",
"[",
"'.swp'",
",",
"'.pyc'",
",",
"'.napp'",
"]",
"ignored_dirs",
"=",
"[",
"'__pycache__'",
",",
"'.git'",
",",
"'.tox'",
"]",
"files",
"=",
"os",
".",
"listdir",
"(",
")... | Build the .napp file to be sent to the napps server.
Args:
napp_identifier (str): Identifier formatted as
<username>/<napp_name>
Return:
file_payload (binary): The binary representation of the napp
package that will be POSTed to the napp server. | [
"Build",
"the",
".",
"napp",
"file",
"to",
"be",
"sent",
"to",
"the",
"napps",
"server",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L444-L478 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.create_metadata | def create_metadata(*args, **kwargs): # pylint: disable=unused-argument
"""Generate the metadata to send the napp package."""
json_filename = kwargs.get('json_filename', 'kytos.json')
readme_filename = kwargs.get('readme_filename', 'README.rst')
ignore_json = kwargs.get('ignore_json', F... | python | def create_metadata(*args, **kwargs): # pylint: disable=unused-argument
"""Generate the metadata to send the napp package."""
json_filename = kwargs.get('json_filename', 'kytos.json')
readme_filename = kwargs.get('readme_filename', 'README.rst')
ignore_json = kwargs.get('ignore_json', F... | [
"def",
"create_metadata",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"json_filename",
"=",
"kwargs",
".",
"get",
"(",
"'json_filename'",
",",
"'kytos.json'",
")",
"readme_filename",
"=",
"kwargs",
".",
"get",
"(",
"'readme_filename'",
",",
"'README.rst'"... | Generate the metadata to send the napp package. | [
"Generate",
"the",
"metadata",
"to",
"send",
"the",
"napp",
"package",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L481-L510 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.upload | def upload(self, *args, **kwargs):
"""Create package and upload it to NApps Server.
Raises:
FileNotFoundError: If kytos.json is not found.
"""
self.prepare()
metadata = self.create_metadata(*args, **kwargs)
package = self.build_napp_package(metadata.get('nam... | python | def upload(self, *args, **kwargs):
"""Create package and upload it to NApps Server.
Raises:
FileNotFoundError: If kytos.json is not found.
"""
self.prepare()
metadata = self.create_metadata(*args, **kwargs)
package = self.build_napp_package(metadata.get('nam... | [
"def",
"upload",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"prepare",
"(",
")",
"metadata",
"=",
"self",
".",
"create_metadata",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"package",
"=",
"self",
".",
"build_napp_pac... | Create package and upload it to NApps Server.
Raises:
FileNotFoundError: If kytos.json is not found. | [
"Create",
"package",
"and",
"upload",
"it",
"to",
"NApps",
"Server",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L512-L523 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.prepare | def prepare(cls):
"""Prepare NApp to be uploaded by creating openAPI skeleton."""
if cls._ask_openapi():
napp_path = Path()
tpl_path = SKEL_PATH / 'napp-structure/username/napp'
OpenAPI(napp_path, tpl_path).render_template()
print('Please, update your open... | python | def prepare(cls):
"""Prepare NApp to be uploaded by creating openAPI skeleton."""
if cls._ask_openapi():
napp_path = Path()
tpl_path = SKEL_PATH / 'napp-structure/username/napp'
OpenAPI(napp_path, tpl_path).render_template()
print('Please, update your open... | [
"def",
"prepare",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_ask_openapi",
"(",
")",
":",
"napp_path",
"=",
"Path",
"(",
")",
"tpl_path",
"=",
"SKEL_PATH",
"/",
"'napp-structure/username/napp'",
"OpenAPI",
"(",
"napp_path",
",",
"tpl_path",
")",
".",
"rende... | Prepare NApp to be uploaded by creating openAPI skeleton. | [
"Prepare",
"NApp",
"to",
"be",
"uploaded",
"by",
"creating",
"openAPI",
"skeleton",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L536-L543 | train |
kytos/kytos-utils | kytos/utils/napps.py | NAppsManager.reload | def reload(self, napps=None):
"""Reload a NApp or all NApps.
Args:
napps (list): NApp list to be reloaded.
Raises:
requests.HTTPError: When there's a server error.
"""
client = NAppsClient(self._config)
client.reload_napps(napps) | python | def reload(self, napps=None):
"""Reload a NApp or all NApps.
Args:
napps (list): NApp list to be reloaded.
Raises:
requests.HTTPError: When there's a server error.
"""
client = NAppsClient(self._config)
client.reload_napps(napps) | [
"def",
"reload",
"(",
"self",
",",
"napps",
"=",
"None",
")",
":",
"client",
"=",
"NAppsClient",
"(",
"self",
".",
"_config",
")",
"client",
".",
"reload_napps",
"(",
"napps",
")"
] | Reload a NApp or all NApps.
Args:
napps (list): NApp list to be reloaded.
Raises:
requests.HTTPError: When there's a server error. | [
"Reload",
"a",
"NApp",
"or",
"all",
"NApps",
"."
] | b4750c618d15cff75970ea6124bda4d2b9a33578 | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L565-L575 | train |
manikos/django-progressiveimagefield | progressiveimagefield/templatetags/progressive_tags.py | _get_thumbnail_url | def _get_thumbnail_url(image):
""" Given a large image, return the thumbnail url """
lhs, rhs = splitext(image.url)
lhs += THUMB_EXT
thumb_url = f'{lhs}{rhs}'
return thumb_url | python | def _get_thumbnail_url(image):
""" Given a large image, return the thumbnail url """
lhs, rhs = splitext(image.url)
lhs += THUMB_EXT
thumb_url = f'{lhs}{rhs}'
return thumb_url | [
"def",
"_get_thumbnail_url",
"(",
"image",
")",
":",
"lhs",
",",
"rhs",
"=",
"splitext",
"(",
"image",
".",
"url",
")",
"lhs",
"+=",
"THUMB_EXT",
"thumb_url",
"=",
"f'{lhs}{rhs}'",
"return",
"thumb_url"
] | Given a large image, return the thumbnail url | [
"Given",
"a",
"large",
"image",
"return",
"the",
"thumbnail",
"url"
] | a432c79d23d87ea8944ac252ae7d15df1e4f3072 | https://github.com/manikos/django-progressiveimagefield/blob/a432c79d23d87ea8944ac252ae7d15df1e4f3072/progressiveimagefield/templatetags/progressive_tags.py#L24-L29 | train |
KE-works/pykechain | pykechain/client.py | Client.from_env | def from_env(cls, env_filename=None):
# type: (Optional[str]) -> Client
"""Create a client from environment variable settings.
:param basestring env_filename: filename of the environment file, defaults to '.env' in the local dir
(or parent dir)
:r... | python | def from_env(cls, env_filename=None):
# type: (Optional[str]) -> Client
"""Create a client from environment variable settings.
:param basestring env_filename: filename of the environment file, defaults to '.env' in the local dir
(or parent dir)
:r... | [
"def",
"from_env",
"(",
"cls",
",",
"env_filename",
"=",
"None",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
",",
"UserWarning",
")",
"env",
".",
"read_envfile",
"(",
"env_filename",... | Create a client from environment variable settings.
:param basestring env_filename: filename of the environment file, defaults to '.env' in the local dir
(or parent dir)
:return: :class:`pykechain.Client`
Example
-------
Initiates the py... | [
"Create",
"a",
"client",
"from",
"environment",
"variable",
"settings",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L107-L151 | train |
KE-works/pykechain | pykechain/client.py | Client._build_url | def _build_url(self, resource, **kwargs):
# type: (str, **str) -> str
"""Build the correct API url."""
return urljoin(self.api_root, API_PATH[resource].format(**kwargs)) | python | def _build_url(self, resource, **kwargs):
# type: (str, **str) -> str
"""Build the correct API url."""
return urljoin(self.api_root, API_PATH[resource].format(**kwargs)) | [
"def",
"_build_url",
"(",
"self",
",",
"resource",
",",
"**",
"kwargs",
")",
":",
"return",
"urljoin",
"(",
"self",
".",
"api_root",
",",
"API_PATH",
"[",
"resource",
"]",
".",
"format",
"(",
"**",
"kwargs",
")",
")"
] | Build the correct API url. | [
"Build",
"the",
"correct",
"API",
"url",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L184-L187 | train |
KE-works/pykechain | pykechain/client.py | Client._retrieve_users | def _retrieve_users(self):
"""
Retrieve user objects of the entire administration.
:return: list of dictionary with users information
:rtype: list(dict)
-------
"""
users_url = self._build_url('users')
response = self._request('GET', users_url)
u... | python | def _retrieve_users(self):
"""
Retrieve user objects of the entire administration.
:return: list of dictionary with users information
:rtype: list(dict)
-------
"""
users_url = self._build_url('users')
response = self._request('GET', users_url)
u... | [
"def",
"_retrieve_users",
"(",
"self",
")",
":",
"users_url",
"=",
"self",
".",
"_build_url",
"(",
"'users'",
")",
"response",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"users_url",
")",
"users",
"=",
"response",
".",
"json",
"(",
")",
"return",
... | Retrieve user objects of the entire administration.
:return: list of dictionary with users information
:rtype: list(dict)
------- | [
"Retrieve",
"user",
"objects",
"of",
"the",
"entire",
"administration",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L189-L201 | train |
KE-works/pykechain | pykechain/client.py | Client._request | def _request(self, method, url, **kwargs):
# type: (str, str, **Any) -> requests.Response
"""Perform the request on the API."""
self.last_request = None
self.last_response = self.session.request(method, url, auth=self.auth, headers=self.headers, **kwargs)
self.last_request = self... | python | def _request(self, method, url, **kwargs):
# type: (str, str, **Any) -> requests.Response
"""Perform the request on the API."""
self.last_request = None
self.last_response = self.session.request(method, url, auth=self.auth, headers=self.headers, **kwargs)
self.last_request = self... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"last_request",
"=",
"None",
"self",
".",
"last_response",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
",",
"url",
",",
"auth",
"="... | Perform the request on the API. | [
"Perform",
"the",
"request",
"on",
"the",
"API",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L203-L214 | train |
KE-works/pykechain | pykechain/client.py | Client.app_versions | def app_versions(self):
"""List of the versions of the internal KE-chain 'app' modules."""
if not self._app_versions:
app_versions_url = self._build_url('versions')
response = self._request('GET', app_versions_url)
if response.status_code == requests.codes.not_found... | python | def app_versions(self):
"""List of the versions of the internal KE-chain 'app' modules."""
if not self._app_versions:
app_versions_url = self._build_url('versions')
response = self._request('GET', app_versions_url)
if response.status_code == requests.codes.not_found... | [
"def",
"app_versions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_app_versions",
":",
"app_versions_url",
"=",
"self",
".",
"_build_url",
"(",
"'versions'",
")",
"response",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"app_versions_url",
")",
... | List of the versions of the internal KE-chain 'app' modules. | [
"List",
"of",
"the",
"versions",
"of",
"the",
"internal",
"KE",
"-",
"chain",
"app",
"modules",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L217-L233 | train |
KE-works/pykechain | pykechain/client.py | Client.match_app_version | def match_app_version(self, app=None, label=None, version=None, default=False):
"""Match app version against a semantic version string.
Checks if a KE-chain app matches a version comparison. Uses the `semver` matcher to check.
`match("2.0.0", ">=1.0.0")` => `True`
`match("1.0.0", ">1.0... | python | def match_app_version(self, app=None, label=None, version=None, default=False):
"""Match app version against a semantic version string.
Checks if a KE-chain app matches a version comparison. Uses the `semver` matcher to check.
`match("2.0.0", ">=1.0.0")` => `True`
`match("1.0.0", ">1.0... | [
"def",
"match_app_version",
"(",
"self",
",",
"app",
"=",
"None",
",",
"label",
"=",
"None",
",",
"version",
"=",
"None",
",",
"default",
"=",
"False",
")",
":",
"if",
"not",
"app",
"or",
"not",
"label",
"and",
"not",
"(",
"app",
"and",
"label",
")... | Match app version against a semantic version string.
Checks if a KE-chain app matches a version comparison. Uses the `semver` matcher to check.
`match("2.0.0", ">=1.0.0")` => `True`
`match("1.0.0", ">1.0.0")` => `False`
Examples
--------
>>> client.match_app_version(la... | [
"Match",
"app",
"version",
"against",
"a",
"semantic",
"version",
"string",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L235-L288 | train |
KE-works/pykechain | pykechain/client.py | Client.reload | def reload(self, obj, extra_params=None):
"""Reload an object from server. This method is immutable and will return a new object.
:param obj: object to reload
:type obj: :py:obj:`obj`
:param extra_params: additional object specific extra query string params (eg for activity)
:ty... | python | def reload(self, obj, extra_params=None):
"""Reload an object from server. This method is immutable and will return a new object.
:param obj: object to reload
:type obj: :py:obj:`obj`
:param extra_params: additional object specific extra query string params (eg for activity)
:ty... | [
"def",
"reload",
"(",
"self",
",",
"obj",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"not",
"obj",
".",
"_json_data",
".",
"get",
"(",
"'url'",
")",
":",
"raise",
"NotFoundError",
"(",
"\"Could not reload object, there is no url for object '{}' configured\"... | Reload an object from server. This method is immutable and will return a new object.
:param obj: object to reload
:type obj: :py:obj:`obj`
:param extra_params: additional object specific extra query string params (eg for activity)
:type extra_params: dict
:return: a new object
... | [
"Reload",
"an",
"object",
"from",
"server",
".",
"This",
"method",
"is",
"immutable",
"and",
"will",
"return",
"a",
"new",
"object",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L290-L310 | train |
KE-works/pykechain | pykechain/client.py | Client.scope | def scope(self, *args, **kwargs):
# type: (*Any, **Any) -> Scope
"""Return a single scope based on the provided name.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional que... | python | def scope(self, *args, **kwargs):
# type: (*Any, **Any) -> Scope
"""Return a single scope based on the provided name.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional que... | [
"def",
"scope",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_scopes",
"=",
"self",
".",
"scopes",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"len",
"(",
"_scopes",
")",
"==",
"0",
":",
"raise",
"NotFoundError",
"(",
"\"N... | Return a single scope based on the provided name.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:return: a single :class:`models.Scope`
:raises NotF... | [
"Return",
"a",
"single",
"scope",
"based",
"on",
"the",
"provided",
"name",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L362-L380 | train |
KE-works/pykechain | pykechain/client.py | Client.activities | def activities(self, name=None, pk=None, scope=None, **kwargs):
# type: (Optional[str], Optional[str], Optional[str], **Any) -> List[Activity]
"""Search for activities with optional name, pk and scope filter.
If additional `keyword=value` arguments are provided, these are added to the request p... | python | def activities(self, name=None, pk=None, scope=None, **kwargs):
# type: (Optional[str], Optional[str], Optional[str], **Any) -> List[Activity]
"""Search for activities with optional name, pk and scope filter.
If additional `keyword=value` arguments are provided, these are added to the request p... | [
"def",
"activities",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'id'",
":",
"pk",
",",
"'name'",
":",
"name",
",",
"'scope'",
":",
"scope",
... | Search for activities with optional name, pk and scope filter.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param pk: id (primary key) of the activity to ... | [
"Search",
"for",
"activities",
"with",
"optional",
"name",
"pk",
"and",
"scope",
"filter",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L382-L425 | train |
KE-works/pykechain | pykechain/client.py | Client.activity | def activity(self, *args, **kwargs):
# type: (*Any, **Any) -> Activity
"""Search for a single activity.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.... | python | def activity(self, *args, **kwargs):
# type: (*Any, **Any) -> Activity
"""Search for a single activity.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.... | [
"def",
"activity",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_activities",
"=",
"self",
".",
"activities",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"len",
"(",
"_activities",
")",
"==",
"0",
":",
"raise",
"NotFoundError"... | Search for a single activity.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param pk: id (primary key) of the activity to retrieve
:type pk: basest... | [
"Search",
"for",
"a",
"single",
"activity",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L427-L451 | train |
KE-works/pykechain | pykechain/client.py | Client.parts | def parts(self,
name=None, # type: Optional[str]
pk=None, # type: Optional[str]
model=None, # type: Optional[Part]
category=Category.INSTANCE, # type: Optional[str]
bucket=None, # type: Optional[str]
parent=None, # type: Optional[... | python | def parts(self,
name=None, # type: Optional[str]
pk=None, # type: Optional[str]
model=None, # type: Optional[Part]
category=Category.INSTANCE, # type: Optional[str]
bucket=None, # type: Optional[str]
parent=None, # type: Optional[... | [
"def",
"parts",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"model",
"=",
"None",
",",
"category",
"=",
"Category",
".",
"INSTANCE",
",",
"bucket",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"activity",
"=",
"None",
",",
... | Retrieve multiple KE-chain parts.
If no parameters are provided, all parts are retrieved.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param name... | [
"Retrieve",
"multiple",
"KE",
"-",
"chain",
"parts",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L453-L551 | train |
KE-works/pykechain | pykechain/client.py | Client.part | def part(self, *args, **kwargs):
# type: (*Any, **Any) -> Part
"""Retrieve single KE-chain part.
Uses the same interface as the :func:`parts` method but returns only a single pykechain :class:`models.Part`
instance.
If additional `keyword=value` arguments are provided, these ar... | python | def part(self, *args, **kwargs):
# type: (*Any, **Any) -> Part
"""Retrieve single KE-chain part.
Uses the same interface as the :func:`parts` method but returns only a single pykechain :class:`models.Part`
instance.
If additional `keyword=value` arguments are provided, these ar... | [
"def",
"part",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_parts",
"=",
"self",
".",
"parts",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"len",
"(",
"_parts",
")",
"==",
"0",
":",
"raise",
"NotFoundError",
"(",
"\"No pa... | Retrieve single KE-chain part.
Uses the same interface as the :func:`parts` method but returns only a single pykechain :class:`models.Part`
instance.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of th... | [
"Retrieve",
"single",
"KE",
"-",
"chain",
"part",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L553-L574 | train |
KE-works/pykechain | pykechain/client.py | Client.model | def model(self, *args, **kwargs):
# type: (*Any, **Any) -> Part
"""Retrieve single KE-chain part model.
Uses the same interface as the :func:`part` method but returns only a single pykechain
:class:`models.Part` instance of category `MODEL`.
If additional `keyword=value` argume... | python | def model(self, *args, **kwargs):
# type: (*Any, **Any) -> Part
"""Retrieve single KE-chain part model.
Uses the same interface as the :func:`part` method but returns only a single pykechain
:class:`models.Part` instance of category `MODEL`.
If additional `keyword=value` argume... | [
"def",
"model",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'category'",
"]",
"=",
"Category",
".",
"MODEL",
"_parts",
"=",
"self",
".",
"parts",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"len",
"(",
"_pa... | Retrieve single KE-chain part model.
Uses the same interface as the :func:`part` method but returns only a single pykechain
:class:`models.Part` instance of category `MODEL`.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer t... | [
"Retrieve",
"single",
"KE",
"-",
"chain",
"part",
"model",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L576-L598 | train |
KE-works/pykechain | pykechain/client.py | Client.property | def property(self, *args, **kwargs):
# type: (*Any, **Any) -> Property
"""Retrieve single KE-chain Property.
Uses the same interface as the :func:`properties` method but returns only a single pykechain :class:
`models.Property` instance.
If additional `keyword=value` arguments ... | python | def property(self, *args, **kwargs):
# type: (*Any, **Any) -> Property
"""Retrieve single KE-chain Property.
Uses the same interface as the :func:`properties` method but returns only a single pykechain :class:
`models.Property` instance.
If additional `keyword=value` arguments ... | [
"def",
"property",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_properties",
"=",
"self",
".",
"properties",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"len",
"(",
"_properties",
")",
"==",
"0",
":",
"raise",
"NotFoundError"... | Retrieve single KE-chain Property.
Uses the same interface as the :func:`properties` method but returns only a single pykechain :class:
`models.Property` instance.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the docum... | [
"Retrieve",
"single",
"KE",
"-",
"chain",
"Property",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L600-L621 | train |
KE-works/pykechain | pykechain/client.py | Client.properties | def properties(self, name=None, pk=None, category=Category.INSTANCE, **kwargs):
# type: (Optional[str], Optional[str], Optional[str], **Any) -> List[Property]
"""Retrieve properties.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
... | python | def properties(self, name=None, pk=None, category=Category.INSTANCE, **kwargs):
# type: (Optional[str], Optional[str], Optional[str], **Any) -> List[Property]
"""Retrieve properties.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
... | [
"def",
"properties",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"category",
"=",
"Category",
".",
"INSTANCE",
",",
"**",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'name'",
":",
"name",
",",
"'id'",
":",
"pk",
",",
"'... | Retrieve properties.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param name: name to limit the search for.
:type name: basestring or None
... | [
"Retrieve",
"properties",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L623-L656 | train |
KE-works/pykechain | pykechain/client.py | Client.services | def services(self, name=None, pk=None, scope=None, **kwargs):
"""
Retrieve Services.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param na... | python | def services(self, name=None, pk=None, scope=None, **kwargs):
"""
Retrieve Services.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param na... | [
"def",
"services",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'name'",
":",
"name",
",",
"'id'",
":",
"pk",
",",
"'scope'",
":",
"scope",
"... | Retrieve Services.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param name: (optional) name to limit the search for
:type name: basestring or None... | [
"Retrieve",
"Services",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L658-L690 | train |
KE-works/pykechain | pykechain/client.py | Client.service | def service(self, name=None, pk=None, scope=None, **kwargs):
"""
Retrieve single KE-chain Service.
Uses the same interface as the :func:`services` method but returns only a single pykechain
:class:`models.Service` instance.
:param name: (optional) name to limit the search for
... | python | def service(self, name=None, pk=None, scope=None, **kwargs):
"""
Retrieve single KE-chain Service.
Uses the same interface as the :func:`services` method but returns only a single pykechain
:class:`models.Service` instance.
:param name: (optional) name to limit the search for
... | [
"def",
"service",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"_services",
"=",
"self",
".",
"services",
"(",
"name",
"=",
"name",
",",
"pk",
"=",
"pk",
",",
"scope",
... | Retrieve single KE-chain Service.
Uses the same interface as the :func:`services` method but returns only a single pykechain
:class:`models.Service` instance.
:param name: (optional) name to limit the search for
:type name: basestring or None
:param pk: (optional) primary key o... | [
"Retrieve",
"single",
"KE",
"-",
"chain",
"Service",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L692-L718 | train |
KE-works/pykechain | pykechain/client.py | Client.service_executions | def service_executions(self, name=None, pk=None, scope=None, service=None, **kwargs):
"""
Retrieve Service Executions.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional qu... | python | def service_executions(self, name=None, pk=None, scope=None, service=None, **kwargs):
"""
Retrieve Service Executions.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional qu... | [
"def",
"service_executions",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"service",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'name'",
":",
"name",
",",
"'id'",
":",
... | Retrieve Service Executions.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
refer to the documentation of the KE-chain API for additional query parameters.
:param name: (optional) name to limit the search for
:type name: basestri... | [
"Retrieve",
"Service",
"Executions",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L720-L755 | train |
KE-works/pykechain | pykechain/client.py | Client.service_execution | def service_execution(self, name=None, pk=None, scope=None, service=None, **kwargs):
"""
Retrieve single KE-chain ServiceExecution.
Uses the same interface as the :func:`service_executions` method but returns only a single
pykechain :class:`models.ServiceExecution` instance.
If... | python | def service_execution(self, name=None, pk=None, scope=None, service=None, **kwargs):
"""
Retrieve single KE-chain ServiceExecution.
Uses the same interface as the :func:`service_executions` method but returns only a single
pykechain :class:`models.ServiceExecution` instance.
If... | [
"def",
"service_execution",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"service",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"_service_executions",
"=",
"self",
".",
"service_executions",
"(",
"name",
... | Retrieve single KE-chain ServiceExecution.
Uses the same interface as the :func:`service_executions` method but returns only a single
pykechain :class:`models.ServiceExecution` instance.
If additional `keyword=value` arguments are provided, these are added to the request parameters. Please
... | [
"Retrieve",
"single",
"KE",
"-",
"chain",
"ServiceExecution",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L757-L786 | train |
KE-works/pykechain | pykechain/client.py | Client.users | def users(self, username=None, pk=None, **kwargs):
"""
Users of KE-chain.
Provide a list of :class:`User`s of KE-chain. You can filter on username or id or any other advanced filter.
:param username: (optional) username to filter
:type username: basestring or None
:para... | python | def users(self, username=None, pk=None, **kwargs):
"""
Users of KE-chain.
Provide a list of :class:`User`s of KE-chain. You can filter on username or id or any other advanced filter.
:param username: (optional) username to filter
:type username: basestring or None
:para... | [
"def",
"users",
"(",
"self",
",",
"username",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'username'",
":",
"username",
",",
"'pk'",
":",
"pk",
",",
"}",
"if",
"kwargs",
":",
"request_params",
".",... | Users of KE-chain.
Provide a list of :class:`User`s of KE-chain. You can filter on username or id or any other advanced filter.
:param username: (optional) username to filter
:type username: basestring or None
:param pk: (optional) id of the user to filter
:type pk: basestring ... | [
"Users",
"of",
"KE",
"-",
"chain",
"."
] | b0296cf34328fd41660bf6f0b9114fd0167c40c4 | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L788-L816 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.