partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | ThermalSpectralElement.temperature | Set temperature. | synphot/thermal.py | def temperature(self, what):
"""Set temperature."""
self._temperature = units.validate_quantity(what, u.K) | def temperature(self, what):
"""Set temperature."""
self._temperature = units.validate_quantity(what, u.K) | [
"Set",
"temperature",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L53-L55 | [
"def",
"temperature",
"(",
"self",
",",
"what",
")",
":",
"self",
".",
"_temperature",
"=",
"units",
".",
"validate_quantity",
"(",
"what",
",",
"u",
".",
"K",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ThermalSpectralElement.thermal_source | Apply emissivity to an existing beam to produce a thermal
source spectrum (without optical counterpart).
Thermal source spectrum is calculated as follow:
#. Create a blackbody spectrum in PHOTLAM per square arcsec
with `temperature`.
#. Multiply the blackbody wit... | synphot/thermal.py | def thermal_source(self):
"""Apply emissivity to an existing beam to produce a thermal
source spectrum (without optical counterpart).
Thermal source spectrum is calculated as follow:
#. Create a blackbody spectrum in PHOTLAM per square arcsec
with `temperature`.
... | def thermal_source(self):
"""Apply emissivity to an existing beam to produce a thermal
source spectrum (without optical counterpart).
Thermal source spectrum is calculated as follow:
#. Create a blackbody spectrum in PHOTLAM per square arcsec
with `temperature`.
... | [
"Apply",
"emissivity",
"to",
"an",
"existing",
"beam",
"to",
"produce",
"a",
"thermal",
"source",
"spectrum",
"(",
"without",
"optical",
"counterpart",
")",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L72-L92 | [
"def",
"thermal_source",
"(",
"self",
")",
":",
"sp",
"=",
"(",
"SourceSpectrum",
"(",
"BlackBody1D",
",",
"temperature",
"=",
"self",
".",
"temperature",
")",
"*",
"units",
".",
"SR_PER_ARCSEC2",
"*",
"self",
".",
"beam_fill_factor",
"*",
"self",
")",
"sp... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ThermalSpectralElement.from_file | Creates a thermal spectral element from file.
.. note::
Only FITS format is supported.
Parameters
----------
filename : str
Thermal spectral element filename.
temperature_key, beamfill_key : str
Keywords in FITS *table extension* that store... | synphot/thermal.py | def from_file(cls, filename, temperature_key='DEFT',
beamfill_key='BEAMFILL', **kwargs):
"""Creates a thermal spectral element from file.
.. note::
Only FITS format is supported.
Parameters
----------
filename : str
Thermal spectral el... | def from_file(cls, filename, temperature_key='DEFT',
beamfill_key='BEAMFILL', **kwargs):
"""Creates a thermal spectral element from file.
.. note::
Only FITS format is supported.
Parameters
----------
filename : str
Thermal spectral el... | [
"Creates",
"a",
"thermal",
"spectral",
"element",
"from",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L95-L150 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"temperature_key",
"=",
"'DEFT'",
",",
"beamfill_key",
"=",
"'BEAMFILL'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"(",
"filename",
".",
"endswith",
"(",
"'fits'",
")",
"or",
"filename",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | FrameGetAllNodesInformationConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_get_all_nodes_information.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = AllNodesInformationStatus(payload[0])
self.number_of_nodes = payload[1] | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = AllNodesInformationStatus(payload[0])
self.number_of_nodes = payload[1] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L46-L49 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"status",
"=",
"AllNodesInformationStatus",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"number_of_nodes",
"=",
"payload",
"[",
"1",
"]"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetAllNodesInformationNotification.get_payload | Return Payload. | pyvlx/frames/frame_get_all_nodes_information.py | def get_payload(self):
"""Return Payload."""
payload = bytes()
payload += bytes([self.node_id])
payload += bytes([self.order >> 8 & 255, self.order & 255])
payload += bytes([self.placement])
payload += bytes(string_to_bytes(self.name, 64))
payload += bytes([self.v... | def get_payload(self):
"""Return Payload."""
payload = bytes()
payload += bytes([self.node_id])
payload += bytes([self.order >> 8 & 255, self.order & 255])
payload += bytes([self.placement])
payload += bytes(string_to_bytes(self.name, 64))
payload += bytes([self.v... | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L92-L118 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
")",
"payload",
"+=",
"bytes",
"(",
"[",
"self",
".",
"node_id",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"[",
"self",
".",
"order",
">>",
"8",
"&",
"255",
",",
"self",
".... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetAllNodesInformationNotification.from_payload | Init frame from binary data. | pyvlx/frames/frame_get_all_nodes_information.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.order = payload[1] * 256 + payload[2]
self.placement = payload[3]
self.name = bytes_to_string(payload[4:68])
self.velocity = Velocity(payload[68])
self.node_type = N... | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.order = payload[1] * 256 + payload[2]
self.placement = payload[3]
self.name = bytes_to_string(payload[4:68])
self.velocity = Velocity(payload[68])
self.node_type = N... | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L120-L143 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"node_id",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"order",
"=",
"payload",
"[",
"1",
"]",
"*",
"256",
"+",
"payload",
"[",
"2",
"]",
"self",
".",
"placement",
"=",
"p... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Parameter.from_parameter | Set internal raw state from parameter. | pyvlx/parameter.py | def from_parameter(self, parameter):
"""Set internal raw state from parameter."""
if not isinstance(parameter, Parameter):
raise Exception("parameter::from_parameter_wrong_object")
self.raw = parameter.raw | def from_parameter(self, parameter):
"""Set internal raw state from parameter."""
if not isinstance(parameter, Parameter):
raise Exception("parameter::from_parameter_wrong_object")
self.raw = parameter.raw | [
"Set",
"internal",
"raw",
"state",
"from",
"parameter",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L21-L25 | [
"def",
"from_parameter",
"(",
"self",
",",
"parameter",
")",
":",
"if",
"not",
"isinstance",
"(",
"parameter",
",",
"Parameter",
")",
":",
"raise",
"Exception",
"(",
"\"parameter::from_parameter_wrong_object\"",
")",
"self",
".",
"raw",
"=",
"parameter",
".",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Parameter.from_int | Create raw out of position vlaue. | pyvlx/parameter.py | def from_int(value):
"""Create raw out of position vlaue."""
if not isinstance(value, int):
raise PyVLXException("value_has_to_be_int")
if not Parameter.is_valid_int(value):
raise PyVLXException("value_out_of_range")
return bytes([value >> 8 & 255, value & 255]) | def from_int(value):
"""Create raw out of position vlaue."""
if not isinstance(value, int):
raise PyVLXException("value_has_to_be_int")
if not Parameter.is_valid_int(value):
raise PyVLXException("value_out_of_range")
return bytes([value >> 8 & 255, value & 255]) | [
"Create",
"raw",
"out",
"of",
"position",
"vlaue",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L28-L34 | [
"def",
"from_int",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"raise",
"PyVLXException",
"(",
"\"value_has_to_be_int\"",
")",
"if",
"not",
"Parameter",
".",
"is_valid_int",
"(",
"value",
")",
":",
"raise",
"PyVLX... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Parameter.is_valid_int | Test if value can be rendered out of int. | pyvlx/parameter.py | def is_valid_int(value):
"""Test if value can be rendered out of int."""
if 0 <= value <= Parameter.MAX: # This includes ON and OFF
return True
if value == Parameter.UNKNOWN_VALUE:
return True
if value == Parameter.CURRENT_POSITION:
return True
... | def is_valid_int(value):
"""Test if value can be rendered out of int."""
if 0 <= value <= Parameter.MAX: # This includes ON and OFF
return True
if value == Parameter.UNKNOWN_VALUE:
return True
if value == Parameter.CURRENT_POSITION:
return True
... | [
"Test",
"if",
"value",
"can",
"be",
"rendered",
"out",
"of",
"int",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L37-L45 | [
"def",
"is_valid_int",
"(",
"value",
")",
":",
"if",
"0",
"<=",
"value",
"<=",
"Parameter",
".",
"MAX",
":",
"# This includes ON and OFF",
"return",
"True",
"if",
"value",
"==",
"Parameter",
".",
"UNKNOWN_VALUE",
":",
"return",
"True",
"if",
"value",
"==",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Parameter.from_raw | Test if raw packets are valid for initialization of Position. | pyvlx/parameter.py | def from_raw(raw):
"""Test if raw packets are valid for initialization of Position."""
if not isinstance(raw, bytes):
raise PyVLXException("Position::raw_must_be_bytes")
if len(raw) != 2:
raise PyVLXException("Position::raw_must_be_two_bytes")
if raw != Position.f... | def from_raw(raw):
"""Test if raw packets are valid for initialization of Position."""
if not isinstance(raw, bytes):
raise PyVLXException("Position::raw_must_be_bytes")
if len(raw) != 2:
raise PyVLXException("Position::raw_must_be_two_bytes")
if raw != Position.f... | [
"Test",
"if",
"raw",
"packets",
"are",
"valid",
"for",
"initialization",
"of",
"Position",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L48-L58 | [
"def",
"from_raw",
"(",
"raw",
")",
":",
"if",
"not",
"isinstance",
"(",
"raw",
",",
"bytes",
")",
":",
"raise",
"PyVLXException",
"(",
"\"Position::raw_must_be_bytes\"",
")",
"if",
"len",
"(",
"raw",
")",
"!=",
"2",
":",
"raise",
"PyVLXException",
"(",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Position.from_percent | Create raw value out of percent position. | pyvlx/parameter.py | def from_percent(position_percent):
"""Create raw value out of percent position."""
if not isinstance(position_percent, int):
raise PyVLXException("Position::position_percent_has_to_be_int")
if position_percent < 0:
raise PyVLXException("Position::position_percent_has_to_... | def from_percent(position_percent):
"""Create raw value out of percent position."""
if not isinstance(position_percent, int):
raise PyVLXException("Position::position_percent_has_to_be_int")
if position_percent < 0:
raise PyVLXException("Position::position_percent_has_to_... | [
"Create",
"raw",
"value",
"out",
"of",
"percent",
"position",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L172-L180 | [
"def",
"from_percent",
"(",
"position_percent",
")",
":",
"if",
"not",
"isinstance",
"(",
"position_percent",
",",
"int",
")",
":",
"raise",
"PyVLXException",
"(",
"\"Position::position_percent_has_to_be_int\"",
")",
"if",
"position_percent",
"<",
"0",
":",
"raise",... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetVersionConfirmation.product | Return product as human readable string. | pyvlx/frames/frame_get_version.py | def product(self):
"""Return product as human readable string."""
if self.product_group == 14 and self.product_type == 3:
return "KLF 200"
return "Unknown Product: {}:{}".format(self.product_group, self.product_type) | def product(self):
"""Return product as human readable string."""
if self.product_group == 14 and self.product_type == 3:
return "KLF 200"
return "Unknown Product: {}:{}".format(self.product_group, self.product_type) | [
"Return",
"product",
"as",
"human",
"readable",
"string",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L44-L48 | [
"def",
"product",
"(",
"self",
")",
":",
"if",
"self",
".",
"product_group",
"==",
"14",
"and",
"self",
".",
"product_type",
"==",
"3",
":",
"return",
"\"KLF 200\"",
"return",
"\"Unknown Product: {}:{}\"",
".",
"format",
"(",
"self",
".",
"product_group",
",... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetVersionConfirmation.get_payload | Return Payload. | pyvlx/frames/frame_get_version.py | def get_payload(self):
"""Return Payload."""
ret = self._software_version
ret += bytes([self.hardware_version, self.product_group, self.product_type])
return ret | def get_payload(self):
"""Return Payload."""
ret = self._software_version
ret += bytes([self.hardware_version, self.product_group, self.product_type])
return ret | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L50-L54 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"_software_version",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"hardware_version",
",",
"self",
".",
"product_group",
",",
"self",
".",
"product_type",
"]",
")",
"return",
"ret"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetVersionConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_get_version.py | def from_payload(self, payload):
"""Init frame from binary data."""
self._software_version = payload[0:6]
self.hardware_version = payload[6]
self.product_group = payload[7]
self.product_type = payload[8] | def from_payload(self, payload):
"""Init frame from binary data."""
self._software_version = payload[0:6]
self.hardware_version = payload[6]
self.product_group = payload[7]
self.product_type = payload[8] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L56-L61 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"_software_version",
"=",
"payload",
"[",
"0",
":",
"6",
"]",
"self",
".",
"hardware_version",
"=",
"payload",
"[",
"6",
"]",
"self",
".",
"product_group",
"=",
"payload",
"[",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameActivateSceneRequest.get_payload | Return Payload. | pyvlx/frames/frame_activate_scene.py | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.originator.value])
ret += bytes([self.priority.value])
ret += bytes([self.scene_id])
ret += bytes([self.velocity.value])
return ret | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.originator.value])
ret += bytes([self.priority.value])
ret += bytes([self.scene_id])
ret += bytes([self.velocity.value])
return ret | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L23-L30 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"session_id",
">>",
"8",
"&",
"255",
",",
"self",
".",
"session_id",
"&",
"255",
"]",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"originator",
".",
"v... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameActivateSceneRequest.from_payload | Init frame from binary data. | pyvlx/frames/frame_activate_scene.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.originator = Originator(payload[2])
self.priority = Priority(payload[3])
self.scene_id = payload[4]
self.velocity = Velocity(payload[5]) | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.originator = Originator(payload[2])
self.priority = Priority(payload[3])
self.scene_id = payload[4]
self.velocity = Velocity(payload[5]) | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L32-L38 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"session_id",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"originator",
"=",
"Originator",
"(",
"payload",
"[",
"2",
"]",
")",
"se... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameActivateSceneConfirmation.get_payload | Return Payload. | pyvlx/frames/frame_activate_scene.py | def get_payload(self):
"""Return Payload."""
ret = bytes([self.status.value])
ret += bytes([self.session_id >> 8 & 255, self.session_id & 255])
return ret | def get_payload(self):
"""Return Payload."""
ret = bytes([self.status.value])
ret += bytes([self.session_id >> 8 & 255, self.session_id & 255])
return ret | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L65-L69 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"status",
".",
"value",
"]",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"session_id",
">>",
"8",
"&",
"255",
",",
"self",
".",
"session_id",
"&",
"255... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameActivateSceneConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_activate_scene.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = ActivateSceneConfirmationStatus(payload[0])
self.session_id = payload[1]*256 + payload[2] | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = ActivateSceneConfirmationStatus(payload[0])
self.session_id = payload[1]*256 + payload[2] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L71-L74 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"status",
"=",
"ActivateSceneConfirmationStatus",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"session_id",
"=",
"payload",
"[",
"1",
"]",
"*",
"256",
"+",
"payload",
"[",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandSendRequest.get_payload | Return Payload. | pyvlx/frames/frame_command_send.py | def get_payload(self):
"""Return Payload."""
# Session id
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.originator.value])
ret += bytes([self.priority.value])
ret += bytes([0]) # ParameterActive pointing to main parameter (MP)
... | def get_payload(self):
"""Return Payload."""
# Session id
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.originator.value])
ret += bytes([self.priority.value])
ret += bytes([0]) # ParameterActive pointing to main parameter (MP)
... | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L25-L50 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"# Session id",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"session_id",
">>",
"8",
"&",
"255",
",",
"self",
".",
"session_id",
"&",
"255",
"]",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"origin... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandSendRequest.from_payload | Init frame from binary data. | pyvlx/frames/frame_command_send.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.originator = Originator(payload[2])
self.priority = Priority(payload[3])
len_node_ids = payload[41]
if len_node_ids > 20:
raise PyVLXExcepti... | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.originator = Originator(payload[2])
self.priority = Priority(payload[3])
len_node_ids = payload[41]
if len_node_ids > 20:
raise PyVLXExcepti... | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L52-L65 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"session_id",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"originator",
"=",
"Originator",
"(",
"payload",
"[",
"2",
"]",
")",
"se... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandSendConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_command_send.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.status = CommandSendConfirmationStatus(payload[2]) | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.status = CommandSendConfirmationStatus(payload[2]) | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L98-L101 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"session_id",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"status",
"=",
"CommandSendConfirmationStatus",
"(",
"payload",
"[",
"2",
"]... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandRunStatusNotification.get_payload | Return Payload. | pyvlx/frames/frame_command_send.py | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.status_id])
ret += bytes([self.index_id])
ret += bytes([self.node_parameter])
ret += bytes([self.parameter_value >> 8 & 255, self.parameter_val... | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.status_id])
ret += bytes([self.index_id])
ret += bytes([self.node_parameter])
ret += bytes([self.parameter_value >> 8 & 255, self.parameter_val... | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L122-L132 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"session_id",
">>",
"8",
"&",
"255",
",",
"self",
".",
"session_id",
"&",
"255",
"]",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"status_id",
"]",
")"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandRunStatusNotification.from_payload | Init frame from binary data. | pyvlx/frames/frame_command_send.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.status_id = payload[2]
self.index_id = payload[3]
self.node_parameter = payload[4]
self.parameter_value = payload[5]*256 + payload[6] | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.status_id = payload[2]
self.index_id = payload[3]
self.node_parameter = payload[4]
self.parameter_value = payload[5]*256 + payload[6] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L134-L140 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"session_id",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"status_id",
"=",
"payload",
"[",
"2",
"]",
"self",
".",
"index_id",
"="... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandRemainingTimeNotification.get_payload | Return Payload. | pyvlx/frames/frame_command_send.py | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.index_id])
ret += bytes([self.node_parameter])
ret += bytes([self.seconds >> 8 & 255, self.seconds & 255])
return ret | def get_payload(self):
"""Return Payload."""
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.index_id])
ret += bytes([self.node_parameter])
ret += bytes([self.seconds >> 8 & 255, self.seconds & 255])
return ret | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L164-L170 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"session_id",
">>",
"8",
"&",
"255",
",",
"self",
".",
"session_id",
"&",
"255",
"]",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"self",
".",
"index_id",
"]",
")",... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameCommandRemainingTimeNotification.from_payload | Init frame from binary data. | pyvlx/frames/frame_command_send.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.index_id = payload[2]
self.node_parameter = payload[3]
self.seconds = payload[4]*256 + payload[5] | def from_payload(self, payload):
"""Init frame from binary data."""
self.session_id = payload[0]*256 + payload[1]
self.index_id = payload[2]
self.node_parameter = payload[3]
self.seconds = payload[4]*256 + payload[5] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L172-L177 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"session_id",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"index_id",
"=",
"payload",
"[",
"2",
"]",
"self",
".",
"node_parameter",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | main | Log packets from Bus. | examples/monitor.py | async def main(loop):
"""Log packets from Bus."""
# Setting debug
PYVLXLOG.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
PYVLXLOG.addHandler(stream_handler)
# Connecting to KLF 200
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
await... | async def main(loop):
"""Log packets from Bus."""
# Setting debug
PYVLXLOG.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
PYVLXLOG.addHandler(stream_handler)
# Connecting to KLF 200
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
await... | [
"Log",
"packets",
"from",
"Bus",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/examples/monitor.py#L9-L27 | [
"async",
"def",
"main",
"(",
"loop",
")",
":",
"# Setting debug",
"PYVLXLOG",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"stream_handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"stream_handler",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Node.rename | Change name of node. | pyvlx/node.py | async def rename(self, name):
"""Change name of node."""
set_node_name = SetNodeName(pyvlx=self.pyvlx, node_id=self.node_id, name=name)
await set_node_name.do_api_call()
if not set_node_name.success:
raise PyVLXException("Unable to rename node")
self.name = name | async def rename(self, name):
"""Change name of node."""
set_node_name = SetNodeName(pyvlx=self.pyvlx, node_id=self.node_id, name=name)
await set_node_name.do_api_call()
if not set_node_name.success:
raise PyVLXException("Unable to rename node")
self.name = name | [
"Change",
"name",
"of",
"node",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/node.py#L36-L42 | [
"async",
"def",
"rename",
"(",
"self",
",",
"name",
")",
":",
"set_node_name",
"=",
"SetNodeName",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"node_id",
"=",
"self",
".",
"node_id",
",",
"name",
"=",
"name",
")",
"await",
"set_node_name",
".",
"do_a... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | OpeningDevice.set_position | Set window to desired position.
Parameters:
* position: Position object containing the target position.
* wait_for_completion: If set, function will return
after device has reached target position. | pyvlx/opening_device.py | async def set_position(self, position, wait_for_completion=True):
"""Set window to desired position.
Parameters:
* position: Position object containing the target position.
* wait_for_completion: If set, function will return
after device has reached target positi... | async def set_position(self, position, wait_for_completion=True):
"""Set window to desired position.
Parameters:
* position: Position object containing the target position.
* wait_for_completion: If set, function will return
after device has reached target positi... | [
"Set",
"window",
"to",
"desired",
"position",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L24-L41 | [
"async",
"def",
"set_position",
"(",
"self",
",",
"position",
",",
"wait_for_completion",
"=",
"True",
")",
":",
"command_send",
"=",
"CommandSend",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"wait_for_completion",
"=",
"wait_for_completion",
",",
"node_id",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | OpeningDevice.open | Open window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position. | pyvlx/opening_device.py | async def open(self, wait_for_completion=True):
"""Open window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=Position(position_percent=0),
... | async def open(self, wait_for_completion=True):
"""Open window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=Position(position_percent=0),
... | [
"Open",
"window",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L43-L53 | [
"async",
"def",
"open",
"(",
"self",
",",
"wait_for_completion",
"=",
"True",
")",
":",
"await",
"self",
".",
"set_position",
"(",
"position",
"=",
"Position",
"(",
"position_percent",
"=",
"0",
")",
",",
"wait_for_completion",
"=",
"wait_for_completion",
")"
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | OpeningDevice.close | Close window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position. | pyvlx/opening_device.py | async def close(self, wait_for_completion=True):
"""Close window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=Position(position_percent=100),
... | async def close(self, wait_for_completion=True):
"""Close window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=Position(position_percent=100),
... | [
"Close",
"window",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L55-L65 | [
"async",
"def",
"close",
"(",
"self",
",",
"wait_for_completion",
"=",
"True",
")",
":",
"await",
"self",
".",
"set_position",
"(",
"position",
"=",
"Position",
"(",
"position_percent",
"=",
"100",
")",
",",
"wait_for_completion",
"=",
"wait_for_completion",
"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | OpeningDevice.stop | Stop window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position. | pyvlx/opening_device.py | async def stop(self, wait_for_completion=True):
"""Stop window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=CurrentPosition(),
wait_fo... | async def stop(self, wait_for_completion=True):
"""Stop window.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
await self.set_position(
position=CurrentPosition(),
wait_fo... | [
"Stop",
"window",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L67-L77 | [
"async",
"def",
"stop",
"(",
"self",
",",
"wait_for_completion",
"=",
"True",
")",
":",
"await",
"self",
".",
"set_position",
"(",
"position",
"=",
"CurrentPosition",
"(",
")",
",",
"wait_for_completion",
"=",
"wait_for_completion",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | _get_sampleset | Return sampleset of a model or `None` if undefined.
Model could be a real model or evaluated sampleset. | synphot/models.py | def _get_sampleset(model):
"""Return sampleset of a model or `None` if undefined.
Model could be a real model or evaluated sampleset."""
if isinstance(model, Model):
if hasattr(model, 'sampleset'):
w = model.sampleset()
else:
w = None
else:
w = model # Al... | def _get_sampleset(model):
"""Return sampleset of a model or `None` if undefined.
Model could be a real model or evaluated sampleset."""
if isinstance(model, Model):
if hasattr(model, 'sampleset'):
w = model.sampleset()
else:
w = None
else:
w = model # Al... | [
"Return",
"sampleset",
"of",
"a",
"model",
"or",
"None",
"if",
"undefined",
".",
"Model",
"could",
"be",
"a",
"real",
"model",
"or",
"evaluated",
"sampleset",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L654-L664 | [
"def",
"_get_sampleset",
"(",
"model",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"Model",
")",
":",
"if",
"hasattr",
"(",
"model",
",",
"'sampleset'",
")",
":",
"w",
"=",
"model",
".",
"sampleset",
"(",
")",
"else",
":",
"w",
"=",
"None",
"e... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | _merge_sampleset | Simple merge of samplesets. | synphot/models.py | def _merge_sampleset(model1, model2):
"""Simple merge of samplesets."""
w1 = _get_sampleset(model1)
w2 = _get_sampleset(model2)
return merge_wavelengths(w1, w2) | def _merge_sampleset(model1, model2):
"""Simple merge of samplesets."""
w1 = _get_sampleset(model1)
w2 = _get_sampleset(model2)
return merge_wavelengths(w1, w2) | [
"Simple",
"merge",
"of",
"samplesets",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L667-L671 | [
"def",
"_merge_sampleset",
"(",
"model1",
",",
"model2",
")",
":",
"w1",
"=",
"_get_sampleset",
"(",
"model1",
")",
"w2",
"=",
"_get_sampleset",
"(",
"model2",
")",
"return",
"merge_wavelengths",
"(",
"w1",
",",
"w2",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | _shift_wavelengths | One of the models is either ``RedshiftScaleFactor`` or ``Scale``.
Possible combos::
RedshiftScaleFactor | Model
Scale | Model
Model | Scale | synphot/models.py | def _shift_wavelengths(model1, model2):
"""One of the models is either ``RedshiftScaleFactor`` or ``Scale``.
Possible combos::
RedshiftScaleFactor | Model
Scale | Model
Model | Scale
"""
if isinstance(model1, _models.RedshiftScaleFactor):
val = _get_sampleset(model2)
... | def _shift_wavelengths(model1, model2):
"""One of the models is either ``RedshiftScaleFactor`` or ``Scale``.
Possible combos::
RedshiftScaleFactor | Model
Scale | Model
Model | Scale
"""
if isinstance(model1, _models.RedshiftScaleFactor):
val = _get_sampleset(model2)
... | [
"One",
"of",
"the",
"models",
"is",
"either",
"RedshiftScaleFactor",
"or",
"Scale",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L674-L694 | [
"def",
"_shift_wavelengths",
"(",
"model1",
",",
"model2",
")",
":",
"if",
"isinstance",
"(",
"model1",
",",
"_models",
".",
"RedshiftScaleFactor",
")",
":",
"val",
"=",
"_get_sampleset",
"(",
"model2",
")",
"if",
"val",
"is",
"None",
":",
"w",
"=",
"val... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | get_waveset | Get optimal wavelengths for sampling a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
waveset : array-like or `None`
Optimal wavelengths. `None` if undefined.
Raises
------
synphot.exceptions.SynphotError
Invalid... | synphot/models.py | def get_waveset(model):
"""Get optimal wavelengths for sampling a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
waveset : array-like or `None`
Optimal wavelengths. `None` if undefined.
Raises
------
synphot.exceptio... | def get_waveset(model):
"""Get optimal wavelengths for sampling a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
waveset : array-like or `None`
Optimal wavelengths. `None` if undefined.
Raises
------
synphot.exceptio... | [
"Get",
"optimal",
"wavelengths",
"for",
"sampling",
"a",
"given",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L708-L735 | [
"def",
"get_waveset",
"(",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"model",
",",
"Model",
")",
":",
"raise",
"SynphotError",
"(",
"'{0} is not a model.'",
".",
"format",
"(",
"model",
")",
")",
"if",
"isinstance",
"(",
"model",
",",
"_CompoundMo... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | _get_meta | Return metadata of a model.
Model could be a real model or evaluated metadata. | synphot/models.py | def _get_meta(model):
"""Return metadata of a model.
Model could be a real model or evaluated metadata."""
if isinstance(model, Model):
w = model.meta
else:
w = model # Already metadata
return w | def _get_meta(model):
"""Return metadata of a model.
Model could be a real model or evaluated metadata."""
if isinstance(model, Model):
w = model.meta
else:
w = model # Already metadata
return w | [
"Return",
"metadata",
"of",
"a",
"model",
".",
"Model",
"could",
"be",
"a",
"real",
"model",
"or",
"evaluated",
"metadata",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L744-L751 | [
"def",
"_get_meta",
"(",
"model",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"Model",
")",
":",
"w",
"=",
"model",
".",
"meta",
"else",
":",
"w",
"=",
"model",
"# Already metadata",
"return",
"w"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | _merge_meta | Simple merge of samplesets. | synphot/models.py | def _merge_meta(model1, model2):
"""Simple merge of samplesets."""
w1 = _get_meta(model1)
w2 = _get_meta(model2)
return metadata.merge(w1, w2, metadata_conflicts='silent') | def _merge_meta(model1, model2):
"""Simple merge of samplesets."""
w1 = _get_meta(model1)
w2 = _get_meta(model2)
return metadata.merge(w1, w2, metadata_conflicts='silent') | [
"Simple",
"merge",
"of",
"samplesets",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L754-L758 | [
"def",
"_merge_meta",
"(",
"model1",
",",
"model2",
")",
":",
"w1",
"=",
"_get_meta",
"(",
"model1",
")",
"w2",
"=",
"_get_meta",
"(",
"model2",
")",
"return",
"metadata",
".",
"merge",
"(",
"w1",
",",
"w2",
",",
"metadata_conflicts",
"=",
"'silent'",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | get_metadata | Get metadata for a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
metadata : dict
Metadata for the model.
Raises
------
synphot.exceptions.SynphotError
Invalid model. | synphot/models.py | def get_metadata(model):
"""Get metadata for a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
metadata : dict
Metadata for the model.
Raises
------
synphot.exceptions.SynphotError
Invalid model.
"""
... | def get_metadata(model):
"""Get metadata for a given model.
Parameters
----------
model : `~astropy.modeling.Model`
Model.
Returns
-------
metadata : dict
Metadata for the model.
Raises
------
synphot.exceptions.SynphotError
Invalid model.
"""
... | [
"Get",
"metadata",
"for",
"a",
"given",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L761-L788 | [
"def",
"get_metadata",
"(",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"model",
",",
"Model",
")",
":",
"raise",
"SynphotError",
"(",
"'{0} is not a model.'",
".",
"format",
"(",
"model",
")",
")",
"if",
"isinstance",
"(",
"model",
",",
"_CompoundM... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BlackBody1D.lambda_max | Peak wavelength in Angstrom when the curve is expressed as
power density. | synphot/models.py | def lambda_max(self):
"""Peak wavelength in Angstrom when the curve is expressed as
power density."""
return ((const.b_wien.value / self.temperature) * u.m).to(u.AA).value | def lambda_max(self):
"""Peak wavelength in Angstrom when the curve is expressed as
power density."""
return ((const.b_wien.value / self.temperature) * u.m).to(u.AA).value | [
"Peak",
"wavelength",
"in",
"Angstrom",
"when",
"the",
"curve",
"is",
"expressed",
"as",
"power",
"density",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L53-L56 | [
"def",
"lambda_max",
"(",
"self",
")",
":",
"return",
"(",
"(",
"const",
".",
"b_wien",
".",
"value",
"/",
"self",
".",
"temperature",
")",
"*",
"u",
".",
"m",
")",
".",
"to",
"(",
"u",
".",
"AA",
")",
".",
"value"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BlackBody1D.bounding_box | Tuple defining the default ``bounding_box`` limits,
``(x_low, x_high)``.
.. math::
x_{\\textnormal{low}} = 0
x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\
(1 + \\textnormal{factor}))
Parameters
----------
factor : float
... | synphot/models.py | def bounding_box(self, factor=10.0):
"""Tuple defining the default ``bounding_box`` limits,
``(x_low, x_high)``.
.. math::
x_{\\textnormal{low}} = 0
x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\
(1 + \\textnormal{factor}))
Parame... | def bounding_box(self, factor=10.0):
"""Tuple defining the default ``bounding_box`` limits,
``(x_low, x_high)``.
.. math::
x_{\\textnormal{low}} = 0
x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\
(1 + \\textnormal{factor}))
Parame... | [
"Tuple",
"defining",
"the",
"default",
"bounding_box",
"limits",
"(",
"x_low",
"x_high",
")",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L58-L76 | [
"def",
"bounding_box",
"(",
"self",
",",
"factor",
"=",
"10.0",
")",
":",
"w0",
"=",
"self",
".",
"lambda_max",
"return",
"(",
"w0",
"*",
"0",
",",
"np",
".",
"log10",
"(",
"w0",
"+",
"factor",
"*",
"w0",
")",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BlackBody1D.sampleset | Return ``x`` array that samples the feature.
Parameters
----------
factor_bbox : float
Factor for ``bounding_box`` calculations.
num : int
Number of points to generate. | synphot/models.py | def sampleset(self, factor_bbox=10.0, num=1000):
"""Return ``x`` array that samples the feature.
Parameters
----------
factor_bbox : float
Factor for ``bounding_box`` calculations.
num : int
Number of points to generate.
"""
w1, w2 = sel... | def sampleset(self, factor_bbox=10.0, num=1000):
"""Return ``x`` array that samples the feature.
Parameters
----------
factor_bbox : float
Factor for ``bounding_box`` calculations.
num : int
Number of points to generate.
"""
w1, w2 = sel... | [
"Return",
"x",
"array",
"that",
"samples",
"the",
"feature",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L78-L97 | [
"def",
"sampleset",
"(",
"self",
",",
"factor_bbox",
"=",
"10.0",
",",
"num",
"=",
"1000",
")",
":",
"w1",
",",
"w2",
"=",
"self",
".",
"bounding_box",
"(",
"factor",
"=",
"factor_bbox",
")",
"if",
"self",
".",
"_n_models",
"==",
"1",
":",
"w",
"="... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BlackBody1D.evaluate | Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbody radiation in PHOTLAM per steradian. | synphot/models.py | def evaluate(x, temperature):
"""Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbody rad... | def evaluate(x, temperature):
"""Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbody rad... | [
"Evaluate",
"the",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L100-L133 | [
"def",
"evaluate",
"(",
"x",
",",
"temperature",
")",
":",
"if",
"ASTROPY_LT_2_0",
":",
"from",
"astropy",
".",
"analytic_functions",
".",
"blackbody",
"import",
"blackbody_nu",
"else",
":",
"from",
"astropy",
".",
"modeling",
".",
"blackbody",
"import",
"blac... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BlackBodyNorm1D.evaluate | Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbody radiation in PHOTLAM. | synphot/models.py | def evaluate(self, x, temperature):
"""Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbo... | def evaluate(self, x, temperature):
"""Evaluate the model.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
temperature : number
Temperature in Kelvin.
Returns
-------
y : number or ndarray
Blackbo... | [
"Evaluate",
"the",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L157-L175 | [
"def",
"evaluate",
"(",
"self",
",",
"x",
",",
"temperature",
")",
":",
"bbflux",
"=",
"super",
"(",
"BlackBodyNorm1D",
",",
"self",
")",
".",
"evaluate",
"(",
"x",
",",
"temperature",
")",
"return",
"bbflux",
"*",
"self",
".",
"_omega"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Box1D._calc_sampleset | Calculate sampleset for each model. | synphot/models.py | def _calc_sampleset(w1, w2, step, minimal):
"""Calculate sampleset for each model."""
if minimal:
arr = [w1 - step, w1, w2, w2 + step]
else:
arr = np.arange(w1 - step, w2 + step + step, step)
return arr | def _calc_sampleset(w1, w2, step, minimal):
"""Calculate sampleset for each model."""
if minimal:
arr = [w1 - step, w1, w2, w2 + step]
else:
arr = np.arange(w1 - step, w2 + step + step, step)
return arr | [
"Calculate",
"sampleset",
"for",
"each",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L184-L191 | [
"def",
"_calc_sampleset",
"(",
"w1",
",",
"w2",
",",
"step",
",",
"minimal",
")",
":",
"if",
"minimal",
":",
"arr",
"=",
"[",
"w1",
"-",
"step",
",",
"w1",
",",
"w2",
",",
"w2",
"+",
"step",
"]",
"else",
":",
"arr",
"=",
"np",
".",
"arange",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Box1D.sampleset | Return ``x`` array that samples the feature.
Parameters
----------
step : float
Distance of first and last points w.r.t. bounding box.
minimal : bool
Only return the minimal points needed to define the box;
i.e., box edges and a point outside on each... | synphot/models.py | def sampleset(self, step=0.01, minimal=False):
"""Return ``x`` array that samples the feature.
Parameters
----------
step : float
Distance of first and last points w.r.t. bounding box.
minimal : bool
Only return the minimal points needed to define the bo... | def sampleset(self, step=0.01, minimal=False):
"""Return ``x`` array that samples the feature.
Parameters
----------
step : float
Distance of first and last points w.r.t. bounding box.
minimal : bool
Only return the minimal points needed to define the bo... | [
"Return",
"x",
"array",
"that",
"samples",
"the",
"feature",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L193-L214 | [
"def",
"sampleset",
"(",
"self",
",",
"step",
"=",
"0.01",
",",
"minimal",
"=",
"False",
")",
":",
"w1",
",",
"w2",
"=",
"self",
".",
"bounding_box",
"if",
"self",
".",
"_n_models",
"==",
"1",
":",
"w",
"=",
"self",
".",
"_calc_sampleset",
"(",
"w1... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ConstFlux1D.evaluate | One dimensional constant flux model function.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
Returns
-------
y : number or ndarray
Flux in PHOTLAM. | synphot/models.py | def evaluate(self, x, *args):
"""One dimensional constant flux model function.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
Returns
-------
y : number or ndarray
Flux in PHOTLAM.
"""
a = (self.ampl... | def evaluate(self, x, *args):
"""One dimensional constant flux model function.
Parameters
----------
x : number or ndarray
Wavelengths in Angstrom.
Returns
-------
y : number or ndarray
Flux in PHOTLAM.
"""
a = (self.ampl... | [
"One",
"dimensional",
"constant",
"flux",
"model",
"function",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L252-L268 | [
"def",
"evaluate",
"(",
"self",
",",
"x",
",",
"*",
"args",
")",
":",
"a",
"=",
"(",
"self",
".",
"amplitude",
"*",
"np",
".",
"ones_like",
"(",
"x",
")",
")",
"*",
"self",
".",
"_flux_unit",
"y",
"=",
"units",
".",
"convert_flux",
"(",
"x",
",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Empirical1D._process_neg_flux | Remove negative flux. | synphot/models.py | def _process_neg_flux(self, x, y):
"""Remove negative flux."""
if self._keep_neg: # Nothing to do
return y
old_y = None
if np.isscalar(y): # pragma: no cover
if y < 0:
n_neg = 1
old_x = x
old_y = y
... | def _process_neg_flux(self, x, y):
"""Remove negative flux."""
if self._keep_neg: # Nothing to do
return y
old_y = None
if np.isscalar(y): # pragma: no cover
if y < 0:
n_neg = 1
old_x = x
old_y = y
... | [
"Remove",
"negative",
"flux",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L328-L360 | [
"def",
"_process_neg_flux",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"self",
".",
"_keep_neg",
":",
"# Nothing to do",
"return",
"y",
"old_y",
"=",
"None",
"if",
"np",
".",
"isscalar",
"(",
"y",
")",
":",
"# pragma: no cover",
"if",
"y",
"<",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Empirical1D.evaluate | Evaluate the model.
Parameters
----------
inputs : number or ndarray
Wavelengths in same unit as ``points``.
Returns
-------
y : number or ndarray
Flux or throughput in same unit as ``lookup_table``. | synphot/models.py | def evaluate(self, inputs):
"""Evaluate the model.
Parameters
----------
inputs : number or ndarray
Wavelengths in same unit as ``points``.
Returns
-------
y : number or ndarray
Flux or throughput in same unit as ``lookup_table``.
... | def evaluate(self, inputs):
"""Evaluate the model.
Parameters
----------
inputs : number or ndarray
Wavelengths in same unit as ``points``.
Returns
-------
y : number or ndarray
Flux or throughput in same unit as ``lookup_table``.
... | [
"Evaluate",
"the",
"model",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L370-L401 | [
"def",
"evaluate",
"(",
"self",
",",
"inputs",
")",
":",
"y",
"=",
"super",
"(",
"Empirical1D",
",",
"self",
")",
".",
"evaluate",
"(",
"inputs",
")",
"# Assume NaN at both ends need to be extrapolated based on",
"# nearest end point.",
"if",
"self",
".",
"fill_va... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | GaussianAbsorption1D.evaluate | GaussianAbsorption1D model function. | synphot/models.py | def evaluate(x, amplitude, mean, stddev):
"""
GaussianAbsorption1D model function.
"""
return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev) | def evaluate(x, amplitude, mean, stddev):
"""
GaussianAbsorption1D model function.
"""
return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev) | [
"GaussianAbsorption1D",
"model",
"function",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L452-L456 | [
"def",
"evaluate",
"(",
"x",
",",
"amplitude",
",",
"mean",
",",
"stddev",
")",
":",
"return",
"1.0",
"-",
"Gaussian1D",
".",
"evaluate",
"(",
"x",
",",
"amplitude",
",",
"mean",
",",
"stddev",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | GaussianAbsorption1D.fit_deriv | GaussianAbsorption1D model function derivatives. | synphot/models.py | def fit_deriv(x, amplitude, mean, stddev):
"""
GaussianAbsorption1D model function derivatives.
"""
import operator
return list(map(
operator.neg, Gaussian1D.fit_deriv(x, amplitude, mean, stddev))) | def fit_deriv(x, amplitude, mean, stddev):
"""
GaussianAbsorption1D model function derivatives.
"""
import operator
return list(map(
operator.neg, Gaussian1D.fit_deriv(x, amplitude, mean, stddev))) | [
"GaussianAbsorption1D",
"model",
"function",
"derivatives",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L459-L465 | [
"def",
"fit_deriv",
"(",
"x",
",",
"amplitude",
",",
"mean",
",",
"stddev",
")",
":",
"import",
"operator",
"return",
"list",
"(",
"map",
"(",
"operator",
".",
"neg",
",",
"Gaussian1D",
".",
"fit_deriv",
"(",
"x",
",",
"amplitude",
",",
"mean",
",",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Lorentz1D.sampleset | Return ``x`` array that samples the feature.
Parameters
----------
factor_step : float
Factor for sample step calculation. The step is calculated
using ``factor_step * self.fwhm``.
kwargs : dict
Keyword(s) for ``bounding_box`` calculation. | synphot/models.py | def sampleset(self, factor_step=0.05, **kwargs):
"""Return ``x`` array that samples the feature.
Parameters
----------
factor_step : float
Factor for sample step calculation. The step is calculated
using ``factor_step * self.fwhm``.
kwargs : dict
... | def sampleset(self, factor_step=0.05, **kwargs):
"""Return ``x`` array that samples the feature.
Parameters
----------
factor_step : float
Factor for sample step calculation. The step is calculated
using ``factor_step * self.fwhm``.
kwargs : dict
... | [
"Return",
"x",
"array",
"that",
"samples",
"the",
"feature",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L530-L551 | [
"def",
"sampleset",
"(",
"self",
",",
"factor_step",
"=",
"0.05",
",",
"*",
"*",
"kwargs",
")",
":",
"w1",
",",
"w2",
"=",
"self",
".",
"bounding_box",
"(",
"*",
"*",
"kwargs",
")",
"dw",
"=",
"factor_step",
"*",
"self",
".",
"fwhm",
"if",
"self",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | PowerLawFlux1D.evaluate | Return flux in PHOTLAM. Assume input wavelength is in Angstrom. | synphot/models.py | def evaluate(self, x, *args):
"""Return flux in PHOTLAM. Assume input wavelength is in Angstrom."""
xx = x / self.x_0
y = (self.amplitude * xx ** (-self.alpha)) * self._flux_unit
flux = units.convert_flux(x, y, units.PHOTLAM)
return flux.value | def evaluate(self, x, *args):
"""Return flux in PHOTLAM. Assume input wavelength is in Angstrom."""
xx = x / self.x_0
y = (self.amplitude * xx ** (-self.alpha)) * self._flux_unit
flux = units.convert_flux(x, y, units.PHOTLAM)
return flux.value | [
"Return",
"flux",
"in",
"PHOTLAM",
".",
"Assume",
"input",
"wavelength",
"is",
"in",
"Angstrom",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L624-L629 | [
"def",
"evaluate",
"(",
"self",
",",
"x",
",",
"*",
"args",
")",
":",
"xx",
"=",
"x",
"/",
"self",
".",
"x_0",
"y",
"=",
"(",
"self",
".",
"amplitude",
"*",
"xx",
"**",
"(",
"-",
"self",
".",
"alpha",
")",
")",
"*",
"self",
".",
"_flux_unit",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Trapezoid1D.sampleset | Return ``x`` array that samples the feature. | synphot/models.py | def sampleset(self):
"""Return ``x`` array that samples the feature."""
x1, x4 = self.bounding_box
dw = self.width * 0.5
x2 = self.x_0 - dw
x3 = self.x_0 + dw
if self._n_models == 1:
w = [x1, x2, x3, x4]
else:
w = list(zip(x1, x2, x3, x4))... | def sampleset(self):
"""Return ``x`` array that samples the feature."""
x1, x4 = self.bounding_box
dw = self.width * 0.5
x2 = self.x_0 - dw
x3 = self.x_0 + dw
if self._n_models == 1:
w = [x1, x2, x3, x4]
else:
w = list(zip(x1, x2, x3, x4))... | [
"Return",
"x",
"array",
"that",
"samples",
"the",
"feature",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L637-L649 | [
"def",
"sampleset",
"(",
"self",
")",
":",
"x1",
",",
"x4",
"=",
"self",
".",
"bounding_box",
"dw",
"=",
"self",
".",
"width",
"*",
"0.5",
"x2",
"=",
"self",
".",
"x_0",
"-",
"dw",
"x3",
"=",
"self",
".",
"x_0",
"+",
"dw",
"if",
"self",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | StripePayment.get_payment_request | From the given request, add a snippet to the page. | shop_stripe/payment.py | def get_payment_request(self, cart, request):
"""
From the given request, add a snippet to the page.
"""
try:
self.charge(cart, request)
thank_you_url = OrderModel.objects.get_latest_url()
js_expression = 'window.location.href="{}";'.format(thank_you_u... | def get_payment_request(self, cart, request):
"""
From the given request, add a snippet to the page.
"""
try:
self.charge(cart, request)
thank_you_url = OrderModel.objects.get_latest_url()
js_expression = 'window.location.href="{}";'.format(thank_you_u... | [
"From",
"the",
"given",
"request",
"add",
"a",
"snippet",
"to",
"the",
"page",
"."
] | awesto/djangoshop-stripe | python | https://github.com/awesto/djangoshop-stripe/blob/010d4642f971961cfeb415520ad819b3751281cb/shop_stripe/payment.py#L28-L38 | [
"def",
"get_payment_request",
"(",
"self",
",",
"cart",
",",
"request",
")",
":",
"try",
":",
"self",
".",
"charge",
"(",
"cart",
",",
"request",
")",
"thank_you_url",
"=",
"OrderModel",
".",
"objects",
".",
"get_latest_url",
"(",
")",
"js_expression",
"="... | 010d4642f971961cfeb415520ad819b3751281cb |
train | StripePayment.charge | Use the Stripe token from the request and charge immediately.
This view is invoked by the Javascript function `scope.charge()` delivered
by `get_payment_request`. | shop_stripe/payment.py | def charge(self, cart, request):
"""
Use the Stripe token from the request and charge immediately.
This view is invoked by the Javascript function `scope.charge()` delivered
by `get_payment_request`.
"""
token_id = cart.extra['payment_extra_data']['token_id']
if L... | def charge(self, cart, request):
"""
Use the Stripe token from the request and charge immediately.
This view is invoked by the Javascript function `scope.charge()` delivered
by `get_payment_request`.
"""
token_id = cart.extra['payment_extra_data']['token_id']
if L... | [
"Use",
"the",
"Stripe",
"token",
"from",
"the",
"request",
"and",
"charge",
"immediately",
".",
"This",
"view",
"is",
"invoked",
"by",
"the",
"Javascript",
"function",
"scope",
".",
"charge",
"()",
"delivered",
"by",
"get_payment_request",
"."
] | awesto/djangoshop-stripe | python | https://github.com/awesto/djangoshop-stripe/blob/010d4642f971961cfeb415520ad819b3751281cb/shop_stripe/payment.py#L40-L74 | [
"def",
"charge",
"(",
"self",
",",
"cart",
",",
"request",
")",
":",
"token_id",
"=",
"cart",
".",
"extra",
"[",
"'payment_extra_data'",
"]",
"[",
"'token_id'",
"]",
"if",
"LooseVersion",
"(",
"SHOP_VERSION",
")",
"<",
"LooseVersion",
"(",
"'0.11'",
")",
... | 010d4642f971961cfeb415520ad819b3751281cb |
train | OrderWorkflowMixin.refund_payment | Refund the payment using Stripe's refunding API. | shop_stripe/payment.py | def refund_payment(self):
"""
Refund the payment using Stripe's refunding API.
"""
Money = MoneyMaker(self.currency)
filter_kwargs = {
'transaction_id__startswith': 'ch_',
'payment_method': StripePayment.namespace,
}
for payment in self.ord... | def refund_payment(self):
"""
Refund the payment using Stripe's refunding API.
"""
Money = MoneyMaker(self.currency)
filter_kwargs = {
'transaction_id__startswith': 'ch_',
'payment_method': StripePayment.namespace,
}
for payment in self.ord... | [
"Refund",
"the",
"payment",
"using",
"Stripe",
"s",
"refunding",
"API",
"."
] | awesto/djangoshop-stripe | python | https://github.com/awesto/djangoshop-stripe/blob/010d4642f971961cfeb415520ad819b3751281cb/shop_stripe/payment.py#L104-L123 | [
"def",
"refund_payment",
"(",
"self",
")",
":",
"Money",
"=",
"MoneyMaker",
"(",
"self",
".",
"currency",
")",
"filter_kwargs",
"=",
"{",
"'transaction_id__startswith'",
":",
"'ch_'",
",",
"'payment_method'",
":",
"StripePayment",
".",
"namespace",
",",
"}",
"... | 010d4642f971961cfeb415520ad819b3751281cb |
train | WeatherForecast.create | Create an instance of the US Weather Forecast Service with
typical starting settings. | predix/admin/weather.py | def create(self):
"""
Create an instance of the US Weather Forecast Service with
typical starting settings.
"""
self.service.create()
# Set env vars for immediate use
zone_id = predix.config.get_env_key(self.use_class, 'zone_id')
zone = self.service.setti... | def create(self):
"""
Create an instance of the US Weather Forecast Service with
typical starting settings.
"""
self.service.create()
# Set env vars for immediate use
zone_id = predix.config.get_env_key(self.use_class, 'zone_id')
zone = self.service.setti... | [
"Create",
"an",
"instance",
"of",
"the",
"US",
"Weather",
"Forecast",
"Service",
"with",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/weather.py#L33-L46 | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"service",
".",
"create",
"(",
")",
"# Set env vars for immediate use",
"zone_id",
"=",
"predix",
".",
"config",
".",
"get_env_key",
"(",
"self",
".",
"use_class",
",",
"'zone_id'",
")",
"zone",
"=",
"se... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | WeatherForecast.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/weather.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/weather.py#L48-L68 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variables",
"zone_id",
"=",
"predix",
".",
"config",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Cache._create_in_progress | Creating this service is handled asynchronously so this method will
simply check if the create is in progress. If it is not in progress,
we could probably infer it either failed or succeeded. | predix/admin/cache.py | def _create_in_progress(self):
"""
Creating this service is handled asynchronously so this method will
simply check if the create is in progress. If it is not in progress,
we could probably infer it either failed or succeeded.
"""
instance = self.service.service.get_inst... | def _create_in_progress(self):
"""
Creating this service is handled asynchronously so this method will
simply check if the create is in progress. If it is not in progress,
we could probably infer it either failed or succeeded.
"""
instance = self.service.service.get_inst... | [
"Creating",
"this",
"service",
"is",
"handled",
"asynchronously",
"so",
"this",
"method",
"will",
"simply",
"check",
"if",
"the",
"create",
"is",
"in",
"progress",
".",
"If",
"it",
"is",
"not",
"in",
"progress",
"we",
"could",
"probably",
"infer",
"it",
"e... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cache.py#L28-L39 | [
"def",
"_create_in_progress",
"(",
"self",
")",
":",
"instance",
"=",
"self",
".",
"service",
".",
"service",
".",
"get_instance",
"(",
"self",
".",
"service",
".",
"name",
")",
"if",
"(",
"instance",
"[",
"'last_operation'",
"]",
"[",
"'state'",
"]",
"=... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Cache.create | Create an instance of the Predix Cache Service with they typical
starting settings.
:param max_wait: service is created asynchronously, so will only wait
this number of seconds before giving up. | predix/admin/cache.py | def create(self, max_wait=180, **kwargs):
"""
Create an instance of the Predix Cache Service with they typical
starting settings.
:param max_wait: service is created asynchronously, so will only wait
this number of seconds before giving up.
"""
# Will need t... | def create(self, max_wait=180, **kwargs):
"""
Create an instance of the Predix Cache Service with they typical
starting settings.
:param max_wait: service is created asynchronously, so will only wait
this number of seconds before giving up.
"""
# Will need t... | [
"Create",
"an",
"instance",
"of",
"the",
"Predix",
"Cache",
"Service",
"with",
"they",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cache.py#L41-L68 | [
"def",
"create",
"(",
"self",
",",
"max_wait",
"=",
"180",
",",
"*",
"*",
"kwargs",
")",
":",
"# Will need to wait for the service to be provisioned before can add",
"# service keys and get env details.",
"self",
".",
"service",
".",
"create",
"(",
"async",
"=",
"True... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Cache.add_to_manifest | Add useful details to the manifest about this service so
that it can be used in an application.
:param manifest: A predix.admin.app.Manifest object instance
that manages reading/writing manifest config for a
cloud foundry app. | predix/admin/cache.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service so
that it can be used in an application.
:param manifest: A predix.admin.app.Manifest object instance
that manages reading/writing manifest config for a
cloud foundry ... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service so
that it can be used in an application.
:param manifest: A predix.admin.app.Manifest object instance
that manages reading/writing manifest config for a
cloud foundry ... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cache.py#L70-L90 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"host",
"=",
"predix",
".",
"config",
".",
"get_env_key",
"(",
"self",
".",
"use_class",
",",
"'host'",
")",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_uri | Will return the uri for an existing instance. | predix/admin/acs.py | def _get_uri(self):
"""
Will return the uri for an existing instance.
"""
if not self.service.exists():
logging.warning("Service does not yet exist.")
return self.service.settings.data['uri'] | def _get_uri(self):
"""
Will return the uri for an existing instance.
"""
if not self.service.exists():
logging.warning("Service does not yet exist.")
return self.service.settings.data['uri'] | [
"Will",
"return",
"the",
"uri",
"for",
"an",
"existing",
"instance",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/acs.py#L23-L30 | [
"def",
"_get_uri",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"service",
".",
"exists",
"(",
")",
":",
"logging",
".",
"warning",
"(",
"\"Service does not yet exist.\"",
")",
"return",
"self",
".",
"service",
".",
"settings",
".",
"data",
"[",
"'ur... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_zone_id | Will return the zone id for an existing instance. | predix/admin/acs.py | def _get_zone_id(self):
"""
Will return the zone id for an existing instance.
"""
if not self.service.exists():
logging.warning("Service does not yet exist.")
return self.service.settings.data['zone']['http-header-value'] | def _get_zone_id(self):
"""
Will return the zone id for an existing instance.
"""
if not self.service.exists():
logging.warning("Service does not yet exist.")
return self.service.settings.data['zone']['http-header-value'] | [
"Will",
"return",
"the",
"zone",
"id",
"for",
"an",
"existing",
"instance",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/acs.py#L32-L39 | [
"def",
"_get_zone_id",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"service",
".",
"exists",
"(",
")",
":",
"logging",
".",
"warning",
"(",
"\"Service does not yet exist.\"",
")",
"return",
"self",
".",
"service",
".",
"settings",
".",
"data",
"[",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.create | Create an instance of the Access Control Service with the typical
starting settings. | predix/admin/acs.py | def create(self):
"""
Create an instance of the Access Control Service with the typical
starting settings.
"""
self.service.create()
# Set environment variables for immediate use
predix.config.set_env_value(self.use_class, 'uri', self._get_uri())
predix.c... | def create(self):
"""
Create an instance of the Access Control Service with the typical
starting settings.
"""
self.service.create()
# Set environment variables for immediate use
predix.config.set_env_value(self.use_class, 'uri', self._get_uri())
predix.c... | [
"Create",
"an",
"instance",
"of",
"the",
"Access",
"Control",
"Service",
"with",
"the",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/acs.py#L47-L57 | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"service",
".",
"create",
"(",
")",
"# Set environment variables for immediate use",
"predix",
".",
"config",
".",
"set_env_value",
"(",
"self",
".",
"use_class",
",",
"'uri'",
",",
"self",
".",
"_get_uri",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.grant_client | Grant the given client id all the scopes and authorities
needed to work with the access control service. | predix/admin/acs.py | def grant_client(self, client_id):
"""
Grant the given client id all the scopes and authorities
needed to work with the access control service.
"""
zone = self.service.settings.data['zone']['oauth-scope']
scopes = ['openid', zone,
'acs.policies.read', '... | def grant_client(self, client_id):
"""
Grant the given client id all the scopes and authorities
needed to work with the access control service.
"""
zone = self.service.settings.data['zone']['oauth-scope']
scopes = ['openid', zone,
'acs.policies.read', '... | [
"Grant",
"the",
"given",
"client",
"id",
"all",
"the",
"scopes",
"and",
"authorities",
"needed",
"to",
"work",
"with",
"the",
"access",
"control",
"service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/acs.py#L59-L77 | [
"def",
"grant_client",
"(",
"self",
",",
"client_id",
")",
":",
"zone",
"=",
"self",
".",
"service",
".",
"settings",
".",
"data",
"[",
"'zone'",
"]",
"[",
"'oauth-scope'",
"]",
"scopes",
"=",
"[",
"'openid'",
",",
"zone",
",",
"'acs.policies.read'",
","... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/acs.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/acs.py#L79-L98 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variables",
"uri",
"=",
"predix",
".",
"config",
".",
"get... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | API.get | Generic GET with headers | predix/admin/cf/api.py | def get(self, path):
"""
Generic GET with headers
"""
uri = self.config.get_target() + path
headers = self._get_headers()
logging.debug("URI=GET " + str(uri))
logging.debug("HEADERS=" + str(headers))
response = self.session.get(uri, headers=headers)
... | def get(self, path):
"""
Generic GET with headers
"""
uri = self.config.get_target() + path
headers = self._get_headers()
logging.debug("URI=GET " + str(uri))
logging.debug("HEADERS=" + str(headers))
response = self.session.get(uri, headers=headers)
... | [
"Generic",
"GET",
"with",
"headers"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/api.py#L50-L66 | [
"def",
"get",
"(",
"self",
",",
"path",
")",
":",
"uri",
"=",
"self",
".",
"config",
".",
"get_target",
"(",
")",
"+",
"path",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
"logging",
".",
"debug",
"(",
"\"URI=GET \"",
"+",
"str",
"(",
"ur... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | API.post | Generic POST with headers | predix/admin/cf/api.py | def post(self, path, data):
"""
Generic POST with headers
"""
uri = self.config.get_target() + path
headers = self._post_headers()
logging.debug("URI=POST " + str(uri))
logging.debug("HEADERS=" + str(headers))
logging.debug("BODY=" + str(data))
r... | def post(self, path, data):
"""
Generic POST with headers
"""
uri = self.config.get_target() + path
headers = self._post_headers()
logging.debug("URI=POST " + str(uri))
logging.debug("HEADERS=" + str(headers))
logging.debug("BODY=" + str(data))
r... | [
"Generic",
"POST",
"with",
"headers"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/api.py#L68-L88 | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"data",
")",
":",
"uri",
"=",
"self",
".",
"config",
".",
"get_target",
"(",
")",
"+",
"path",
"headers",
"=",
"self",
".",
"_post_headers",
"(",
")",
"logging",
".",
"debug",
"(",
"\"URI=POST \"",
"+",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | API.delete | Generic DELETE with headers | predix/admin/cf/api.py | def delete(self, path, data=None, params=None):
"""
Generic DELETE with headers
"""
uri = self.config.get_target() + path
headers = {
'Authorization': self.config.get_access_token()
}
logging.debug("URI=DELETE " + str(uri))
logging.debug("... | def delete(self, path, data=None, params=None):
"""
Generic DELETE with headers
"""
uri = self.config.get_target() + path
headers = {
'Authorization': self.config.get_access_token()
}
logging.debug("URI=DELETE " + str(uri))
logging.debug("... | [
"Generic",
"DELETE",
"with",
"headers"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/api.py#L113-L133 | [
"def",
"delete",
"(",
"self",
",",
"path",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"uri",
"=",
"self",
".",
"config",
".",
"get_target",
"(",
")",
"+",
"path",
"headers",
"=",
"{",
"'Authorization'",
":",
"self",
".",
"confi... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Org.get_orgs | Returns a flat list of the names for the organizations
user belongs. | predix/admin/cf/orgs.py | def get_orgs(self):
"""
Returns a flat list of the names for the organizations
user belongs.
"""
orgs = []
for resource in self._get_orgs()['resources']:
orgs.append(resource['entity']['name'])
return orgs | def get_orgs(self):
"""
Returns a flat list of the names for the organizations
user belongs.
"""
orgs = []
for resource in self._get_orgs()['resources']:
orgs.append(resource['entity']['name'])
return orgs | [
"Returns",
"a",
"flat",
"list",
"of",
"the",
"names",
"for",
"the",
"organizations",
"user",
"belongs",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/orgs.py#L30-L39 | [
"def",
"get_orgs",
"(",
"self",
")",
":",
"orgs",
"=",
"[",
"]",
"for",
"resource",
"in",
"self",
".",
"_get_orgs",
"(",
")",
"[",
"'resources'",
"]",
":",
"orgs",
".",
"append",
"(",
"resource",
"[",
"'entity'",
"]",
"[",
"'name'",
"]",
")",
"retu... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Org.get_apps | Returns a flat list of the names for the apps in
the organization. | predix/admin/cf/orgs.py | def get_apps(self):
"""
Returns a flat list of the names for the apps in
the organization.
"""
apps = []
for resource in self._get_apps()['resources']:
apps.append(resource['entity']['name'])
return apps | def get_apps(self):
"""
Returns a flat list of the names for the apps in
the organization.
"""
apps = []
for resource in self._get_apps()['resources']:
apps.append(resource['entity']['name'])
return apps | [
"Returns",
"a",
"flat",
"list",
"of",
"the",
"names",
"for",
"the",
"apps",
"in",
"the",
"organization",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/orgs.py#L47-L56 | [
"def",
"get_apps",
"(",
"self",
")",
":",
"apps",
"=",
"[",
"]",
"for",
"resource",
"in",
"self",
".",
"_get_apps",
"(",
")",
"[",
"'resources'",
"]",
":",
"apps",
".",
"append",
"(",
"resource",
"[",
"'entity'",
"]",
"[",
"'name'",
"]",
")",
"retu... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Org.add_user | Calls CF's associate user with org. Valid roles include `user`, `auditor`,
`manager`,`billing_manager` | predix/admin/cf/orgs.py | def add_user(self, user_name, role='user'):
"""
Calls CF's associate user with org. Valid roles include `user`, `auditor`,
`manager`,`billing_manager`
"""
role_uri = self._get_role_uri(role=role)
return self.api.put(path=role_uri, data={'username': user_name}) | def add_user(self, user_name, role='user'):
"""
Calls CF's associate user with org. Valid roles include `user`, `auditor`,
`manager`,`billing_manager`
"""
role_uri = self._get_role_uri(role=role)
return self.api.put(path=role_uri, data={'username': user_name}) | [
"Calls",
"CF",
"s",
"associate",
"user",
"with",
"org",
".",
"Valid",
"roles",
"include",
"user",
"auditor",
"manager",
"billing_manager"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/orgs.py#L68-L74 | [
"def",
"add_user",
"(",
"self",
",",
"user_name",
",",
"role",
"=",
"'user'",
")",
":",
"role_uri",
"=",
"self",
".",
"_get_role_uri",
"(",
"role",
"=",
"role",
")",
"return",
"self",
".",
"api",
".",
"put",
"(",
"path",
"=",
"role_uri",
",",
"data",... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Org.remove_user | Calls CF's remove user with org | predix/admin/cf/orgs.py | def remove_user(self, user_name, role):
"""
Calls CF's remove user with org
"""
role_uri = self._get_role_uri(role=role)
return self.api.delete(path=role_uri, data={'username': user_name}) | def remove_user(self, user_name, role):
"""
Calls CF's remove user with org
"""
role_uri = self._get_role_uri(role=role)
return self.api.delete(path=role_uri, data={'username': user_name}) | [
"Calls",
"CF",
"s",
"remove",
"user",
"with",
"org"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/orgs.py#L84-L89 | [
"def",
"remove_user",
"(",
"self",
",",
"user_name",
",",
"role",
")",
":",
"role_uri",
"=",
"self",
".",
"_get_role_uri",
"(",
"role",
"=",
"role",
")",
"return",
"self",
".",
"api",
".",
"delete",
"(",
"path",
"=",
"role_uri",
",",
"data",
"=",
"{"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher.add_message | add messages to the rx_queue
:param id: str message Id
:param body: str the message body
:param tags: dict[string->string] tags to be associated with the message
:return: self | predix/data/eventhub/publisher.py | def add_message(self, id, body, tags=False):
"""
add messages to the rx_queue
:param id: str message Id
:param body: str the message body
:param tags: dict[string->string] tags to be associated with the message
:return: self
"""
if not tags:
ta... | def add_message(self, id, body, tags=False):
"""
add messages to the rx_queue
:param id: str message Id
:param body: str the message body
:param tags: dict[string->string] tags to be associated with the message
:return: self
"""
if not tags:
ta... | [
"add",
"messages",
"to",
"the",
"rx_queue",
":",
"param",
"id",
":",
"str",
"message",
"Id",
":",
"param",
"body",
":",
"str",
"the",
"message",
"body",
":",
"param",
"tags",
":",
"dict",
"[",
"string",
"-",
">",
"string",
"]",
"tags",
"to",
"be",
... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L171-L187 | [
"def",
"add_message",
"(",
"self",
",",
"id",
",",
"body",
",",
"tags",
"=",
"False",
")",
":",
"if",
"not",
"tags",
":",
"tags",
"=",
"{",
"}",
"try",
":",
"self",
".",
"_tx_queue_lock",
".",
"acquire",
"(",
")",
"self",
".",
"_tx_queue",
".",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher.publish_queue | Publish all messages that have been added to the queue for configured protocol
:return: None | predix/data/eventhub/publisher.py | def publish_queue(self):
"""
Publish all messages that have been added to the queue for configured protocol
:return: None
"""
self.last_send_time = time.time()
try:
self._tx_queue_lock.acquire()
start_length = len(self._rx_queue)
publis... | def publish_queue(self):
"""
Publish all messages that have been added to the queue for configured protocol
:return: None
"""
self.last_send_time = time.time()
try:
self._tx_queue_lock.acquire()
start_length = len(self._rx_queue)
publis... | [
"Publish",
"all",
"messages",
"that",
"have",
"been",
"added",
"to",
"the",
"queue",
"for",
"configured",
"protocol",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L189-L212 | [
"def",
"publish_queue",
"(",
"self",
")",
":",
"self",
".",
"last_send_time",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"self",
".",
"_tx_queue_lock",
".",
"acquire",
"(",
")",
"start_length",
"=",
"len",
"(",
"self",
".",
"_rx_queue",
")",
"publ... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher.ack_generator | generator for acks to yield messages to the user in a async configuration
:return: messages as they come in | predix/data/eventhub/publisher.py | def ack_generator(self):
"""
generator for acks to yield messages to the user in a async configuration
:return: messages as they come in
"""
if self.config.is_sync():
logging.warning('cant use generator on a sync publisher')
return
while self._run_... | def ack_generator(self):
"""
generator for acks to yield messages to the user in a async configuration
:return: messages as they come in
"""
if self.config.is_sync():
logging.warning('cant use generator on a sync publisher')
return
while self._run_... | [
"generator",
"for",
"acks",
"to",
"yield",
"messages",
"to",
"the",
"user",
"in",
"a",
"async",
"configuration",
":",
"return",
":",
"messages",
"as",
"they",
"come",
"in"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L214-L226 | [
"def",
"ack_generator",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
".",
"is_sync",
"(",
")",
":",
"logging",
".",
"warning",
"(",
"'cant use generator on a sync publisher'",
")",
"return",
"while",
"self",
".",
"_run_ack_generator",
":",
"while",
"len... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._auto_send | auto send blocking function, when the interval or the message size has been reached, publish
:return: | predix/data/eventhub/publisher.py | def _auto_send(self):
"""
auto send blocking function, when the interval or the message size has been reached, publish
:return:
"""
while True:
if time.time() - self.last_send_time > self.config.async_auto_send_interval_millis or \
len(self... | def _auto_send(self):
"""
auto send blocking function, when the interval or the message size has been reached, publish
:return:
"""
while True:
if time.time() - self.last_send_time > self.config.async_auto_send_interval_millis or \
len(self... | [
"auto",
"send",
"blocking",
"function",
"when",
"the",
"interval",
"or",
"the",
"message",
"size",
"has",
"been",
"reached",
"publish",
":",
"return",
":"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L234-L242 | [
"def",
"_auto_send",
"(",
"self",
")",
":",
"while",
"True",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"last_send_time",
">",
"self",
".",
"config",
".",
"async_auto_send_interval_millis",
"or",
"len",
"(",
"self",
".",
"_tx_queue",
")"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._generate_publish_headers | generate the headers for the connection to event hub service based on the provided config
:return: {} headers | predix/data/eventhub/publisher.py | def _generate_publish_headers(self):
"""
generate the headers for the connection to event hub service based on the provided config
:return: {} headers
"""
headers = {
'predix-zone-id': self.eventhub_client.zone_id
}
token = self.eventhub_client.service... | def _generate_publish_headers(self):
"""
generate the headers for the connection to event hub service based on the provided config
:return: {} headers
"""
headers = {
'predix-zone-id': self.eventhub_client.zone_id
}
token = self.eventhub_client.service... | [
"generate",
"the",
"headers",
"for",
"the",
"connection",
"to",
"event",
"hub",
"service",
"based",
"on",
"the",
"provided",
"config",
":",
"return",
":",
"{}",
"headers"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L244-L271 | [
"def",
"_generate_publish_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'predix-zone-id'",
":",
"self",
".",
"eventhub_client",
".",
"zone_id",
"}",
"token",
"=",
"self",
".",
"eventhub_client",
".",
"service",
".",
"_get_bearer_token",
"(",
")",
"if"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._publisher_callback | publisher callback that grpc and web socket can pass messages to
address the received message onto the queue
:param publish_ack: EventHub_pb2.Ack the ack received from either wss or grpc
:return: None | predix/data/eventhub/publisher.py | def _publisher_callback(self, publish_ack):
"""
publisher callback that grpc and web socket can pass messages to
address the received message onto the queue
:param publish_ack: EventHub_pb2.Ack the ack received from either wss or grpc
:return: None
"""
logging.deb... | def _publisher_callback(self, publish_ack):
"""
publisher callback that grpc and web socket can pass messages to
address the received message onto the queue
:param publish_ack: EventHub_pb2.Ack the ack received from either wss or grpc
:return: None
"""
logging.deb... | [
"publisher",
"callback",
"that",
"grpc",
"and",
"web",
"socket",
"can",
"pass",
"messages",
"to",
"address",
"the",
"received",
"message",
"onto",
"the",
"queue",
":",
"param",
"publish_ack",
":",
"EventHub_pb2",
".",
"Ack",
"the",
"ack",
"received",
"from",
... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L273-L281 | [
"def",
"_publisher_callback",
"(",
"self",
",",
"publish_ack",
")",
":",
"logging",
".",
"debug",
"(",
"\"ack received: \"",
"+",
"str",
"(",
"publish_ack",
")",
".",
"replace",
"(",
"'\\n'",
",",
"' '",
")",
")",
"self",
".",
"_rx_queue",
".",
"append",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._init_grpc_publisher | initialize the grpc publisher, builds the stub and then starts the grpc manager
:return: None | predix/data/eventhub/publisher.py | def _init_grpc_publisher(self):
"""
initialize the grpc publisher, builds the stub and then starts the grpc manager
:return: None
"""
self._stub = EventHub_pb2_grpc.PublisherStub(channel=self._channel)
self.grpc_manager = Eventhub.GrpcManager(stub_call=self._stub.send,
... | def _init_grpc_publisher(self):
"""
initialize the grpc publisher, builds the stub and then starts the grpc manager
:return: None
"""
self._stub = EventHub_pb2_grpc.PublisherStub(channel=self._channel)
self.grpc_manager = Eventhub.GrpcManager(stub_call=self._stub.send,
... | [
"initialize",
"the",
"grpc",
"publisher",
"builds",
"the",
"stub",
"and",
"then",
"starts",
"the",
"grpc",
"manager",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L289-L297 | [
"def",
"_init_grpc_publisher",
"(",
"self",
")",
":",
"self",
".",
"_stub",
"=",
"EventHub_pb2_grpc",
".",
"PublisherStub",
"(",
"channel",
"=",
"self",
".",
"_channel",
")",
"self",
".",
"grpc_manager",
"=",
"Eventhub",
".",
"GrpcManager",
"(",
"stub_call",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._publish_queue_grpc | send the messages in the tx queue to the GRPC manager
:return: None | predix/data/eventhub/publisher.py | def _publish_queue_grpc(self):
"""
send the messages in the tx queue to the GRPC manager
:return: None
"""
messages = EventHub_pb2.Messages(msg=self._tx_queue)
publish_request = EventHub_pb2.PublishRequest(messages=messages)
self.grpc_manager.send_message(publish_... | def _publish_queue_grpc(self):
"""
send the messages in the tx queue to the GRPC manager
:return: None
"""
messages = EventHub_pb2.Messages(msg=self._tx_queue)
publish_request = EventHub_pb2.PublishRequest(messages=messages)
self.grpc_manager.send_message(publish_... | [
"send",
"the",
"messages",
"in",
"the",
"tx",
"queue",
"to",
"the",
"GRPC",
"manager",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L299-L306 | [
"def",
"_publish_queue_grpc",
"(",
"self",
")",
":",
"messages",
"=",
"EventHub_pb2",
".",
"Messages",
"(",
"msg",
"=",
"self",
".",
"_tx_queue",
")",
"publish_request",
"=",
"EventHub_pb2",
".",
"PublishRequest",
"(",
"messages",
"=",
"messages",
")",
"self",... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._publish_queue_wss | send the messages down the web socket connection as a json object
:return: None | predix/data/eventhub/publisher.py | def _publish_queue_wss(self):
"""
send the messages down the web socket connection as a json object
:return: None
"""
msg = []
for m in self._tx_queue:
msg.append({'id': m.id, 'body': m.body, 'zone_id': m.zone_id})
self._ws.send(json.dumps(msg), opcod... | def _publish_queue_wss(self):
"""
send the messages down the web socket connection as a json object
:return: None
"""
msg = []
for m in self._tx_queue:
msg.append({'id': m.id, 'body': m.body, 'zone_id': m.zone_id})
self._ws.send(json.dumps(msg), opcod... | [
"send",
"the",
"messages",
"down",
"the",
"web",
"socket",
"connection",
"as",
"a",
"json",
"object",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L314-L323 | [
"def",
"_publish_queue_wss",
"(",
"self",
")",
":",
"msg",
"=",
"[",
"]",
"for",
"m",
"in",
"self",
".",
"_tx_queue",
":",
"msg",
".",
"append",
"(",
"{",
"'id'",
":",
"m",
".",
"id",
",",
"'body'",
":",
"m",
".",
"body",
",",
"'zone_id'",
":",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._init_publisher_ws | Create a new web socket connection with proper headers. | predix/data/eventhub/publisher.py | def _init_publisher_ws(self):
"""
Create a new web socket connection with proper headers.
"""
logging.debug("Initializing new web socket connection.")
url = ('wss://%s/v1/stream/messages/' % self.eventhub_client.host)
headers = self._generate_publish_headers()
... | def _init_publisher_ws(self):
"""
Create a new web socket connection with proper headers.
"""
logging.debug("Initializing new web socket connection.")
url = ('wss://%s/v1/stream/messages/' % self.eventhub_client.host)
headers = self._generate_publish_headers()
... | [
"Create",
"a",
"new",
"web",
"socket",
"connection",
"with",
"proper",
"headers",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L325-L347 | [
"def",
"_init_publisher_ws",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"Initializing new web socket connection.\"",
")",
"url",
"=",
"(",
"'wss://%s/v1/stream/messages/'",
"%",
"self",
".",
"eventhub_client",
".",
"host",
")",
"headers",
"=",
"self",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Publisher._on_ws_message | on_message callback of websocket class, load the message into a dict and then
update an Ack Object with the results
:param ws: web socket connection that the message was received on
:param message: web socket message in text form
:return: None | predix/data/eventhub/publisher.py | def _on_ws_message(self, ws, message):
"""
on_message callback of websocket class, load the message into a dict and then
update an Ack Object with the results
:param ws: web socket connection that the message was received on
:param message: web socket message in text form
... | def _on_ws_message(self, ws, message):
"""
on_message callback of websocket class, load the message into a dict and then
update an Ack Object with the results
:param ws: web socket connection that the message was received on
:param message: web socket message in text form
... | [
"on_message",
"callback",
"of",
"websocket",
"class",
"load",
"the",
"message",
"into",
"a",
"dict",
"and",
"then",
"update",
"an",
"Ack",
"Object",
"with",
"the",
"results",
":",
"param",
"ws",
":",
"web",
"socket",
"connection",
"that",
"the",
"message",
... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L349-L363 | [
"def",
"_on_ws_message",
"(",
"self",
",",
"ws",
",",
"message",
")",
":",
"logging",
".",
"debug",
"(",
"message",
")",
"json_list",
"=",
"json",
".",
"loads",
"(",
"message",
")",
"for",
"rx_ack",
"in",
"json_list",
":",
"ack",
"=",
"EventHub_pb2",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ParkingPlanning.create | Create an instance of the Parking Planning Service with the
typical starting settings. | predix/admin/ie/parking.py | def create(self):
"""
Create an instance of the Parking Planning Service with the
typical starting settings.
"""
self.service.create()
os.environ[self.__module__ + '.uri'] = self.service.settings.data['url']
os.environ[self.__module__ + '.zone_id'] = self.get_pred... | def create(self):
"""
Create an instance of the Parking Planning Service with the
typical starting settings.
"""
self.service.create()
os.environ[self.__module__ + '.uri'] = self.service.settings.data['url']
os.environ[self.__module__ + '.zone_id'] = self.get_pred... | [
"Create",
"an",
"instance",
"of",
"the",
"Parking",
"Planning",
"Service",
"with",
"the",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/ie/parking.py#L24-L31 | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"service",
".",
"create",
"(",
")",
"os",
".",
"environ",
"[",
"self",
".",
"__module__",
"+",
"'.uri'",
"]",
"=",
"self",
".",
"service",
".",
"settings",
".",
"data",
"[",
"'url'",
"]",
"os",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ParkingPlanning.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/ie/parking.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/ie/parking.py#L60-L78 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variables",
"manifest",
".",
"add_env_var",
"(",
"self",
"."... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.read_manifest | Read an existing manifest. | predix/app.py | def read_manifest(self, encrypted=None):
"""
Read an existing manifest.
"""
with open(self.manifest_path, 'r') as input_file:
self.manifest = yaml.safe_load(input_file)
if 'env' not in self.manifest:
self.manifest['env'] = {}
if 'servic... | def read_manifest(self, encrypted=None):
"""
Read an existing manifest.
"""
with open(self.manifest_path, 'r') as input_file:
self.manifest = yaml.safe_load(input_file)
if 'env' not in self.manifest:
self.manifest['env'] = {}
if 'servic... | [
"Read",
"an",
"existing",
"manifest",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L69-L96 | [
"def",
"read_manifest",
"(",
"self",
",",
"encrypted",
"=",
"None",
")",
":",
"with",
"open",
"(",
"self",
".",
"manifest_path",
",",
"'r'",
")",
"as",
"input_file",
":",
"self",
".",
"manifest",
"=",
"yaml",
".",
"safe_load",
"(",
"input_file",
")",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.create_manifest | Create a new manifest and write it to
disk. | predix/app.py | def create_manifest(self):
"""
Create a new manifest and write it to
disk.
"""
self.manifest = {}
self.manifest['applications'] = [{'name': self.app_name}]
self.manifest['services'] = []
self.manifest['env'] = {
'PREDIXPY_VERSION': str(pred... | def create_manifest(self):
"""
Create a new manifest and write it to
disk.
"""
self.manifest = {}
self.manifest['applications'] = [{'name': self.app_name}]
self.manifest['services'] = []
self.manifest['env'] = {
'PREDIXPY_VERSION': str(pred... | [
"Create",
"a",
"new",
"manifest",
"and",
"write",
"it",
"to",
"disk",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L98-L110 | [
"def",
"create_manifest",
"(",
"self",
")",
":",
"self",
".",
"manifest",
"=",
"{",
"}",
"self",
".",
"manifest",
"[",
"'applications'",
"]",
"=",
"[",
"{",
"'name'",
":",
"self",
".",
"app_name",
"}",
"]",
"self",
".",
"manifest",
"[",
"'services'",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest._get_encrypted_manifest | Returns contents of the manifest where environment variables
that are secret will be encrypted without modifying the existing
state in memory which will remain unencrypted. | predix/app.py | def _get_encrypted_manifest(self):
"""
Returns contents of the manifest where environment variables
that are secret will be encrypted without modifying the existing
state in memory which will remain unencrypted.
"""
key = predix.config.get_crypt_key(self.manifest_key)
... | def _get_encrypted_manifest(self):
"""
Returns contents of the manifest where environment variables
that are secret will be encrypted without modifying the existing
state in memory which will remain unencrypted.
"""
key = predix.config.get_crypt_key(self.manifest_key)
... | [
"Returns",
"contents",
"of",
"the",
"manifest",
"where",
"environment",
"variables",
"that",
"are",
"secret",
"will",
"be",
"encrypted",
"without",
"modifying",
"the",
"existing",
"state",
"in",
"memory",
"which",
"will",
"remain",
"unencrypted",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L112-L126 | [
"def",
"_get_encrypted_manifest",
"(",
"self",
")",
":",
"key",
"=",
"predix",
".",
"config",
".",
"get_crypt_key",
"(",
"self",
".",
"manifest_key",
")",
"f",
"=",
"Fernet",
"(",
"key",
")",
"manifest",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.write_manifest | Write manifest to disk.
:param manifest_path: write to a different location
:param encrypted: write with env data encrypted | predix/app.py | def write_manifest(self, manifest_path=None, encrypted=None):
"""
Write manifest to disk.
:param manifest_path: write to a different location
:param encrypted: write with env data encrypted
"""
manifest_path = manifest_path or self.manifest_path
self.manifest['e... | def write_manifest(self, manifest_path=None, encrypted=None):
"""
Write manifest to disk.
:param manifest_path: write to a different location
:param encrypted: write with env data encrypted
"""
manifest_path = manifest_path or self.manifest_path
self.manifest['e... | [
"Write",
"manifest",
"to",
"disk",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L128-L150 | [
"def",
"write_manifest",
"(",
"self",
",",
"manifest_path",
"=",
"None",
",",
"encrypted",
"=",
"None",
")",
":",
"manifest_path",
"=",
"manifest_path",
"or",
"self",
".",
"manifest_path",
"self",
".",
"manifest",
"[",
"'env'",
"]",
"[",
"'PREDIXPY_VERSION'",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.add_env_var | Add the given key / value as another environment
variable. | predix/app.py | def add_env_var(self, key, value):
"""
Add the given key / value as another environment
variable.
"""
self.manifest['env'][key] = value
os.environ[key] = str(value) | def add_env_var(self, key, value):
"""
Add the given key / value as another environment
variable.
"""
self.manifest['env'][key] = value
os.environ[key] = str(value) | [
"Add",
"the",
"given",
"key",
"/",
"value",
"as",
"another",
"environment",
"variable",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L152-L158 | [
"def",
"add_env_var",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"manifest",
"[",
"'env'",
"]",
"[",
"key",
"]",
"=",
"value",
"os",
".",
"environ",
"[",
"key",
"]",
"=",
"str",
"(",
"value",
")"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.add_service | Add the given service to the manifest. | predix/app.py | def add_service(self, service_name):
"""
Add the given service to the manifest.
"""
if service_name not in self.manifest['services']:
self.manifest['services'].append(service_name) | def add_service(self, service_name):
"""
Add the given service to the manifest.
"""
if service_name not in self.manifest['services']:
self.manifest['services'].append(service_name) | [
"Add",
"the",
"given",
"service",
"to",
"the",
"manifest",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L160-L165 | [
"def",
"add_service",
"(",
"self",
",",
"service_name",
")",
":",
"if",
"service_name",
"not",
"in",
"self",
".",
"manifest",
"[",
"'services'",
"]",
":",
"self",
".",
"manifest",
"[",
"'services'",
"]",
".",
"append",
"(",
"service_name",
")"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.set_os_environ | Will load any environment variables found in the
manifest file into the current process for use
by applications.
When apps run in cloud foundry this would happen
automatically. | predix/app.py | def set_os_environ(self):
"""
Will load any environment variables found in the
manifest file into the current process for use
by applications.
When apps run in cloud foundry this would happen
automatically.
"""
for key in self.manifest['env'].keys():
... | def set_os_environ(self):
"""
Will load any environment variables found in the
manifest file into the current process for use
by applications.
When apps run in cloud foundry this would happen
automatically.
"""
for key in self.manifest['env'].keys():
... | [
"Will",
"load",
"any",
"environment",
"variables",
"found",
"in",
"the",
"manifest",
"file",
"into",
"the",
"current",
"process",
"for",
"use",
"by",
"applications",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L167-L177 | [
"def",
"set_os_environ",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"manifest",
"[",
"'env'",
"]",
".",
"keys",
"(",
")",
":",
"os",
".",
"environ",
"[",
"key",
"]",
"=",
"str",
"(",
"self",
".",
"manifest",
"[",
"'env'",
"]",
"[",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_client_id | Return the client id that should have all the
needed scopes and authorities for the services
in this manifest. | predix/app.py | def get_client_id(self):
"""
Return the client id that should have all the
needed scopes and authorities for the services
in this manifest.
"""
self._client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id')
return self._client_id | def get_client_id(self):
"""
Return the client id that should have all the
needed scopes and authorities for the services
in this manifest.
"""
self._client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id')
return self._client_id | [
"Return",
"the",
"client",
"id",
"that",
"should",
"have",
"all",
"the",
"needed",
"scopes",
"and",
"authorities",
"for",
"the",
"services",
"in",
"this",
"manifest",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L179-L186 | [
"def",
"get_client_id",
"(",
"self",
")",
":",
"self",
".",
"_client_id",
"=",
"predix",
".",
"config",
".",
"get_env_value",
"(",
"predix",
".",
"app",
".",
"Manifest",
",",
"'client_id'",
")",
"return",
"self",
".",
"_client_id"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_client_secret | Return the client secret that should correspond with
the client id. | predix/app.py | def get_client_secret(self):
"""
Return the client secret that should correspond with
the client id.
"""
self._client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret')
return self._client_secret | def get_client_secret(self):
"""
Return the client secret that should correspond with
the client id.
"""
self._client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret')
return self._client_secret | [
"Return",
"the",
"client",
"secret",
"that",
"should",
"correspond",
"with",
"the",
"client",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L188-L194 | [
"def",
"get_client_secret",
"(",
"self",
")",
":",
"self",
".",
"_client_secret",
"=",
"predix",
".",
"config",
".",
"get_env_value",
"(",
"predix",
".",
"app",
".",
"Manifest",
",",
"'client_secret'",
")",
"return",
"self",
".",
"_client_secret"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_timeseries | Returns an instance of the Time Series Service. | predix/app.py | def get_timeseries(self, *args, **kwargs):
"""
Returns an instance of the Time Series Service.
"""
import predix.data.timeseries
ts = predix.data.timeseries.TimeSeries(*args, **kwargs)
return ts | def get_timeseries(self, *args, **kwargs):
"""
Returns an instance of the Time Series Service.
"""
import predix.data.timeseries
ts = predix.data.timeseries.TimeSeries(*args, **kwargs)
return ts | [
"Returns",
"an",
"instance",
"of",
"the",
"Time",
"Series",
"Service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L196-L202 | [
"def",
"get_timeseries",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"predix",
".",
"data",
".",
"timeseries",
"ts",
"=",
"predix",
".",
"data",
".",
"timeseries",
".",
"TimeSeries",
"(",
"*",
"args",
",",
"*",
"*",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_asset | Returns an instance of the Asset Service. | predix/app.py | def get_asset(self):
"""
Returns an instance of the Asset Service.
"""
import predix.data.asset
asset = predix.data.asset.Asset()
return asset | def get_asset(self):
"""
Returns an instance of the Asset Service.
"""
import predix.data.asset
asset = predix.data.asset.Asset()
return asset | [
"Returns",
"an",
"instance",
"of",
"the",
"Asset",
"Service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L204-L210 | [
"def",
"get_asset",
"(",
"self",
")",
":",
"import",
"predix",
".",
"data",
".",
"asset",
"asset",
"=",
"predix",
".",
"data",
".",
"asset",
".",
"Asset",
"(",
")",
"return",
"asset"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_uaa | Returns an insstance of the UAA Service. | predix/app.py | def get_uaa(self):
"""
Returns an insstance of the UAA Service.
"""
import predix.security.uaa
uaa = predix.security.uaa.UserAccountAuthentication()
return uaa | def get_uaa(self):
"""
Returns an insstance of the UAA Service.
"""
import predix.security.uaa
uaa = predix.security.uaa.UserAccountAuthentication()
return uaa | [
"Returns",
"an",
"insstance",
"of",
"the",
"UAA",
"Service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L212-L218 | [
"def",
"get_uaa",
"(",
"self",
")",
":",
"import",
"predix",
".",
"security",
".",
"uaa",
"uaa",
"=",
"predix",
".",
"security",
".",
"uaa",
".",
"UserAccountAuthentication",
"(",
")",
"return",
"uaa"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_acs | Returns an instance of the Asset Control Service. | predix/app.py | def get_acs(self):
"""
Returns an instance of the Asset Control Service.
"""
import predix.security.acs
acs = predix.security.acs.AccessControl()
return acs | def get_acs(self):
"""
Returns an instance of the Asset Control Service.
"""
import predix.security.acs
acs = predix.security.acs.AccessControl()
return acs | [
"Returns",
"an",
"instance",
"of",
"the",
"Asset",
"Control",
"Service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L220-L226 | [
"def",
"get_acs",
"(",
"self",
")",
":",
"import",
"predix",
".",
"security",
".",
"acs",
"acs",
"=",
"predix",
".",
"security",
".",
"acs",
".",
"AccessControl",
"(",
")",
"return",
"acs"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Manifest.get_weather | Returns an instance of the Weather Service. | predix/app.py | def get_weather(self):
"""
Returns an instance of the Weather Service.
"""
import predix.data.weather
weather = predix.data.weather.WeatherForecast()
return weather | def get_weather(self):
"""
Returns an instance of the Weather Service.
"""
import predix.data.weather
weather = predix.data.weather.WeatherForecast()
return weather | [
"Returns",
"an",
"instance",
"of",
"the",
"Weather",
"Service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/app.py#L228-L234 | [
"def",
"get_weather",
"(",
"self",
")",
":",
"import",
"predix",
".",
"data",
".",
"weather",
"weather",
"=",
"predix",
".",
"data",
".",
"weather",
".",
"WeatherForecast",
"(",
")",
"return",
"weather"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.