nwo
stringlengths
6
76
sha
stringlengths
40
40
path
stringlengths
5
118
language
stringclasses
1 value
identifier
stringlengths
1
89
parameters
stringlengths
2
5.4k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
51.1k
docstring
stringlengths
1
17.6k
docstring_summary
stringlengths
0
7.02k
docstring_tokens
sequence
function
stringlengths
30
51.1k
function_tokens
sequence
url
stringlengths
85
218
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/types.py
python
ZDOHeader.is_reply
(self)
return bool(self._command_id & 0x8000)
Return True if this is a reply.
Return True if this is a reply.
[ "Return", "True", "if", "this", "is", "a", "reply", "." ]
def is_reply(self) -> bool: """Return True if this is a reply.""" return bool(self._command_id & 0x8000)
[ "def", "is_reply", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_command_id", "&", "0x8000", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/types.py#L709-L711
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/types.py
python
ZDOHeader.tsn
(self)
return self._tsn
Return transaction seq number.
Return transaction seq number.
[ "Return", "transaction", "seq", "number", "." ]
def tsn(self) -> t.uint8_t: """Return transaction seq number.""" return self._tsn
[ "def", "tsn", "(", "self", ")", "->", "t", ".", "uint8_t", ":", "return", "self", ".", "_tsn" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/types.py#L714-L716
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/types.py
python
ZDOHeader.tsn
(self, value: t.uint8_t)
Set TSN.
Set TSN.
[ "Set", "TSN", "." ]
def tsn(self, value: t.uint8_t) -> None: """Set TSN.""" self._tsn = t.uint8_t(value)
[ "def", "tsn", "(", "self", ",", "value", ":", "t", ".", "uint8_t", ")", "->", "None", ":", "self", ".", "_tsn", "=", "t", ".", "uint8_t", "(", "value", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/types.py#L719-L721
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/types.py
python
ZDOHeader.deserialize
( cls, command_id: t.uint16_t, data: bytes )
return cls(command_id, tsn), data
Deserialize data.
Deserialize data.
[ "Deserialize", "data", "." ]
def deserialize( cls, command_id: t.uint16_t, data: bytes ) -> typing.Tuple["ZDOHeader", bytes]: """Deserialize data.""" tsn, data = t.uint8_t.deserialize(data) return cls(command_id, tsn), data
[ "def", "deserialize", "(", "cls", ",", "command_id", ":", "t", ".", "uint16_t", ",", "data", ":", "bytes", ")", "->", "typing", ".", "Tuple", "[", "\"ZDOHeader\"", ",", "bytes", "]", ":", "tsn", ",", "data", "=", "t", ".", "uint8_t", ".", "deserialize", "(", "data", ")", "return", "cls", "(", "command_id", ",", "tsn", ")", ",", "data" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/types.py#L724-L729
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/types.py
python
ZDOHeader.serialize
(self)
return self.tsn.serialize()
Serialize header.
Serialize header.
[ "Serialize", "header", "." ]
def serialize(self) -> bytes: """Serialize header.""" return self.tsn.serialize()
[ "def", "serialize", "(", "self", ")", "->", "bytes", ":", "return", "self", ".", "tsn", ".", "serialize", "(", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/types.py#L731-L734
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/__init__.py
python
ZDO.handle_nwk_addr_req
( self, hdr: types.ZDOHeader, ieee: t.EUI64, request_type: int, start_index: int | None = None, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, )
Handle ZDO NWK Address request.
Handle ZDO NWK Address request.
[ "Handle", "ZDO", "NWK", "Address", "request", "." ]
def handle_nwk_addr_req( self, hdr: types.ZDOHeader, ieee: t.EUI64, request_type: int, start_index: int | None = None, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, ): """Handle ZDO NWK Address request.""" app = self._device.application if ieee == app.ieee: self.create_catching_task( self.NWK_addr_rsp(0, app.ieee, app.nwk, 0, 0, [], tsn=hdr.tsn) )
[ "def", "handle_nwk_addr_req", "(", "self", ",", "hdr", ":", "types", ".", "ZDOHeader", ",", "ieee", ":", "t", ".", "EUI64", ",", "request_type", ":", "int", ",", "start_index", ":", "int", "|", "None", "=", "None", ",", "dst_addressing", ":", "t", ".", "Addressing", ".", "Group", "|", "t", ".", "Addressing", ".", "IEEE", "|", "t", ".", "Addressing", ".", "NWK", "|", "None", "=", "None", ",", ")", ":", "app", "=", "self", ".", "_device", ".", "application", "if", "ieee", "==", "app", ".", "ieee", ":", "self", ".", "create_catching_task", "(", "self", ".", "NWK_addr_rsp", "(", "0", ",", "app", ".", "ieee", ",", "app", ".", "nwk", ",", "0", ",", "0", ",", "[", "]", ",", "tsn", "=", "hdr", ".", "tsn", ")", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/__init__.py#L85-L102
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/__init__.py
python
ZDO.handle_ieee_addr_req
( self, hdr: types.ZDOHeader, nwk: t.NWK, request_type: int, start_index: int | None = None, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, )
Handle ZDO IEEE Address request.
Handle ZDO IEEE Address request.
[ "Handle", "ZDO", "IEEE", "Address", "request", "." ]
def handle_ieee_addr_req( self, hdr: types.ZDOHeader, nwk: t.NWK, request_type: int, start_index: int | None = None, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, ): """Handle ZDO IEEE Address request.""" app = self._device.application if nwk in (0xFFFF, 0xFFFD, 0xFFFC, app.nwk): self.create_catching_task( self.IEEE_addr_rsp(0, app.ieee, app.nwk, 0, 0, [], tsn=hdr.tsn) )
[ "def", "handle_ieee_addr_req", "(", "self", ",", "hdr", ":", "types", ".", "ZDOHeader", ",", "nwk", ":", "t", ".", "NWK", ",", "request_type", ":", "int", ",", "start_index", ":", "int", "|", "None", "=", "None", ",", "dst_addressing", ":", "t", ".", "Addressing", ".", "Group", "|", "t", ".", "Addressing", ".", "IEEE", "|", "t", ".", "Addressing", ".", "NWK", "|", "None", "=", "None", ",", ")", ":", "app", "=", "self", ".", "_device", ".", "application", "if", "nwk", "in", "(", "0xFFFF", ",", "0xFFFD", ",", "0xFFFC", ",", "app", ".", "nwk", ")", ":", "self", ".", "create_catching_task", "(", "self", ".", "IEEE_addr_rsp", "(", "0", ",", "app", ".", "ieee", ",", "app", ".", "nwk", ",", "0", ",", "0", ",", "[", "]", ",", "tsn", "=", "hdr", ".", "tsn", ")", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/__init__.py#L104-L121
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/__init__.py
python
ZDO.handle_device_annce
( self, hdr: types.ZDOHeader, nwk: t.NWK, ieee: t.EUI64, capability: int, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, )
Handle ZDO device announcement request.
Handle ZDO device announcement request.
[ "Handle", "ZDO", "device", "announcement", "request", "." ]
def handle_device_annce( self, hdr: types.ZDOHeader, nwk: t.NWK, ieee: t.EUI64, capability: int, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, ): """Handle ZDO device announcement request.""" self.listener_event("device_announce", self._device)
[ "def", "handle_device_annce", "(", "self", ",", "hdr", ":", "types", ".", "ZDOHeader", ",", "nwk", ":", "t", ".", "NWK", ",", "ieee", ":", "t", ".", "EUI64", ",", "capability", ":", "int", ",", "dst_addressing", ":", "t", ".", "Addressing", ".", "Group", "|", "t", ".", "Addressing", ".", "IEEE", "|", "t", ".", "Addressing", ".", "NWK", "|", "None", "=", "None", ",", ")", ":", "self", ".", "listener_event", "(", "\"device_announce\"", ",", "self", ".", "_device", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/__init__.py#L123-L135
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/__init__.py
python
ZDO.handle_mgmt_permit_joining_req
( self, hdr: types.ZDOHeader, permit_duration: int, tc_significance: int, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, )
Handle ZDO permit joining request.
Handle ZDO permit joining request.
[ "Handle", "ZDO", "permit", "joining", "request", "." ]
def handle_mgmt_permit_joining_req( self, hdr: types.ZDOHeader, permit_duration: int, tc_significance: int, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, ): """Handle ZDO permit joining request.""" self.listener_event("permit_duration", permit_duration)
[ "def", "handle_mgmt_permit_joining_req", "(", "self", ",", "hdr", ":", "types", ".", "ZDOHeader", ",", "permit_duration", ":", "int", ",", "tc_significance", ":", "int", ",", "dst_addressing", ":", "t", ".", "Addressing", ".", "Group", "|", "t", ".", "Addressing", ".", "IEEE", "|", "t", ".", "Addressing", ".", "NWK", "|", "None", "=", "None", ",", ")", ":", "self", ".", "listener_event", "(", "\"permit_duration\"", ",", "permit_duration", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/__init__.py#L137-L149
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zdo/__init__.py
python
ZDO.handle_match_desc_req
( self, hdr: types.ZDOHeader, addr: t.NWK, profile: int, in_clusters: list, out_cluster: list, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, )
Handle ZDO Match_desc_req request.
Handle ZDO Match_desc_req request.
[ "Handle", "ZDO", "Match_desc_req", "request", "." ]
def handle_match_desc_req( self, hdr: types.ZDOHeader, addr: t.NWK, profile: int, in_clusters: list, out_cluster: list, dst_addressing: t.Addressing.Group | t.Addressing.IEEE | t.Addressing.NWK | None = None, ): """Handle ZDO Match_desc_req request.""" local_addr = self._device.application.nwk if profile != zigpy.profiles.zha.PROFILE_ID: self.create_catching_task( self.Match_Desc_rsp(0, local_addr, [], tsn=hdr.tsn) ) return self.create_catching_task( self.Match_Desc_rsp(0, local_addr, [t.uint8_t(1)], tsn=hdr.tsn) )
[ "def", "handle_match_desc_req", "(", "self", ",", "hdr", ":", "types", ".", "ZDOHeader", ",", "addr", ":", "t", ".", "NWK", ",", "profile", ":", "int", ",", "in_clusters", ":", "list", ",", "out_cluster", ":", "list", ",", "dst_addressing", ":", "t", ".", "Addressing", ".", "Group", "|", "t", ".", "Addressing", ".", "IEEE", "|", "t", ".", "Addressing", ".", "NWK", "|", "None", "=", "None", ",", ")", ":", "local_addr", "=", "self", ".", "_device", ".", "application", ".", "nwk", "if", "profile", "!=", "zigpy", ".", "profiles", ".", "zha", ".", "PROFILE_ID", ":", "self", ".", "create_catching_task", "(", "self", ".", "Match_Desc_rsp", "(", "0", ",", "local_addr", ",", "[", "]", ",", "tsn", "=", "hdr", ".", "tsn", ")", ")", "return", "self", ".", "create_catching_task", "(", "self", ".", "Match_Desc_rsp", "(", "0", ",", "local_addr", ",", "[", "t", ".", "uint8_t", "(", "1", ")", "]", ",", "tsn", "=", "hdr", ".", "tsn", ")", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zdo/__init__.py#L151-L174
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
DataTypes.pytype_to_datatype_id
(self, python_type)
return 0xFF
Return Zigbee Datatype ID for a give python type.
Return Zigbee Datatype ID for a give python type.
[ "Return", "Zigbee", "Datatype", "ID", "for", "a", "give", "python", "type", "." ]
def pytype_to_datatype_id(self, python_type) -> int: """Return Zigbee Datatype ID for a give python type.""" # We return the most specific parent class for cls in python_type.__mro__: if cls in self._idx_by_class: return self._idx_by_class[cls] return 0xFF
[ "def", "pytype_to_datatype_id", "(", "self", ",", "python_type", ")", "->", "int", ":", "# We return the most specific parent class", "for", "cls", "in", "python_type", ".", "__mro__", ":", "if", "cls", "in", "self", ".", "_idx_by_class", ":", "return", "self", ".", "_idx_by_class", "[", "cls", "]", "return", "0xFF" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L135-L143
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.disable_default_response
(self)
return bool(self.value & 0b10000)
Return True if default response is disabled.
Return True if default response is disabled.
[ "Return", "True", "if", "default", "response", "is", "disabled", "." ]
def disable_default_response(self) -> bool: """Return True if default response is disabled.""" return bool(self.value & 0b10000)
[ "def", "disable_default_response", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "value", "&", "0b10000", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L491-L493
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.disable_default_response
(self, value: bool)
Disable the default response.
Disable the default response.
[ "Disable", "the", "default", "response", "." ]
def disable_default_response(self, value: bool) -> None: """Disable the default response.""" if value: self.value |= 0b10000 return self.value &= 0b11101111
[ "def", "disable_default_response", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "if", "value", ":", "self", ".", "value", "|=", "0b10000", "return", "self", ".", "value", "&=", "0b11101111" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L496-L501
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.frame_type
(self)
return FrameType(self.value & 0b00000011)
Return frame type.
Return frame type.
[ "Return", "frame", "type", "." ]
def frame_type(self) -> FrameType: """Return frame type.""" return FrameType(self.value & 0b00000011)
[ "def", "frame_type", "(", "self", ")", "->", "FrameType", ":", "return", "FrameType", "(", "self", ".", "value", "&", "0b00000011", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L504-L506
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.frame_type
(self, value: FrameType)
Sets frame type to Global general command.
Sets frame type to Global general command.
[ "Sets", "frame", "type", "to", "Global", "general", "command", "." ]
def frame_type(self, value: FrameType) -> None: """Sets frame type to Global general command.""" self.value &= 0b11111100 self.value |= value
[ "def", "frame_type", "(", "self", ",", "value", ":", "FrameType", ")", "->", "None", ":", "self", ".", "value", "&=", "0b11111100", "self", ".", "value", "|=", "value" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L509-L512
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_cluster
(self)
return bool(self.frame_type == FrameType.CLUSTER_COMMAND)
Return True if command is a local cluster specific command.
Return True if command is a local cluster specific command.
[ "Return", "True", "if", "command", "is", "a", "local", "cluster", "specific", "command", "." ]
def is_cluster(self) -> bool: """Return True if command is a local cluster specific command.""" return bool(self.frame_type == FrameType.CLUSTER_COMMAND)
[ "def", "is_cluster", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "frame_type", "==", "FrameType", ".", "CLUSTER_COMMAND", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L515-L517
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_general
(self)
return bool(self.frame_type == FrameType.GLOBAL_COMMAND)
Return True if command is a global ZCL command.
Return True if command is a global ZCL command.
[ "Return", "True", "if", "command", "is", "a", "global", "ZCL", "command", "." ]
def is_general(self) -> bool: """Return True if command is a global ZCL command.""" return bool(self.frame_type == FrameType.GLOBAL_COMMAND)
[ "def", "is_general", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "frame_type", "==", "FrameType", ".", "GLOBAL_COMMAND", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L520-L522
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_manufacturer_specific
(self)
return bool(self.value & 0b100)
Return True if manufacturer code is present.
Return True if manufacturer code is present.
[ "Return", "True", "if", "manufacturer", "code", "is", "present", "." ]
def is_manufacturer_specific(self) -> bool: """Return True if manufacturer code is present.""" return bool(self.value & 0b100)
[ "def", "is_manufacturer_specific", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "value", "&", "0b100", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L525-L527
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_manufacturer_specific
(self, value: bool)
Sets manufacturer specific code.
Sets manufacturer specific code.
[ "Sets", "manufacturer", "specific", "code", "." ]
def is_manufacturer_specific(self, value: bool) -> None: """Sets manufacturer specific code.""" if value: self.value |= 0b100 return self.value &= 0b11111011
[ "def", "is_manufacturer_specific", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "if", "value", ":", "self", ".", "value", "|=", "0b100", "return", "self", ".", "value", "&=", "0b11111011" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L530-L535
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_reply
(self)
return bool(self.value & 0b1000)
Return True if is a reply (server cluster -> client cluster.
Return True if is a reply (server cluster -> client cluster.
[ "Return", "True", "if", "is", "a", "reply", "(", "server", "cluster", "-", ">", "client", "cluster", "." ]
def is_reply(self) -> bool: """Return True if is a reply (server cluster -> client cluster.""" return bool(self.value & 0b1000)
[ "def", "is_reply", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "value", "&", "0b1000", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L538-L540
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.is_reply
(self, value: bool)
Sets the direction.
Sets the direction.
[ "Sets", "the", "direction", "." ]
def is_reply(self, value: bool) -> None: """Sets the direction.""" if value: self.value |= 0b1000 return self.value &= 0b11110111
[ "def", "is_reply", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "if", "value", ":", "self", ".", "value", "|=", "0b1000", "return", "self", ".", "value", "&=", "0b11110111" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L546-L551
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.__repr__
(self)
return ( "<{} frame_type={} manufacturer_specific={} is_reply={} " "disable_default_response={}>" ).format( self.__class__.__name__, self.frame_type.name, self.is_manufacturer_specific, self.is_reply, self.disable_default_response, )
Representation.
Representation.
[ "Representation", "." ]
def __repr__(self) -> str: """Representation.""" return ( "<{} frame_type={} manufacturer_specific={} is_reply={} " "disable_default_response={}>" ).format( self.__class__.__name__, self.frame_type.name, self.is_manufacturer_specific, self.is_reply, self.disable_default_response, )
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "(", "\"<{} frame_type={} manufacturer_specific={} is_reply={} \"", "\"disable_default_response={}>\"", ")", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "frame_type", ".", "name", ",", "self", ".", "is_manufacturer_specific", ",", "self", ".", "is_reply", ",", "self", ".", "disable_default_response", ",", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L553-L564
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.cluster
(cls, is_reply: bool = False)
return r
New Local Cluster specific command frame control.
New Local Cluster specific command frame control.
[ "New", "Local", "Cluster", "specific", "command", "frame", "control", "." ]
def cluster(cls, is_reply: bool = False): """New Local Cluster specific command frame control.""" r = cls(FrameType.CLUSTER_COMMAND) r.is_reply = is_reply if is_reply: r.disable_default_response = True return r
[ "def", "cluster", "(", "cls", ",", "is_reply", ":", "bool", "=", "False", ")", ":", "r", "=", "cls", "(", "FrameType", ".", "CLUSTER_COMMAND", ")", "r", ".", "is_reply", "=", "is_reply", "if", "is_reply", ":", "r", ".", "disable_default_response", "=", "True", "return", "r" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L570-L576
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
FrameControl.general
(cls, is_reply: bool = False)
return r
New General ZCL command frame control.
New General ZCL command frame control.
[ "New", "General", "ZCL", "command", "frame", "control", "." ]
def general(cls, is_reply: bool = False): """New General ZCL command frame control.""" r = cls(FrameType.GLOBAL_COMMAND) r.is_reply = is_reply if is_reply: r.disable_default_response = True return r
[ "def", "general", "(", "cls", ",", "is_reply", ":", "bool", "=", "False", ")", ":", "r", "=", "cls", "(", "FrameType", ".", "GLOBAL_COMMAND", ")", "r", ".", "is_reply", "=", "is_reply", "if", "is_reply", ":", "r", ".", "disable_default_response", "=", "True", "return", "r" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L584-L590
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.__init__
( self, frame_control: FrameControl, tsn: Union[int, t.uint8_t] = 0, command_id: Union[Command, int, t.uint8_t] = 0, manufacturer: Optional[Union[int, t.uint16_t]] = None, )
Initialize ZCL Frame instance.
Initialize ZCL Frame instance.
[ "Initialize", "ZCL", "Frame", "instance", "." ]
def __init__( self, frame_control: FrameControl, tsn: Union[int, t.uint8_t] = 0, command_id: Union[Command, int, t.uint8_t] = 0, manufacturer: Optional[Union[int, t.uint16_t]] = None, ) -> None: """Initialize ZCL Frame instance.""" self._frc = frame_control if frame_control.is_general: self._cmd_id = Command(command_id) else: self._cmd_id = t.uint8_t(command_id) self._manufacturer = manufacturer if manufacturer is not None: self.frame_control.is_manufacturer_specific = True self._tsn = t.uint8_t(tsn)
[ "def", "__init__", "(", "self", ",", "frame_control", ":", "FrameControl", ",", "tsn", ":", "Union", "[", "int", ",", "t", ".", "uint8_t", "]", "=", "0", ",", "command_id", ":", "Union", "[", "Command", ",", "int", ",", "t", ".", "uint8_t", "]", "=", "0", ",", "manufacturer", ":", "Optional", "[", "Union", "[", "int", ",", "t", ".", "uint16_t", "]", "]", "=", "None", ",", ")", "->", "None", ":", "self", ".", "_frc", "=", "frame_control", "if", "frame_control", ".", "is_general", ":", "self", ".", "_cmd_id", "=", "Command", "(", "command_id", ")", "else", ":", "self", ".", "_cmd_id", "=", "t", ".", "uint8_t", "(", "command_id", ")", "self", ".", "_manufacturer", "=", "manufacturer", "if", "manufacturer", "is", "not", "None", ":", "self", ".", "frame_control", ".", "is_manufacturer_specific", "=", "True", "self", ".", "_tsn", "=", "t", ".", "uint8_t", "(", "tsn", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L596-L612
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.frame_control
(self)
return self._frc
Return frame control.
Return frame control.
[ "Return", "frame", "control", "." ]
def frame_control(self) -> FrameControl: """Return frame control.""" return self._frc
[ "def", "frame_control", "(", "self", ")", "->", "FrameControl", ":", "return", "self", ".", "_frc" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L615-L617
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.command_id
(self)
return self._cmd_id
Return command identifier.
Return command identifier.
[ "Return", "command", "identifier", "." ]
def command_id(self) -> Command: """Return command identifier.""" return self._cmd_id
[ "def", "command_id", "(", "self", ")", "->", "Command", ":", "return", "self", ".", "_cmd_id" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L620-L622
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.command_id
(self, value: Command)
Setter for command identifier.
Setter for command identifier.
[ "Setter", "for", "command", "identifier", "." ]
def command_id(self, value: Command) -> None: """Setter for command identifier.""" if self.frame_control.is_general: self._cmd_id = Command(value) return self._cmd_id = t.uint8_t(value)
[ "def", "command_id", "(", "self", ",", "value", ":", "Command", ")", "->", "None", ":", "if", "self", ".", "frame_control", ".", "is_general", ":", "self", ".", "_cmd_id", "=", "Command", "(", "value", ")", "return", "self", ".", "_cmd_id", "=", "t", ".", "uint8_t", "(", "value", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L625-L630
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.is_reply
(self)
return self.frame_control.is_reply
Return direction of Frame Control.
Return direction of Frame Control.
[ "Return", "direction", "of", "Frame", "Control", "." ]
def is_reply(self) -> bool: """Return direction of Frame Control.""" return self.frame_control.is_reply
[ "def", "is_reply", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "frame_control", ".", "is_reply" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L633-L635
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.manufacturer
(self)
return t.uint16_t(self._manufacturer)
Return manufacturer id.
Return manufacturer id.
[ "Return", "manufacturer", "id", "." ]
def manufacturer(self) -> Optional[t.uint16_t]: """Return manufacturer id.""" if self._manufacturer is None: return None return t.uint16_t(self._manufacturer)
[ "def", "manufacturer", "(", "self", ")", "->", "Optional", "[", "t", ".", "uint16_t", "]", ":", "if", "self", ".", "_manufacturer", "is", "None", ":", "return", "None", "return", "t", ".", "uint16_t", "(", "self", ".", "_manufacturer", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L638-L642
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.tsn
(self)
return self._tsn
Return transaction seq number.
Return transaction seq number.
[ "Return", "transaction", "seq", "number", "." ]
def tsn(self) -> t.uint8_t: """Return transaction seq number.""" return self._tsn
[ "def", "tsn", "(", "self", ")", "->", "t", ".", "uint8_t", ":", "return", "self", ".", "_tsn" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L650-L652
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.tsn
(self, value: t.uint8_t)
Setter for tsn.
Setter for tsn.
[ "Setter", "for", "tsn", "." ]
def tsn(self, value: t.uint8_t) -> None: """Setter for tsn.""" self._tsn = t.uint8_t(value)
[ "def", "tsn", "(", "self", ",", "value", ":", "t", ".", "uint8_t", ")", "->", "None", ":", "self", ".", "_tsn", "=", "t", ".", "uint8_t", "(", "value", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L655-L657
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.deserialize
(cls, data)
return r, data
Deserialize from bytes.
Deserialize from bytes.
[ "Deserialize", "from", "bytes", "." ]
def deserialize(cls, data): """Deserialize from bytes.""" frc, data = FrameControl.deserialize(data) r = cls(frc) if frc.is_manufacturer_specific: r.manufacturer, data = t.uint16_t.deserialize(data) r.tsn, data = t.uint8_t.deserialize(data) r.command_id, data = Command.deserialize(data) return r, data
[ "def", "deserialize", "(", "cls", ",", "data", ")", ":", "frc", ",", "data", "=", "FrameControl", ".", "deserialize", "(", "data", ")", "r", "=", "cls", "(", "frc", ")", "if", "frc", ".", "is_manufacturer_specific", ":", "r", ".", "manufacturer", ",", "data", "=", "t", ".", "uint16_t", ".", "deserialize", "(", "data", ")", "r", ".", "tsn", ",", "data", "=", "t", ".", "uint8_t", ".", "deserialize", "(", "data", ")", "r", ".", "command_id", ",", "data", "=", "Command", ".", "deserialize", "(", "data", ")", "return", "r", ",", "data" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L660-L668
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.serialize
(self)
return d
Serialize to bytes.
Serialize to bytes.
[ "Serialize", "to", "bytes", "." ]
def serialize(self): """Serialize to bytes.""" d = self.frame_control.serialize() if self.frame_control.is_manufacturer_specific: d += self.manufacturer.serialize() d += self.tsn.serialize() d += self.command_id.serialize() return d
[ "def", "serialize", "(", "self", ")", ":", "d", "=", "self", ".", "frame_control", ".", "serialize", "(", ")", "if", "self", ".", "frame_control", ".", "is_manufacturer_specific", ":", "d", "+=", "self", ".", "manufacturer", ".", "serialize", "(", ")", "d", "+=", "self", ".", "tsn", ".", "serialize", "(", ")", "d", "+=", "self", ".", "command_id", ".", "serialize", "(", ")", "return", "d" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L670-L677
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/foundation.py
python
ZCLHeader.__repr__
(self)
return "<{} frame_control={} manufacturer={} tsn={} command_id={}>".format( self.__class__.__name__, self.frame_control, self.manufacturer, self.tsn, str(self.command_id), )
Representation.
Representation.
[ "Representation", "." ]
def __repr__(self) -> str: """Representation.""" return "<{} frame_control={} manufacturer={} tsn={} command_id={}>".format( self.__class__.__name__, self.frame_control, self.manufacturer, self.tsn, str(self.command_id), )
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "\"<{} frame_control={} manufacturer={} tsn={} command_id={}>\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "frame_control", ",", "self", ".", "manufacturer", ",", "self", ".", "tsn", ",", "str", "(", "self", ".", "command_id", ")", ",", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/foundation.py#L705-L713
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.write_attributes_undivided
( self, attributes: Dict[Union[str, int], Any], manufacturer: Optional[int] = None )
return self._write_attributes_undivided(args, manufacturer=manufacturer)
Either all or none of the attributes are written by the device.
Either all or none of the attributes are written by the device.
[ "Either", "all", "or", "none", "of", "the", "attributes", "are", "written", "by", "the", "device", "." ]
def write_attributes_undivided( self, attributes: Dict[Union[str, int], Any], manufacturer: Optional[int] = None ) -> List: """Either all or none of the attributes are written by the device.""" args = self._write_attr_records(attributes) return self._write_attributes_undivided(args, manufacturer=manufacturer)
[ "def", "write_attributes_undivided", "(", "self", ",", "attributes", ":", "Dict", "[", "Union", "[", "str", ",", "int", "]", ",", "Any", "]", ",", "manufacturer", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "List", ":", "args", "=", "self", ".", "_write_attr_records", "(", "attributes", ")", "return", "self", ".", "_write_attributes_undivided", "(", "args", ",", "manufacturer", "=", "manufacturer", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L394-L399
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.configure_reporting
( self, attribute: int | str, min_interval: int, max_interval: int, reportable_change: int, manufacturer: int | None = None, )
return self.configure_reporting_multiple( {attribute: (min_interval, max_interval, reportable_change)}, manufacturer=manufacturer, )
Configure attribute reporting for a single attribute.
Configure attribute reporting for a single attribute.
[ "Configure", "attribute", "reporting", "for", "a", "single", "attribute", "." ]
def configure_reporting( self, attribute: int | str, min_interval: int, max_interval: int, reportable_change: int, manufacturer: int | None = None, ) -> Coroutine: """Configure attribute reporting for a single attribute.""" return self.configure_reporting_multiple( {attribute: (min_interval, max_interval, reportable_change)}, manufacturer=manufacturer, )
[ "def", "configure_reporting", "(", "self", ",", "attribute", ":", "int", "|", "str", ",", "min_interval", ":", "int", ",", "max_interval", ":", "int", ",", "reportable_change", ":", "int", ",", "manufacturer", ":", "int", "|", "None", "=", "None", ",", ")", "->", "Coroutine", ":", "return", "self", ".", "configure_reporting_multiple", "(", "{", "attribute", ":", "(", "min_interval", ",", "max_interval", ",", "reportable_change", ")", "}", ",", "manufacturer", "=", "manufacturer", ",", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L433-L445
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.configure_reporting_multiple
( self, attributes: dict[int | str, tuple[int, int, int]], manufacturer: int | None = None, )
return res
Configure attribute reporting for multiple attributes in the same request. :param attributes: dict of attributes to configure attribute reporting. Key is either int or str for attribute id or attribute name. Value is a Tuple of: - minimum reporting interval - maximum reporting interval - reportable change :param manufacturer: optional manufacturer id to use with the command
Configure attribute reporting for multiple attributes in the same request.
[ "Configure", "attribute", "reporting", "for", "multiple", "attributes", "in", "the", "same", "request", "." ]
async def configure_reporting_multiple( self, attributes: dict[int | str, tuple[int, int, int]], manufacturer: int | None = None, ) -> list[foundation.ConfigureReportingResponseRecord]: """Configure attribute reporting for multiple attributes in the same request. :param attributes: dict of attributes to configure attribute reporting. Key is either int or str for attribute id or attribute name. Value is a Tuple of: - minimum reporting interval - maximum reporting interval - reportable change :param manufacturer: optional manufacturer id to use with the command """ cfg = [ self._attr_reporting_rec(attr, rep[0], rep[1], rep[2]) for attr, rep in attributes.items() ] res = await self._configure_reporting(cfg, manufacturer=manufacturer) # Parse configure reporting result for unsupported attributes records = res[0] if ( isinstance(records, list) and not ( len(records) == 1 and records[0].status == foundation.Status.SUCCESS ) and len(records) >= 0 ): failed = [ r.attrid for r in records if r.status == foundation.Status.UNSUPPORTED_ATTRIBUTE ] for attr in failed: self.add_unsupported_attribute(attr) return res
[ "async", "def", "configure_reporting_multiple", "(", "self", ",", "attributes", ":", "dict", "[", "int", "|", "str", ",", "tuple", "[", "int", ",", "int", ",", "int", "]", "]", ",", "manufacturer", ":", "int", "|", "None", "=", "None", ",", ")", "->", "list", "[", "foundation", ".", "ConfigureReportingResponseRecord", "]", ":", "cfg", "=", "[", "self", ".", "_attr_reporting_rec", "(", "attr", ",", "rep", "[", "0", "]", ",", "rep", "[", "1", "]", ",", "rep", "[", "2", "]", ")", "for", "attr", ",", "rep", "in", "attributes", ".", "items", "(", ")", "]", "res", "=", "await", "self", ".", "_configure_reporting", "(", "cfg", ",", "manufacturer", "=", "manufacturer", ")", "# Parse configure reporting result for unsupported attributes", "records", "=", "res", "[", "0", "]", "if", "(", "isinstance", "(", "records", ",", "list", ")", "and", "not", "(", "len", "(", "records", ")", "==", "1", "and", "records", "[", "0", "]", ".", "status", "==", "foundation", ".", "Status", ".", "SUCCESS", ")", "and", "len", "(", "records", ")", ">=", "0", ")", ":", "failed", "=", "[", "r", ".", "attrid", "for", "r", "in", "records", "if", "r", ".", "status", "==", "foundation", ".", "Status", ".", "UNSUPPORTED_ATTRIBUTE", "]", "for", "attr", "in", "failed", ":", "self", ".", "add_unsupported_attribute", "(", "attr", ")", "return", "res" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L447-L485
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.is_client
(self)
return self._type == ClusterType.Client
Return True if this is a client cluster.
Return True if this is a client cluster.
[ "Return", "True", "if", "this", "is", "a", "client", "cluster", "." ]
def is_client(self) -> bool: """Return True if this is a client cluster.""" return self._type == ClusterType.Client
[ "def", "is_client", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_type", "==", "ClusterType", ".", "Client" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L521-L523
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.is_server
(self)
return self._type == ClusterType.Server
Return True if this is a server cluster.
Return True if this is a server cluster.
[ "Return", "True", "if", "this", "is", "a", "server", "cluster", "." ]
def is_server(self) -> bool: """Return True if this is a server cluster.""" return self._type == ClusterType.Server
[ "def", "is_server", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_type", "==", "ClusterType", ".", "Server" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L526-L528
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.update_attribute
(self, attrid, value)
Update specified attribute with specified value
Update specified attribute with specified value
[ "Update", "specified", "attribute", "with", "specified", "value" ]
def update_attribute(self, attrid, value): """Update specified attribute with specified value""" self._update_attribute(attrid, value)
[ "def", "update_attribute", "(", "self", ",", "attrid", ",", "value", ")", ":", "self", ".", "_update_attribute", "(", "attrid", ",", "value", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L542-L544
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.get
(self, key: Union[int, str], default: Optional[Any] = None)
Get cached attribute.
Get cached attribute.
[ "Get", "cached", "attribute", "." ]
def get(self, key: Union[int, str], default: Optional[Any] = None) -> Any: """Get cached attribute.""" if isinstance(key, int): return self._attr_cache.get(key, default) elif isinstance(key, str): try: attr_id = self.attridx[key] except KeyError: return default return self._attr_cache.get(attr_id, default) raise ValueError("attr_name or attr_id are accepted only")
[ "def", "get", "(", "self", ",", "key", ":", "Union", "[", "int", ",", "str", "]", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ")", "->", "Any", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "return", "self", ".", "_attr_cache", ".", "get", "(", "key", ",", "default", ")", "elif", "isinstance", "(", "key", ",", "str", ")", ":", "try", ":", "attr_id", "=", "self", ".", "attridx", "[", "key", "]", "except", "KeyError", ":", "return", "default", "return", "self", ".", "_attr_cache", ".", "get", "(", "attr_id", ",", "default", ")", "raise", "ValueError", "(", "\"attr_name or attr_id are accepted only\"", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L569-L580
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.__getitem__
(self, key: Union[int, str])
Return cached value of the attr.
Return cached value of the attr.
[ "Return", "cached", "value", "of", "the", "attr", "." ]
def __getitem__(self, key: Union[int, str]) -> Any: """Return cached value of the attr.""" if isinstance(key, int): return self._attr_cache[key] elif isinstance(key, str): return self._attr_cache[self.attridx[key]] raise ValueError("attr_name or attr_id are accepted only")
[ "def", "__getitem__", "(", "self", ",", "key", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "Any", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "return", "self", ".", "_attr_cache", "[", "key", "]", "elif", "isinstance", "(", "key", ",", "str", ")", ":", "return", "self", ".", "_attr_cache", "[", "self", ".", "attridx", "[", "key", "]", "]", "raise", "ValueError", "(", "\"attr_name or attr_id are accepted only\"", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L582-L588
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.__setitem__
(self, key: Union[int, str], value: Any)
Set cached value through attribute write.
Set cached value through attribute write.
[ "Set", "cached", "value", "through", "attribute", "write", "." ]
def __setitem__(self, key: Union[int, str], value: Any) -> None: """Set cached value through attribute write.""" if not isinstance(key, (int, str)): raise ValueError("attr_name or attr_id are accepted only") self.create_catching_task(self.write_attributes({key: value}))
[ "def", "__setitem__", "(", "self", ",", "key", ":", "Union", "[", "int", ",", "str", "]", ",", "value", ":", "Any", ")", "->", "None", ":", "if", "not", "isinstance", "(", "key", ",", "(", "int", ",", "str", ")", ")", ":", "raise", "ValueError", "(", "\"attr_name or attr_id are accepted only\"", ")", "self", ".", "create_catching_task", "(", "self", ".", "write_attributes", "(", "{", "key", ":", "value", "}", ")", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L590-L594
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.send_default_rsp
( self, hdr: foundation.ZCLHeader, status: foundation.Status = foundation.Status.SUCCESS, )
Send default response unconditionally.
Send default response unconditionally.
[ "Send", "default", "response", "unconditionally", "." ]
def send_default_rsp( self, hdr: foundation.ZCLHeader, status: foundation.Status = foundation.Status.SUCCESS, ) -> None: """Send default response unconditionally.""" self.create_catching_task( self.general_command( foundation.Command.Default_Response, hdr.command_id, status, tsn=hdr.tsn, ) )
[ "def", "send_default_rsp", "(", "self", ",", "hdr", ":", "foundation", ".", "ZCLHeader", ",", "status", ":", "foundation", ".", "Status", "=", "foundation", ".", "Status", ".", "SUCCESS", ",", ")", "->", "None", ":", "self", ".", "create_catching_task", "(", "self", ".", "general_command", "(", "foundation", ".", "Command", ".", "Default_Response", ",", "hdr", ".", "command_id", ",", "status", ",", "tsn", "=", "hdr", ".", "tsn", ",", ")", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L651-L664
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
Cluster.add_unsupported_attribute
( self, attr: int | str, inhibit_events: bool = False )
Adds unsupported attribute.
Adds unsupported attribute.
[ "Adds", "unsupported", "attribute", "." ]
def add_unsupported_attribute( self, attr: int | str, inhibit_events: bool = False ) -> None: """Adds unsupported attribute.""" if attr in self.unsupported_attributes: return self.unsupported_attributes.add(attr) if isinstance(attr, int): if not inhibit_events: self.listener_event("unsupported_attribute_added", attr) reverse_attr = self.attributes.get(attr, (None,))[0] else: reverse_attr = self.attridx.get(attr) if not (reverse_attr is None or reverse_attr in self.unsupported_attributes): self.add_unsupported_attribute(reverse_attr, inhibit_events)
[ "def", "add_unsupported_attribute", "(", "self", ",", "attr", ":", "int", "|", "str", ",", "inhibit_events", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "attr", "in", "self", ".", "unsupported_attributes", ":", "return", "self", ".", "unsupported_attributes", ".", "add", "(", "attr", ")", "if", "isinstance", "(", "attr", ",", "int", ")", ":", "if", "not", "inhibit_events", ":", "self", ".", "listener_event", "(", "\"unsupported_attribute_added\"", ",", "attr", ")", "reverse_attr", "=", "self", ".", "attributes", ".", "get", "(", "attr", ",", "(", "None", ",", ")", ")", "[", "0", "]", "else", ":", "reverse_attr", "=", "self", ".", "attridx", ".", "get", "(", "attr", ")", "if", "not", "(", "reverse_attr", "is", "None", "or", "reverse_attr", "in", "self", ".", "unsupported_attributes", ")", ":", "self", ".", "add_unsupported_attribute", "(", "reverse_attr", ",", "inhibit_events", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L666-L682
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/__init__.py
python
ClusterPersistingListener.unsupported_attribute_added
(self, attrid: int)
An unsupported attribute was added.
An unsupported attribute was added.
[ "An", "unsupported", "attribute", "was", "added", "." ]
def unsupported_attribute_added(self, attrid: int) -> None: """An unsupported attribute was added.""" self._applistener.unsupported_attribute_added(self._cluster, attrid)
[ "def", "unsupported_attribute_added", "(", "self", ",", "attrid", ":", "int", ")", "->", "None", ":", "self", ".", "_applistener", ".", "unsupported_attribute_added", "(", "self", ".", "_cluster", ",", "attrid", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/__init__.py#L699-L701
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/clusters/security.py
python
_SquawkOrWarningCommand.__eq__
(self, other)
return self.value == other
Compare to int.
Compare to int.
[ "Compare", "to", "int", "." ]
def __eq__(self, other): """Compare to int.""" return self.value == other
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "value", "==", "other" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/clusters/security.py#L249-L251
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/zcl/clusters/general.py
python
Ota._handle_cluster_request
( self, hdr: foundation.ZCLHeader, args: List[Any], *, dst_addressing: Optional[ Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK] ] = None, )
Parse OTA commands.
Parse OTA commands.
[ "Parse", "OTA", "commands", "." ]
async def _handle_cluster_request( self, hdr: foundation.ZCLHeader, args: List[Any], *, dst_addressing: Optional[ Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK] ] = None, ): """Parse OTA commands.""" tsn, command_id = hdr.tsn, hdr.command_id cmd_name = self.server_commands.get(command_id, [command_id])[0] if cmd_name == "query_next_image": await self._handle_query_next_image( *args, tsn=tsn, model=self.endpoint.model ) elif cmd_name == "image_block": await self._handle_image_block(*args, tsn=tsn, model=self.endpoint.model) elif cmd_name == "upgrade_end": await self._handle_upgrade_end(*args, tsn=tsn) else: self.debug( "no '%s' OTA command handler for '%s %s': %s", cmd_name, self.endpoint.manufacturer, self.endpoint.model, args, )
[ "async", "def", "_handle_cluster_request", "(", "self", ",", "hdr", ":", "foundation", ".", "ZCLHeader", ",", "args", ":", "List", "[", "Any", "]", ",", "*", ",", "dst_addressing", ":", "Optional", "[", "Union", "[", "t", ".", "Addressing", ".", "Group", ",", "t", ".", "Addressing", ".", "IEEE", ",", "t", ".", "Addressing", ".", "NWK", "]", "]", "=", "None", ",", ")", ":", "tsn", ",", "command_id", "=", "hdr", ".", "tsn", ",", "hdr", ".", "command_id", "cmd_name", "=", "self", ".", "server_commands", ".", "get", "(", "command_id", ",", "[", "command_id", "]", ")", "[", "0", "]", "if", "cmd_name", "==", "\"query_next_image\"", ":", "await", "self", ".", "_handle_query_next_image", "(", "*", "args", ",", "tsn", "=", "tsn", ",", "model", "=", "self", ".", "endpoint", ".", "model", ")", "elif", "cmd_name", "==", "\"image_block\"", ":", "await", "self", ".", "_handle_image_block", "(", "*", "args", ",", "tsn", "=", "tsn", ",", "model", "=", "self", ".", "endpoint", ".", "model", ")", "elif", "cmd_name", "==", "\"upgrade_end\"", ":", "await", "self", ".", "_handle_upgrade_end", "(", "*", "args", ",", "tsn", "=", "tsn", ")", "else", ":", "self", ".", "debug", "(", "\"no '%s' OTA command handler for '%s %s': %s\"", ",", "cmd_name", ",", "self", ".", "endpoint", ".", "manufacturer", ",", "self", ".", "endpoint", ".", "model", ",", "args", ",", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/zcl/clusters/general.py#L1017-L1045
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/config/validators.py
python
cv_boolean
(value: Union[bool, int, str])
Validate and coerce a boolean value.
Validate and coerce a boolean value.
[ "Validate", "and", "coerce", "a", "boolean", "value", "." ]
def cv_boolean(value: Union[bool, int, str]) -> bool: """Validate and coerce a boolean value.""" if isinstance(value, bool): return value if isinstance(value, str): value = value.lower().strip() if value in ("1", "true", "yes", "on", "enable"): return True if value in ("0", "false", "no", "off", "disable"): return False elif isinstance(value, int): return bool(value) raise vol.Invalid(f"invalid boolean '{value}' value")
[ "def", "cv_boolean", "(", "value", ":", "Union", "[", "bool", ",", "int", ",", "str", "]", ")", "->", "bool", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "value", ".", "lower", "(", ")", ".", "strip", "(", ")", "if", "value", "in", "(", "\"1\"", ",", "\"true\"", ",", "\"yes\"", ",", "\"on\"", ",", "\"enable\"", ")", ":", "return", "True", "if", "value", "in", "(", "\"0\"", ",", "\"false\"", ",", "\"no\"", ",", "\"off\"", ",", "\"disable\"", ")", ":", "return", "False", "elif", "isinstance", "(", "value", ",", "int", ")", ":", "return", "bool", "(", "value", ")", "raise", "vol", ".", "Invalid", "(", "f\"invalid boolean '{value}' value\"", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/config/validators.py#L8-L20
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/config/validators.py
python
cv_hex
(value: Union[int, str])
return value
Convert string with possible hex number into int.
Convert string with possible hex number into int.
[ "Convert", "string", "with", "possible", "hex", "number", "into", "int", "." ]
def cv_hex(value: Union[int, str]) -> int: """Convert string with possible hex number into int.""" if isinstance(value, int): return value if not isinstance(value, str): raise vol.Invalid(f"{value} is not a valid hex number") try: if value.startswith("0x"): value = int(value, base=16) else: value = int(value) except ValueError: raise vol.Invalid(f"Could not convert '{value}' to number") return value
[ "def", "cv_hex", "(", "value", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "int", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "return", "value", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "raise", "vol", ".", "Invalid", "(", "f\"{value} is not a valid hex number\"", ")", "try", ":", "if", "value", ".", "startswith", "(", "\"0x\"", ")", ":", "value", "=", "int", "(", "value", ",", "base", "=", "16", ")", "else", ":", "value", "=", "int", "(", "value", ")", "except", "ValueError", ":", "raise", "vol", ".", "Invalid", "(", "f\"Could not convert '{value}' to number\"", ")", "return", "value" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/config/validators.py#L23-L39
zigpy/zigpy
0e901b013da074d24de18aca1e579287e756cd84
zigpy/config/validators.py
python
cv_key
(key: List[int])
return t.KeyData(key)
Validate a key.
Validate a key.
[ "Validate", "a", "key", "." ]
def cv_key(key: List[int]) -> t.KeyData: """Validate a key.""" if not isinstance(key, list) or not all(isinstance(v, int) for v in key): raise vol.Invalid("key must be a list of integers") if len(key) != 16: raise vol.Invalid("key length must be 16") if not all((0 <= e <= 255 for e in key)): raise vol.Invalid("Key bytes must be within (0..255) range") return t.KeyData(key)
[ "def", "cv_key", "(", "key", ":", "List", "[", "int", "]", ")", "->", "t", ".", "KeyData", ":", "if", "not", "isinstance", "(", "key", ",", "list", ")", "or", "not", "all", "(", "isinstance", "(", "v", ",", "int", ")", "for", "v", "in", "key", ")", ":", "raise", "vol", ".", "Invalid", "(", "\"key must be a list of integers\"", ")", "if", "len", "(", "key", ")", "!=", "16", ":", "raise", "vol", ".", "Invalid", "(", "\"key length must be 16\"", ")", "if", "not", "all", "(", "(", "0", "<=", "e", "<=", "255", "for", "e", "in", "key", ")", ")", ":", "raise", "vol", ".", "Invalid", "(", "\"Key bytes must be within (0..255) range\"", ")", "return", "t", ".", "KeyData", "(", "key", ")" ]
https://github.com/zigpy/zigpy/blob/0e901b013da074d24de18aca1e579287e756cd84/zigpy/config/validators.py#L42-L53
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.pub
(self, topic=b'', embed_topic=False)
return self.__send_function(sock, topic, embed_topic)
Returns a callable that can be used to transmit a message, with a given ``topic``, in a publisher-subscriber fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. By default, no topic will be included into published messages. Being up to developers to include the topic, at the beginning of the first part (i.e. frame) of every published message, so that subscribers are able to receive them. For a different behaviour, check the embed_topic argument. :param topic: the topic that will be published to (default=b'') :type topic: bytes :param embed_topic: set for the topic to be automatically sent as the first part (i.e. frame) of every published message (default=False) :type embed_topic bool :rtype: function
Returns a callable that can be used to transmit a message, with a given ``topic``, in a publisher-subscriber fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message.
[ "Returns", "a", "callable", "that", "can", "be", "used", "to", "transmit", "a", "message", "with", "a", "given", "topic", "in", "a", "publisher", "-", "subscriber", "fashion", ".", "Note", "that", "the", "sender", "function", "has", "a", "print", "like", "signature", "with", "an", "infinite", "number", "of", "arguments", ".", "Each", "one", "being", "a", "part", "of", "the", "complete", "message", "." ]
def pub(self, topic=b'', embed_topic=False): """ Returns a callable that can be used to transmit a message, with a given ``topic``, in a publisher-subscriber fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. By default, no topic will be included into published messages. Being up to developers to include the topic, at the beginning of the first part (i.e. frame) of every published message, so that subscribers are able to receive them. For a different behaviour, check the embed_topic argument. :param topic: the topic that will be published to (default=b'') :type topic: bytes :param embed_topic: set for the topic to be automatically sent as the first part (i.e. frame) of every published message (default=False) :type embed_topic bool :rtype: function """ if not isinstance(topic, bytes): error = 'Topic must be bytes' log.error(error) raise TypeError(error) sock = self.__sock(zmq.PUB) return self.__send_function(sock, topic, embed_topic)
[ "def", "pub", "(", "self", ",", "topic", "=", "b''", ",", "embed_topic", "=", "False", ")", ":", "if", "not", "isinstance", "(", "topic", ",", "bytes", ")", ":", "error", "=", "'Topic must be bytes'", "log", ".", "error", "(", "error", ")", "raise", "TypeError", "(", "error", ")", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "PUB", ")", "return", "self", ".", "__send_function", "(", "sock", ",", "topic", ",", "embed_topic", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L114-L141
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.sub
(self, topics=(b'',))
return self.__recv_generator(sock)
Returns an iterable that can be used to iterate over incoming messages, that were published with one of the topics specified in ``topics``. Note that the iterable returns as many parts as sent by subscribed publishers. :param topics: a list of topics to subscribe to (default=b'') :type topics: list of bytes :rtype: generator
Returns an iterable that can be used to iterate over incoming messages, that were published with one of the topics specified in ``topics``. Note that the iterable returns as many parts as sent by subscribed publishers.
[ "Returns", "an", "iterable", "that", "can", "be", "used", "to", "iterate", "over", "incoming", "messages", "that", "were", "published", "with", "one", "of", "the", "topics", "specified", "in", "topics", ".", "Note", "that", "the", "iterable", "returns", "as", "many", "parts", "as", "sent", "by", "subscribed", "publishers", "." ]
def sub(self, topics=(b'',)): """ Returns an iterable that can be used to iterate over incoming messages, that were published with one of the topics specified in ``topics``. Note that the iterable returns as many parts as sent by subscribed publishers. :param topics: a list of topics to subscribe to (default=b'') :type topics: list of bytes :rtype: generator """ sock = self.__sock(zmq.SUB) for topic in topics: if not isinstance(topic, bytes): error = 'Topics must be a list of bytes' log.error(error) raise TypeError(error) sock.setsockopt(zmq.SUBSCRIBE, topic) return self.__recv_generator(sock)
[ "def", "sub", "(", "self", ",", "topics", "=", "(", "b''", ",", ")", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "SUB", ")", "for", "topic", "in", "topics", ":", "if", "not", "isinstance", "(", "topic", ",", "bytes", ")", ":", "error", "=", "'Topics must be a list of bytes'", "log", ".", "error", "(", "error", ")", "raise", "TypeError", "(", "error", ")", "sock", ".", "setsockopt", "(", "zmq", ".", "SUBSCRIBE", ",", "topic", ")", "return", "self", ".", "__recv_generator", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L143-L162
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.push
(self)
return self.__send_function(sock)
Returns a callable that can be used to transmit a message in a push-pull fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: function
Returns a callable that can be used to transmit a message in a push-pull fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message.
[ "Returns", "a", "callable", "that", "can", "be", "used", "to", "transmit", "a", "message", "in", "a", "push", "-", "pull", "fashion", ".", "Note", "that", "the", "sender", "function", "has", "a", "print", "like", "signature", "with", "an", "infinite", "number", "of", "arguments", ".", "Each", "one", "being", "a", "part", "of", "the", "complete", "message", "." ]
def push(self): """ Returns a callable that can be used to transmit a message in a push-pull fashion. Note that the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: function """ sock = self.__sock(zmq.PUSH) return self.__send_function(sock)
[ "def", "push", "(", "self", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "PUSH", ")", "return", "self", ".", "__send_function", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L165-L175
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.pull
(self)
return self.__recv_generator(sock)
Returns an iterable that can be used to iterate over incoming messages, that were pushed by a push socket. Note that the iterable returns as many parts as sent by pushers. :rtype: generator
Returns an iterable that can be used to iterate over incoming messages, that were pushed by a push socket. Note that the iterable returns as many parts as sent by pushers.
[ "Returns", "an", "iterable", "that", "can", "be", "used", "to", "iterate", "over", "incoming", "messages", "that", "were", "pushed", "by", "a", "push", "socket", ".", "Note", "that", "the", "iterable", "returns", "as", "many", "parts", "as", "sent", "by", "pushers", "." ]
def pull(self): """ Returns an iterable that can be used to iterate over incoming messages, that were pushed by a push socket. Note that the iterable returns as many parts as sent by pushers. :rtype: generator """ sock = self.__sock(zmq.PULL) return self.__recv_generator(sock)
[ "def", "pull", "(", "self", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "PULL", ")", "return", "self", ".", "__recv_generator", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L177-L186
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.request
(self)
return self.__send_function(sock), self.__recv_generator(sock)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were replied by a reply socket. Note that the iterable returns as many parts as sent by repliers. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were replied by a reply socket. Note that the iterable returns as many parts as sent by repliers. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message.
[ "Returns", "a", "callable", "and", "an", "iterable", "respectively", ".", "Those", "can", "be", "used", "to", "both", "transmit", "a", "message", "and", "/", "or", "iterate", "over", "incoming", "messages", "that", "were", "replied", "by", "a", "reply", "socket", ".", "Note", "that", "the", "iterable", "returns", "as", "many", "parts", "as", "sent", "by", "repliers", ".", "Also", "the", "sender", "function", "has", "a", "print", "like", "signature", "with", "an", "infinite", "number", "of", "arguments", ".", "Each", "one", "being", "a", "part", "of", "the", "complete", "message", "." ]
def request(self): """ Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were replied by a reply socket. Note that the iterable returns as many parts as sent by repliers. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator) """ sock = self.__sock(zmq.REQ) return self.__send_function(sock), self.__recv_generator(sock)
[ "def", "request", "(", "self", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "REQ", ")", "return", "self", ".", "__send_function", "(", "sock", ")", ",", "self", ".", "__recv_generator", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L189-L201
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.reply
(self)
return self.__send_function(sock), self.__recv_generator(sock)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were requested by a request socket. Note that the iterable returns as many parts as sent by requesters. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were requested by a request socket. Note that the iterable returns as many parts as sent by requesters. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message.
[ "Returns", "a", "callable", "and", "an", "iterable", "respectively", ".", "Those", "can", "be", "used", "to", "both", "transmit", "a", "message", "and", "/", "or", "iterate", "over", "incoming", "messages", "that", "were", "requested", "by", "a", "request", "socket", ".", "Note", "that", "the", "iterable", "returns", "as", "many", "parts", "as", "sent", "by", "requesters", ".", "Also", "the", "sender", "function", "has", "a", "print", "like", "signature", "with", "an", "infinite", "number", "of", "arguments", ".", "Each", "one", "being", "a", "part", "of", "the", "complete", "message", "." ]
def reply(self): """ Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were requested by a request socket. Note that the iterable returns as many parts as sent by requesters. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator) """ sock = self.__sock(zmq.REP) return self.__send_function(sock), self.__recv_generator(sock)
[ "def", "reply", "(", "self", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "REP", ")", "return", "self", ".", "__send_function", "(", "sock", ")", ",", "self", ".", "__recv_generator", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L203-L215
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Sock.pair
(self)
return self.__send_function(sock), self.__recv_generator(sock)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were sent by a pair socket. Note that the iterable returns as many parts as sent by a pair. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator)
Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were sent by a pair socket. Note that the iterable returns as many parts as sent by a pair. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message.
[ "Returns", "a", "callable", "and", "an", "iterable", "respectively", ".", "Those", "can", "be", "used", "to", "both", "transmit", "a", "message", "and", "/", "or", "iterate", "over", "incoming", "messages", "that", "were", "sent", "by", "a", "pair", "socket", ".", "Note", "that", "the", "iterable", "returns", "as", "many", "parts", "as", "sent", "by", "a", "pair", ".", "Also", "the", "sender", "function", "has", "a", "print", "like", "signature", "with", "an", "infinite", "number", "of", "arguments", ".", "Each", "one", "being", "a", "part", "of", "the", "complete", "message", "." ]
def pair(self): """ Returns a callable and an iterable respectively. Those can be used to both transmit a message and/or iterate over incoming messages, that were sent by a pair socket. Note that the iterable returns as many parts as sent by a pair. Also, the sender function has a ``print`` like signature, with an infinite number of arguments. Each one being a part of the complete message. :rtype: (function, generator) """ sock = self.__sock(zmq.PAIR) return self.__send_function(sock), self.__recv_generator(sock)
[ "def", "pair", "(", "self", ")", ":", "sock", "=", "self", ".", "__sock", "(", "zmq", ".", "PAIR", ")", "return", "self", ".", "__send_function", "(", "sock", ")", ",", "self", ".", "__recv_generator", "(", "sock", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L218-L230
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.__init__
(self)
Constructor of the Client.
Constructor of the Client.
[ "Constructor", "of", "the", "Client", "." ]
def __init__(self): """ Constructor of the Client. """ self._sock = None self._is_ready = False self._addresses = [] Sock.__init__(self)
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_sock", "=", "None", "self", ".", "_is_ready", "=", "False", "self", ".", "_addresses", "=", "[", "]", "Sock", ".", "__init__", "(", "self", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L239-L247
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.addresses
(self)
return tuple(self._addresses)
Returns a tuple containing all the connected addresses. Each address is a tuple with an ip address and a port. :rtype: (addresses)
Returns a tuple containing all the connected addresses. Each address is a tuple with an ip address and a port.
[ "Returns", "a", "tuple", "containing", "all", "the", "connected", "addresses", ".", "Each", "address", "is", "a", "tuple", "with", "an", "ip", "address", "and", "a", "port", "." ]
def addresses(self): """ Returns a tuple containing all the connected addresses. Each address is a tuple with an ip address and a port. :rtype: (addresses) """ return tuple(self._addresses)
[ "def", "addresses", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "_addresses", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L260-L267
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.connect
(self, ip, port)
return self
Connects to a server at the specified ip and port. :param ip: an IP address :type ip: str or unicode :param port: port number from 1024 up to 65535 :type port: int :rtype: self
Connects to a server at the specified ip and port.
[ "Connects", "to", "a", "server", "at", "the", "specified", "ip", "and", "port", "." ]
def connect(self, ip, port): """ Connects to a server at the specified ip and port. :param ip: an IP address :type ip: str or unicode :param port: port number from 1024 up to 65535 :type port: int :rtype: self """ _check_valid_port_range(port) address = (ip, port) if address in self._addresses: error = 'Already connected to {0} on port {1}'.format(ip, port) log.exception(error) raise ValueError(error) self._addresses.append(address) if self._is_ready: _check_valid_num_connections(self._sock.socket_type, len(self._addresses)) _connect_zmq_sock(self._sock, ip, port) return self
[ "def", "connect", "(", "self", ",", "ip", ",", "port", ")", ":", "_check_valid_port_range", "(", "port", ")", "address", "=", "(", "ip", ",", "port", ")", "if", "address", "in", "self", ".", "_addresses", ":", "error", "=", "'Already connected to {0} on port {1}'", ".", "format", "(", "ip", ",", "port", ")", "log", ".", "exception", "(", "error", ")", "raise", "ValueError", "(", "error", ")", "self", ".", "_addresses", ".", "append", "(", "address", ")", "if", "self", ".", "_is_ready", ":", "_check_valid_num_connections", "(", "self", ".", "_sock", ".", "socket_type", ",", "len", "(", "self", ".", "_addresses", ")", ")", "_connect_zmq_sock", "(", "self", ".", "_sock", ",", "ip", ",", "port", ")", "return", "self" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L269-L296
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.connect_local
(self, port)
return self.connect('127.0.0.1', port)
Connects to a server in localhost at the specified port. :param port: port number from 1024 up to 65535 :type port: int :rtype: self
Connects to a server in localhost at the specified port.
[ "Connects", "to", "a", "server", "in", "localhost", "at", "the", "specified", "port", "." ]
def connect_local(self, port): """ Connects to a server in localhost at the specified port. :param port: port number from 1024 up to 65535 :type port: int :rtype: self """ return self.connect('127.0.0.1', port)
[ "def", "connect_local", "(", "self", ",", "port", ")", ":", "return", "self", ".", "connect", "(", "'127.0.0.1'", ",", "port", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L298-L306
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.disconnect
(self, ip, port)
return self
Disconnects from a server at the specified ip and port. :param ip: an IP address :type ip: str or unicode :param port: port number from 1024 up to 65535 :type port: int :rtype: self
Disconnects from a server at the specified ip and port.
[ "Disconnects", "from", "a", "server", "at", "the", "specified", "ip", "and", "port", "." ]
def disconnect(self, ip, port): """ Disconnects from a server at the specified ip and port. :param ip: an IP address :type ip: str or unicode :param port: port number from 1024 up to 65535 :type port: int :rtype: self """ _check_valid_port_range(port) address = (ip, port) try: self._addresses.remove(address) except ValueError: error = 'There was no connection to {0} on port {1}'.format(ip, port) log.exception(error) raise ValueError(error) if self._is_ready: _disconnect_zmq_sock(self._sock, ip, port) return self
[ "def", "disconnect", "(", "self", ",", "ip", ",", "port", ")", ":", "_check_valid_port_range", "(", "port", ")", "address", "=", "(", "ip", ",", "port", ")", "try", ":", "self", ".", "_addresses", ".", "remove", "(", "address", ")", "except", "ValueError", ":", "error", "=", "'There was no connection to {0} on port {1}'", ".", "format", "(", "ip", ",", "port", ")", "log", ".", "exception", "(", "error", ")", "raise", "ValueError", "(", "error", ")", "if", "self", ".", "_is_ready", ":", "_disconnect_zmq_sock", "(", "self", ".", "_sock", ",", "ip", ",", "port", ")", "return", "self" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L308-L331
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.disconnect_local
(self, port)
return self.disconnect('127.0.0.1', port)
Disconnects from a server in localhost at the specified port. :param port: port number from 1024 up to 65535 :type port: int :rtype: self
Disconnects from a server in localhost at the specified port.
[ "Disconnects", "from", "a", "server", "in", "localhost", "at", "the", "specified", "port", "." ]
def disconnect_local(self, port): """ Disconnects from a server in localhost at the specified port. :param port: port number from 1024 up to 65535 :type port: int :rtype: self """ return self.disconnect('127.0.0.1', port)
[ "def", "disconnect_local", "(", "self", ",", "port", ")", ":", "return", "self", ".", "disconnect", "(", "'127.0.0.1'", ",", "port", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L333-L341
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Client.disconnect_all
(self)
return self
Disconnects from all connected servers. :rtype: self
Disconnects from all connected servers. :rtype: self
[ "Disconnects", "from", "all", "connected", "servers", ".", ":", "rtype", ":", "self" ]
def disconnect_all(self): """ Disconnects from all connected servers. :rtype: self """ addresses = deepcopy(self._addresses) for ip, port in addresses: self.disconnect(ip, port) return self
[ "def", "disconnect_all", "(", "self", ")", ":", "addresses", "=", "deepcopy", "(", "self", ".", "_addresses", ")", "for", "ip", ",", "port", "in", "addresses", ":", "self", ".", "disconnect", "(", "ip", ",", "port", ")", "return", "self" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L343-L353
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Server.__init__
(self, port)
Constructor of the Server. :param port: either a port number from 1024 up to 65535 or None. In the latter case the server will be bound on a random port and the actual value for the port will be available only after the binding :type port: int
Constructor of the Server.
[ "Constructor", "of", "the", "Server", "." ]
def __init__(self, port): """ Constructor of the Server. :param port: either a port number from 1024 up to 65535 or None. In the latter case the server will be bound on a random port and the actual value for the port will be available only after the binding :type port: int """ if port: _check_valid_port_range(port) self._port = port Sock.__init__(self)
[ "def", "__init__", "(", "self", ",", "port", ")", ":", "if", "port", ":", "_check_valid_port_range", "(", "port", ")", "self", ".", "_port", "=", "port", "Sock", ".", "__init__", "(", "self", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L359-L372
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless/zeroless.py
python
Server.port
(self)
return self._port
Returns the port. :rtype: int
Returns the port.
[ "Returns", "the", "port", "." ]
def port(self): """ Returns the port. :rtype: int """ return self._port
[ "def", "port", "(", "self", ")", ":", "return", "self", ".", "_port" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless/zeroless.py#L385-L391
zmqless/python-zeroless
bff8ce0d12aae36537f41b57b2bd4ee087ed70e2
zeroless_helpers/version.py
python
version
()
return '{major}.{minor}.{patch}'.format(major=__major_version__, minor=__minor_version__, patch=__patch_version__)
Returns the version of the zeroless module. :rtype: string
Returns the version of the zeroless module.
[ "Returns", "the", "version", "of", "the", "zeroless", "module", "." ]
def version(): """ Returns the version of the zeroless module. :rtype: string """ return '{major}.{minor}.{patch}'.format(major=__major_version__, minor=__minor_version__, patch=__patch_version__)
[ "def", "version", "(", ")", ":", "return", "'{major}.{minor}.{patch}'", ".", "format", "(", "major", "=", "__major_version__", ",", "minor", "=", "__minor_version__", ",", "patch", "=", "__patch_version__", ")" ]
https://github.com/zmqless/python-zeroless/blob/bff8ce0d12aae36537f41b57b2bd4ee087ed70e2/zeroless_helpers/version.py#L5-L13
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollProduct.py
python
PollProduct.castVote
(self, index)
Votes for a choice
Votes for a choice
[ "Votes", "for", "a", "choice" ]
def castVote(self, index): "Votes for a choice" self._votes[index] = self._votes[index] + 1 self._votes = self._votes
[ "def", "castVote", "(", "self", ",", "index", ")", ":", "self", ".", "_votes", "[", "index", "]", "=", "self", ".", "_votes", "[", "index", "]", "+", "1", "self", ".", "_votes", "=", "self", ".", "_votes" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollProduct.py#L34-L37
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollProduct.py
python
PollProduct.getTotalVotes
(self)
return total
Returns total number of votes cast
Returns total number of votes cast
[ "Returns", "total", "number", "of", "votes", "cast" ]
def getTotalVotes(self): "Returns total number of votes cast" total = 0 for v in self._votes.values(): total = total + v return total
[ "def", "getTotalVotes", "(", "self", ")", ":", "total", "=", "0", "for", "v", "in", "self", ".", "_votes", ".", "values", "(", ")", ":", "total", "=", "total", "+", "v", "return", "total" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollProduct.py#L40-L45
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollProduct.py
python
PollProduct.getVotesFor
(self, index)
return self._votes[index]
Returns number of votes cast for a given response
Returns number of votes cast for a given response
[ "Returns", "number", "of", "votes", "cast", "for", "a", "given", "response" ]
def getVotesFor(self, index): "Returns number of votes cast for a given response" return self._votes[index]
[ "def", "getVotesFor", "(", "self", ",", "index", ")", ":", "return", "self", ".", "_votes", "[", "index", "]" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollProduct.py#L48-L50
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollProduct.py
python
PollProduct.getResponses
(self)
return tuple(self._responses)
Returns the sequence of responses
Returns the sequence of responses
[ "Returns", "the", "sequence", "of", "responses" ]
def getResponses(self): "Returns the sequence of responses" return tuple(self._responses)
[ "def", "getResponses", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "_responses", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollProduct.py#L53-L55
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollProduct.py
python
PollProduct.getQuestion
(self)
return self._question
Returns the question
Returns the question
[ "Returns", "the", "question" ]
def getQuestion(self): "Returns the question" return self._question
[ "def", "getQuestion", "(", "self", ")", ":", "return", "self", ".", "_question" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollProduct.py#L58-L60
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollImplementation.py
python
PollImplementation.castVote
(self, index)
Votes for a choice
Votes for a choice
[ "Votes", "for", "a", "choice" ]
def castVote(self, index): "Votes for a choice" self._votes[index] = self._votes[index] + 1
[ "def", "castVote", "(", "self", ",", "index", ")", ":", "self", ".", "_votes", "[", "index", "]", "=", "self", ".", "_votes", "[", "index", "]", "+", "1" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollImplementation.py#L22-L24
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollImplementation.py
python
PollImplementation.getTotalVotes
(self)
return total
Returns total number of votes cast
Returns total number of votes cast
[ "Returns", "total", "number", "of", "votes", "cast" ]
def getTotalVotes(self): "Returns total number of votes cast" total = 0 for v in self._votes.values(): total = total + v return total
[ "def", "getTotalVotes", "(", "self", ")", ":", "total", "=", "0", "for", "v", "in", "self", ".", "_votes", ".", "values", "(", ")", ":", "total", "=", "total", "+", "v", "return", "total" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollImplementation.py#L26-L31
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollImplementation.py
python
PollImplementation.getVotesFor
(self, index)
return self._votes[index]
Returns number of votes cast for a given response
Returns number of votes cast for a given response
[ "Returns", "number", "of", "votes", "cast", "for", "a", "given", "response" ]
def getVotesFor(self, index): "Returns number of votes cast for a given response" return self._votes[index]
[ "def", "getVotesFor", "(", "self", ",", "index", ")", ":", "return", "self", ".", "_votes", "[", "index", "]" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollImplementation.py#L33-L35
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollImplementation.py
python
PollImplementation.getResponses
(self)
return tuple(self._responses)
Returns the sequence of responses
Returns the sequence of responses
[ "Returns", "the", "sequence", "of", "responses" ]
def getResponses(self): "Returns the sequence of responses" return tuple(self._responses)
[ "def", "getResponses", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "_responses", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollImplementation.py#L37-L39
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/PollImplementation.py
python
PollImplementation.getQuestion
(self)
return self._question
Returns the question
Returns the question
[ "Returns", "the", "question" ]
def getQuestion(self): "Returns the question" return self._question
[ "def", "getQuestion", "(", "self", ")", ":", "return", "self", ".", "_question" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/PollImplementation.py#L41-L43
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/Poll.py
python
Poll.castVote
(self, index)
Votes for a choice
Votes for a choice
[ "Votes", "for", "a", "choice" ]
def castVote(self, index): "Votes for a choice"
[ "def", "castVote", "(", "self", ",", "index", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/Poll.py#L7-L8
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/Poll.py
python
Poll.getTotalVotes
(self)
Returns total number of votes cast
Returns total number of votes cast
[ "Returns", "total", "number", "of", "votes", "cast" ]
def getTotalVotes(self): "Returns total number of votes cast"
[ "def", "getTotalVotes", "(", "self", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/Poll.py#L10-L11
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/Poll.py
python
Poll.getVotesFor
(self, index)
Returns number of votes cast for a given response
Returns number of votes cast for a given response
[ "Returns", "number", "of", "votes", "cast", "for", "a", "given", "response" ]
def getVotesFor(self, index): "Returns number of votes cast for a given response"
[ "def", "getVotesFor", "(", "self", ",", "index", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/Poll.py#L13-L14
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/Poll.py
python
Poll.getResponses
(self)
Returns the sequence of responses
Returns the sequence of responses
[ "Returns", "the", "sequence", "of", "responses" ]
def getResponses(self): "Returns the sequence of responses"
[ "def", "getResponses", "(", "self", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/Poll.py#L16-L17
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
docs/zdgbook/examples/Poll.py
python
Poll.getQuestion
(self)
Returns the question
Returns the question
[ "Returns", "the", "question" ]
def getQuestion(self): "Returns the question"
[ "def", "getQuestion", "(", "self", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/docs/zdgbook/examples/Poll.py#L19-L20
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/BindingsUI.py
python
BindingsUI.ZBindingsHTML_editAction
(self, REQUEST)
return self.manage_main(self, REQUEST, manage_tabs_message=message)
Changes binding names.
Changes binding names.
[ "Changes", "binding", "names", "." ]
def ZBindingsHTML_editAction(self, REQUEST): '''Changes binding names. ''' self.ZBindings_edit(REQUEST) message = "Bindings changed." return self.manage_main(self, REQUEST, manage_tabs_message=message)
[ "def", "ZBindingsHTML_editAction", "(", "self", ",", "REQUEST", ")", ":", "self", ".", "ZBindings_edit", "(", "REQUEST", ")", "message", "=", "\"Bindings changed.\"", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/BindingsUI.py#L34-L39
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/Bindings.py
python
Bindings.ZBindings_setClient
(self, clientname)
Name the binding to be used as the "client". This is used by classes such as DTMLFile that want to choose an object on which to operate by default.
Name the binding to be used as the "client".
[ "Name", "the", "binding", "to", "be", "used", "as", "the", "client", "." ]
def ZBindings_setClient(self, clientname): '''Name the binding to be used as the "client". This is used by classes such as DTMLFile that want to choose an object on which to operate by default.''' self._Bindings_client = str(clientname)
[ "def", "ZBindings_setClient", "(", "self", ",", "clientname", ")", ":", "self", ".", "_Bindings_client", "=", "str", "(", "clientname", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/Bindings.py#L223-L228
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/Bindings.py
python
Bindings.__call__
(self, *args, **kw)
return self._bindAndExec(args, kw, None)
Calls the script.
Calls the script.
[ "Calls", "the", "script", "." ]
def __call__(self, *args, **kw): '''Calls the script.''' return self._bindAndExec(args, kw, None)
[ "def", "__call__", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "self", ".", "_bindAndExec", "(", "args", ",", "kw", ",", "None", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/Bindings.py#L331-L333
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/Bindings.py
python
Bindings.__render_with_namespace__
(self, namespace)
return self._bindAndExec((), namevals, namespace)
Calls the script with the specified namespace.
Calls the script with the specified namespace.
[ "Calls", "the", "script", "with", "the", "specified", "namespace", "." ]
def __render_with_namespace__(self, namespace): '''Calls the script with the specified namespace.''' namevals = {} # Try to find unbound parameters in the namespace, if the # namespace is bound. if self.getBindingAssignments().isNameAssigned('name_ns'): code = self.__code__ for name in code.co_varnames[:code.co_argcount]: try: namevals[name] = namespace[name] except KeyError: pass return self._bindAndExec((), namevals, namespace)
[ "def", "__render_with_namespace__", "(", "self", ",", "namespace", ")", ":", "namevals", "=", "{", "}", "# Try to find unbound parameters in the namespace, if the", "# namespace is bound.", "if", "self", ".", "getBindingAssignments", "(", ")", ".", "isNameAssigned", "(", "'name_ns'", ")", ":", "code", "=", "self", ".", "__code__", "for", "name", "in", "code", ".", "co_varnames", "[", ":", "code", ".", "co_argcount", "]", ":", "try", ":", "namevals", "[", "name", "]", "=", "namespace", "[", "name", "]", "except", "KeyError", ":", "pass", "return", "self", ".", "_bindAndExec", "(", "(", ")", ",", "namevals", ",", "namespace", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/Bindings.py#L335-L347
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/Bindings.py
python
Bindings._bindAndExec
(self, args, kw, caller_namespace)
Prepares the bound information and calls _exec(), possibly with a namespace.
Prepares the bound information and calls _exec(), possibly with a namespace.
[ "Prepares", "the", "bound", "information", "and", "calls", "_exec", "()", "possibly", "with", "a", "namespace", "." ]
def _bindAndExec(self, args, kw, caller_namespace): '''Prepares the bound information and calls _exec(), possibly with a namespace. ''' bindcode = getattr(self, '_v_bindcode', _marker) if bindcode is _marker: bindcode = self._prepareBindCode() # Execute the script in a new security context (including the # bindings preparation). security = getSecurityManager() security.addContext(self) try: if bindcode is None: bound_data = {} else: bound_data = [] exec(bindcode) bound_data = bound_data[0] return self._exec(bound_data, args, kw) finally: security.removeContext(self)
[ "def", "_bindAndExec", "(", "self", ",", "args", ",", "kw", ",", "caller_namespace", ")", ":", "bindcode", "=", "getattr", "(", "self", ",", "'_v_bindcode'", ",", "_marker", ")", "if", "bindcode", "is", "_marker", ":", "bindcode", "=", "self", ".", "_prepareBindCode", "(", ")", "# Execute the script in a new security context (including the", "# bindings preparation).", "security", "=", "getSecurityManager", "(", ")", "security", ".", "addContext", "(", "self", ")", "try", ":", "if", "bindcode", "is", "None", ":", "bound_data", "=", "{", "}", "else", ":", "bound_data", "=", "[", "]", "exec", "(", "bindcode", ")", "bound_data", "=", "bound_data", "[", "0", "]", "return", "self", ".", "_exec", "(", "bound_data", ",", "args", ",", "kw", ")", "finally", ":", "security", ".", "removeContext", "(", "self", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/Bindings.py#L351-L372
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/Shared/DC/Scripts/Script.py
python
Script.ZScriptHTML_tryAction
(self, REQUEST, argvars)
Apply the test parameters.
Apply the test parameters.
[ "Apply", "the", "test", "parameters", "." ]
def ZScriptHTML_tryAction(self, REQUEST, argvars): """Apply the test parameters. """ vv = [] for argvar in argvars: if argvar.value: vv.append(f"{quote(argvar.name)}={quote(argvar.value)}") raise Redirect(f"{REQUEST['URL1']}?{'&'.join(vv)}")
[ "def", "ZScriptHTML_tryAction", "(", "self", ",", "REQUEST", ",", "argvars", ")", ":", "vv", "=", "[", "]", "for", "argvar", "in", "argvars", ":", "if", "argvar", ".", "value", ":", "vv", ".", "append", "(", "f\"{quote(argvar.name)}={quote(argvar.value)}\"", ")", "raise", "Redirect", "(", "f\"{REQUEST['URL1']}?{'&'.join(vv)}\"", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/Shared/DC/Scripts/Script.py#L48-L55
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/ObjectManager.py
python
findChildren
(obj, dirname='')
return lst
recursive walk through the object hierarchy to find all children of an object (ajung)
recursive walk through the object hierarchy to find all children of an object (ajung)
[ "recursive", "walk", "through", "the", "object", "hierarchy", "to", "find", "all", "children", "of", "an", "object", "(", "ajung", ")" ]
def findChildren(obj, dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst = [] for name, child in obj.objectItems(): if hasattr(aq_base(child), 'isPrincipiaFolderish') and \ child.isPrincipiaFolderish: lst.extend(findChildren(child, dirname + obj.getId() + '/')) else: lst.append((dirname + obj.getId() + "/" + name, child)) return lst
[ "def", "findChildren", "(", "obj", ",", "dirname", "=", "''", ")", ":", "lst", "=", "[", "]", "for", "name", ",", "child", "in", "obj", ".", "objectItems", "(", ")", ":", "if", "hasattr", "(", "aq_base", "(", "child", ")", ",", "'isPrincipiaFolderish'", ")", "and", "child", ".", "isPrincipiaFolderish", ":", "lst", ".", "extend", "(", "findChildren", "(", "child", ",", "dirname", "+", "obj", ".", "getId", "(", ")", "+", "'/'", ")", ")", "else", ":", "lst", ".", "append", "(", "(", "dirname", "+", "obj", ".", "getId", "(", ")", "+", "\"/\"", "+", "name", ",", "child", ")", ")", "return", "lst" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/ObjectManager.py#L858-L871
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/owner.py
python
Owned.manage_takeOwnership
(self, REQUEST, RESPONSE, recursive=0)
Take ownership (responsibility) for an object. If 'recursive' is true, then also take ownership of all sub-objects.
Take ownership (responsibility) for an object.
[ "Take", "ownership", "(", "responsibility", ")", "for", "an", "object", "." ]
def manage_takeOwnership(self, REQUEST, RESPONSE, recursive=0): """Take ownership (responsibility) for an object. If 'recursive' is true, then also take ownership of all sub-objects. """ security = getSecurityManager() want_referer = REQUEST['URL1'] + '/manage_owner' got_referer = ("%s://%s%s" % parse.urlparse(REQUEST['HTTP_REFERER'])[:3]) __traceback_info__ = want_referer, got_referer if (want_referer != got_referer or security.calledByExecutable()): raise Unauthorized( 'manage_takeOwnership was called from an invalid context') self.changeOwnership(security.getUser(), recursive) if RESPONSE is not None: RESPONSE.redirect(REQUEST['HTTP_REFERER'])
[ "def", "manage_takeOwnership", "(", "self", ",", "REQUEST", ",", "RESPONSE", ",", "recursive", "=", "0", ")", ":", "security", "=", "getSecurityManager", "(", ")", "want_referer", "=", "REQUEST", "[", "'URL1'", "]", "+", "'/manage_owner'", "got_referer", "=", "(", "\"%s://%s%s\"", "%", "parse", ".", "urlparse", "(", "REQUEST", "[", "'HTTP_REFERER'", "]", ")", "[", ":", "3", "]", ")", "__traceback_info__", "=", "want_referer", ",", "got_referer", "if", "(", "want_referer", "!=", "got_referer", "or", "security", ".", "calledByExecutable", "(", ")", ")", ":", "raise", "Unauthorized", "(", "'manage_takeOwnership was called from an invalid context'", ")", "self", ".", "changeOwnership", "(", "security", ".", "getUser", "(", ")", ",", "recursive", ")", "if", "RESPONSE", "is", "not", "None", ":", "RESPONSE", ".", "redirect", "(", "REQUEST", "[", "'HTTP_REFERER'", "]", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/owner.py#L51-L68
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/owner.py
python
Owned.manage_changeOwnershipType
( self, explicit=1, RESPONSE=None, REQUEST=None )
Change the type (implicit or explicit) of ownership.
Change the type (implicit or explicit) of ownership.
[ "Change", "the", "type", "(", "implicit", "or", "explicit", ")", "of", "ownership", "." ]
def manage_changeOwnershipType( self, explicit=1, RESPONSE=None, REQUEST=None ): """Change the type (implicit or explicit) of ownership.""" old = getattr(self, '_owner', None) if explicit: if old is not None: return owner = self.getOwnerTuple() if owner is not None and owner is not UnownableOwner: self._owner = owner else: if old is None: return new = aq_get(aq_parent(self), '_owner', None, 1) _m = object() if old is new and (self.__dict__.get('_owner', _m) is not _m): del self._owner if RESPONSE is not None: RESPONSE.redirect(REQUEST['HTTP_REFERER'])
[ "def", "manage_changeOwnershipType", "(", "self", ",", "explicit", "=", "1", ",", "RESPONSE", "=", "None", ",", "REQUEST", "=", "None", ")", ":", "old", "=", "getattr", "(", "self", ",", "'_owner'", ",", "None", ")", "if", "explicit", ":", "if", "old", "is", "not", "None", ":", "return", "owner", "=", "self", ".", "getOwnerTuple", "(", ")", "if", "owner", "is", "not", "None", "and", "owner", "is", "not", "UnownableOwner", ":", "self", ".", "_owner", "=", "owner", "else", ":", "if", "old", "is", "None", ":", "return", "new", "=", "aq_get", "(", "aq_parent", "(", "self", ")", ",", "'_owner'", ",", "None", ",", "1", ")", "_m", "=", "object", "(", ")", "if", "old", "is", "new", "and", "(", "self", ".", "__dict__", ".", "get", "(", "'_owner'", ",", "_m", ")", "is", "not", "_m", ")", ":", "del", "self", ".", "_owner", "if", "RESPONSE", "is", "not", "None", ":", "RESPONSE", ".", "redirect", "(", "REQUEST", "[", "'HTTP_REFERER'", "]", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/owner.py#L72-L95
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Image.py
python
manage_addFile
( self, id, file=b'', title='', precondition='', content_type='', REQUEST=None )
Add a new File object. Creates a new File object 'id' with the contents of 'file
Add a new File object.
[ "Add", "a", "new", "File", "object", "." ]
def manage_addFile( self, id, file=b'', title='', precondition='', content_type='', REQUEST=None ): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id = str(id) title = str(title) content_type = str(content_type) precondition = str(precondition) id, title = cookId(id, title, file) self = self.this() # First, we create the file without data: self._setObject(id, File(id, title, b'', content_type, precondition)) newFile = self._getOb(id) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. if file: newFile.manage_upload(file) if content_type: newFile.content_type = content_type notify(ObjectCreatedEvent(newFile)) if REQUEST is not None: REQUEST.RESPONSE.redirect(self.absolute_url() + '/manage_main')
[ "def", "manage_addFile", "(", "self", ",", "id", ",", "file", "=", "b''", ",", "title", "=", "''", ",", "precondition", "=", "''", ",", "content_type", "=", "''", ",", "REQUEST", "=", "None", ")", ":", "id", "=", "str", "(", "id", ")", "title", "=", "str", "(", "title", ")", "content_type", "=", "str", "(", "content_type", ")", "precondition", "=", "str", "(", "precondition", ")", "id", ",", "title", "=", "cookId", "(", "id", ",", "title", ",", "file", ")", "self", "=", "self", ".", "this", "(", ")", "# First, we create the file without data:", "self", ".", "_setObject", "(", "id", ",", "File", "(", "id", ",", "title", ",", "b''", ",", "content_type", ",", "precondition", ")", ")", "newFile", "=", "self", ".", "_getOb", "(", "id", ")", "# Now we \"upload\" the data. By doing this in two steps, we", "# can use a database trick to make the upload more efficient.", "if", "file", ":", "newFile", ".", "manage_upload", "(", "file", ")", "if", "content_type", ":", "newFile", ".", "content_type", "=", "content_type", "notify", "(", "ObjectCreatedEvent", "(", "newFile", ")", ")", "if", "REQUEST", "is", "not", "None", ":", "REQUEST", ".", "RESPONSE", ".", "redirect", "(", "self", ".", "absolute_url", "(", ")", "+", "'/manage_main'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Image.py#L58-L95
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Image.py
python
manage_addImage
( self, id, file, title='', precondition='', content_type='', REQUEST=None )
return id
Add a new Image object. Creates a new Image object 'id' with the contents of 'file'.
Add a new Image object.
[ "Add", "a", "new", "Image", "object", "." ]
def manage_addImage( self, id, file, title='', precondition='', content_type='', REQUEST=None ): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id = str(id) title = str(title) content_type = str(content_type) precondition = str(precondition) id, title = cookId(id, title, file) self = self.this() # First, we create the image without data: self._setObject(id, Image(id, title, b'', content_type, precondition)) newFile = self._getOb(id) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. if file: newFile.manage_upload(file) if content_type: newFile.content_type = content_type notify(ObjectCreatedEvent(newFile)) if REQUEST is not None: try: url = self.DestinationURL() except Exception: url = REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
[ "def", "manage_addImage", "(", "self", ",", "id", ",", "file", ",", "title", "=", "''", ",", "precondition", "=", "''", ",", "content_type", "=", "''", ",", "REQUEST", "=", "None", ")", ":", "id", "=", "str", "(", "id", ")", "title", "=", "str", "(", "title", ")", "content_type", "=", "str", "(", "content_type", ")", "precondition", "=", "str", "(", "precondition", ")", "id", ",", "title", "=", "cookId", "(", "id", ",", "title", ",", "file", ")", "self", "=", "self", ".", "this", "(", ")", "# First, we create the image without data:", "self", ".", "_setObject", "(", "id", ",", "Image", "(", "id", ",", "title", ",", "b''", ",", "content_type", ",", "precondition", ")", ")", "newFile", "=", "self", ".", "_getOb", "(", "id", ")", "# Now we \"upload\" the data. By doing this in two steps, we", "# can use a database trick to make the upload more efficient.", "if", "file", ":", "newFile", ".", "manage_upload", "(", "file", ")", "if", "content_type", ":", "newFile", ".", "content_type", "=", "content_type", "notify", "(", "ObjectCreatedEvent", "(", "newFile", ")", ")", "if", "REQUEST", "is", "not", "None", ":", "try", ":", "url", "=", "self", ".", "DestinationURL", "(", ")", "except", "Exception", ":", "url", "=", "REQUEST", "[", "'URL1'", "]", "REQUEST", ".", "RESPONSE", ".", "redirect", "(", "'%s/manage_main'", "%", "url", ")", "return", "id" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Image.py#L734-L777
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Image.py
python
Image.tag
( self, height=None, width=None, alt=None, scale=0, xscale=0, yscale=0, css_class=None, title=None, **args )
return '%s />' % result
Generate an HTML IMG tag for this image, with customization. Arguments to self.tag() can be any valid attributes of an IMG tag. 'src' will always be an absolute pathname, to prevent redundant downloading of images. Defaults are applied intelligently for 'height', 'width', and 'alt'. If specified, the 'scale', 'xscale', and 'yscale' keyword arguments will be used to automatically adjust the output height and width values of the image tag. # Since 'class' is a Python reserved word, it cannot be passed in directly in keyword arguments which is a problem if you are trying to use 'tag()' to include a CSS class. The tag() method will accept a 'css_class' argument that will be converted to 'class' in the output tag to work around this.
Generate an HTML IMG tag for this image, with customization.
[ "Generate", "an", "HTML", "IMG", "tag", "for", "this", "image", "with", "customization", "." ]
def tag( self, height=None, width=None, alt=None, scale=0, xscale=0, yscale=0, css_class=None, title=None, **args ): """Generate an HTML IMG tag for this image, with customization. Arguments to self.tag() can be any valid attributes of an IMG tag. 'src' will always be an absolute pathname, to prevent redundant downloading of images. Defaults are applied intelligently for 'height', 'width', and 'alt'. If specified, the 'scale', 'xscale', and 'yscale' keyword arguments will be used to automatically adjust the output height and width values of the image tag. # Since 'class' is a Python reserved word, it cannot be passed in directly in keyword arguments which is a problem if you are trying to use 'tag()' to include a CSS class. The tag() method will accept a 'css_class' argument that will be converted to 'class' in the output tag to work around this. """ if height is None: height = self.height if width is None: width = self.width # Auto-scaling support xdelta = xscale or scale ydelta = yscale or scale if xdelta and width: width = str(int(round(int(width) * xdelta))) if ydelta and height: height = str(int(round(int(height) * ydelta))) result = '<img src="%s"' % (self.absolute_url()) if alt is None: alt = getattr(self, 'alt', '') result = f'{result} alt="{html.escape(alt, True)}"' if title is None: title = getattr(self, 'title', '') result = f'{result} title="{html.escape(title, True)}"' if height: result = f'{result} height="{height}"' if width: result = f'{result} width="{width}"' if css_class is not None: result = f'{result} class="{css_class}"' for key in list(args.keys()): value = args.get(key) if value: result = f'{result} {key}="{value}"' return '%s />' % result
[ "def", "tag", "(", "self", ",", "height", "=", "None", ",", "width", "=", "None", ",", "alt", "=", "None", ",", "scale", "=", "0", ",", "xscale", "=", "0", ",", "yscale", "=", "0", ",", "css_class", "=", "None", ",", "title", "=", "None", ",", "*", "*", "args", ")", ":", "if", "height", "is", "None", ":", "height", "=", "self", ".", "height", "if", "width", "is", "None", ":", "width", "=", "self", ".", "width", "# Auto-scaling support", "xdelta", "=", "xscale", "or", "scale", "ydelta", "=", "yscale", "or", "scale", "if", "xdelta", "and", "width", ":", "width", "=", "str", "(", "int", "(", "round", "(", "int", "(", "width", ")", "*", "xdelta", ")", ")", ")", "if", "ydelta", "and", "height", ":", "height", "=", "str", "(", "int", "(", "round", "(", "int", "(", "height", ")", "*", "ydelta", ")", ")", ")", "result", "=", "'<img src=\"%s\"'", "%", "(", "self", ".", "absolute_url", "(", ")", ")", "if", "alt", "is", "None", ":", "alt", "=", "getattr", "(", "self", ",", "'alt'", ",", "''", ")", "result", "=", "f'{result} alt=\"{html.escape(alt, True)}\"'", "if", "title", "is", "None", ":", "title", "=", "getattr", "(", "self", ",", "'title'", ",", "''", ")", "result", "=", "f'{result} title=\"{html.escape(title, True)}\"'", "if", "height", ":", "result", "=", "f'{result} height=\"{height}\"'", "if", "width", ":", "result", "=", "f'{result} width=\"{width}\"'", "if", "css_class", "is", "not", "None", ":", "result", "=", "f'{result} class=\"{css_class}\"'", "for", "key", "in", "list", "(", "args", ".", "keys", "(", ")", ")", ":", "value", "=", "args", ".", "get", "(", "key", ")", "if", "value", ":", "result", "=", "f'{result} {key}=\"{value}\"'", "return", "'%s />'", "%", "result" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Image.py#L931-L996
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/History.py
python
Historian.manage_workspace
(self, REQUEST)
We aren't real, so we delegate to that that spawned us!
We aren't real, so we delegate to that that spawned us!
[ "We", "aren", "t", "real", "so", "we", "delegate", "to", "that", "that", "spawned", "us!" ]
def manage_workspace(self, REQUEST): """ We aren't real, so we delegate to that that spawned us! """ raise Redirect('/%s/manage_change_history_page' % REQUEST['URL2'])
[ "def", "manage_workspace", "(", "self", ",", "REQUEST", ")", ":", "raise", "Redirect", "(", "'/%s/manage_change_history_page'", "%", "REQUEST", "[", "'URL2'", "]", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/History.py#L89-L91
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/History.py
python
Historical.manage_historyCopy
(self, keys=[], RESPONSE=None, URL1=None)
Copy a selected revision to the present
Copy a selected revision to the present
[ "Copy", "a", "selected", "revision", "to", "the", "present" ]
def manage_historyCopy(self, keys=[], RESPONSE=None, URL1=None): """ Copy a selected revision to the present """ if not keys: raise HistorySelectionError('No historical revision selected.') if len(keys) > 1: raise HistorySelectionError( 'Only one historical revision can be copied to the present.') key = keys[0] serial = pack(*('>HHHH',) + tuple(map(int, key.split('.')))) if serial != self._p_serial: self.manage_beforeHistoryCopy() state = self._p_jar.oldstate(self, serial) base = aq_base(self) base._p_activate() # make sure we're not a ghost base.__setstate__(state) # change the state base._p_changed = True # marke object as dirty self.manage_afterHistoryCopy() if RESPONSE is not None and URL1 is not None: RESPONSE.redirect('%s/manage_workspace' % URL1)
[ "def", "manage_historyCopy", "(", "self", ",", "keys", "=", "[", "]", ",", "RESPONSE", "=", "None", ",", "URL1", "=", "None", ")", ":", "if", "not", "keys", ":", "raise", "HistorySelectionError", "(", "'No historical revision selected.'", ")", "if", "len", "(", "keys", ")", ">", "1", ":", "raise", "HistorySelectionError", "(", "'Only one historical revision can be copied to the present.'", ")", "key", "=", "keys", "[", "0", "]", "serial", "=", "pack", "(", "*", "(", "'>HHHH'", ",", ")", "+", "tuple", "(", "map", "(", "int", ",", "key", ".", "split", "(", "'.'", ")", ")", ")", ")", "if", "serial", "!=", "self", ".", "_p_serial", ":", "self", ".", "manage_beforeHistoryCopy", "(", ")", "state", "=", "self", ".", "_p_jar", ".", "oldstate", "(", "self", ",", "serial", ")", "base", "=", "aq_base", "(", "self", ")", "base", ".", "_p_activate", "(", ")", "# make sure we're not a ghost", "base", ".", "__setstate__", "(", "state", ")", "# change the state", "base", ".", "_p_changed", "=", "True", "# marke object as dirty", "self", ".", "manage_afterHistoryCopy", "(", ")", "if", "RESPONSE", "is", "not", "None", "and", "URL1", "is", "not", "None", ":", "RESPONSE", ".", "redirect", "(", "'%s/manage_workspace'", "%", "URL1", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/History.py#L142-L164
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/History.py
python
Historical.manage_historicalComparison
(self, REQUEST, keys=[])
return self.manage_historyCompare(rev1, rev2, REQUEST)
Compare two selected revisions
Compare two selected revisions
[ "Compare", "two", "selected", "revisions" ]
def manage_historicalComparison(self, REQUEST, keys=[]): """ Compare two selected revisions """ if not keys: raise HistorySelectionError('No historical revision selected.') if len(keys) > 2: raise HistorySelectionError( 'Only two historical revision can be compared.') serial = pack(*('>HHHH',) + tuple(map(int, keys[-1].split('.')))) rev1 = historicalRevision(self, serial) if len(keys) == 2: serial = pack(*('>HHHH',) + tuple(map(int, keys[0].split('.')))) rev2 = historicalRevision(self, serial) else: rev2 = self return self.manage_historyCompare(rev1, rev2, REQUEST)
[ "def", "manage_historicalComparison", "(", "self", ",", "REQUEST", ",", "keys", "=", "[", "]", ")", ":", "if", "not", "keys", ":", "raise", "HistorySelectionError", "(", "'No historical revision selected.'", ")", "if", "len", "(", "keys", ")", ">", "2", ":", "raise", "HistorySelectionError", "(", "'Only two historical revision can be compared.'", ")", "serial", "=", "pack", "(", "*", "(", "'>HHHH'", ",", ")", "+", "tuple", "(", "map", "(", "int", ",", "keys", "[", "-", "1", "]", ".", "split", "(", "'.'", ")", ")", ")", ")", "rev1", "=", "historicalRevision", "(", "self", ",", "serial", ")", "if", "len", "(", "keys", ")", "==", "2", ":", "serial", "=", "pack", "(", "*", "(", "'>HHHH'", ",", ")", "+", "tuple", "(", "map", "(", "int", ",", "keys", "[", "0", "]", ".", "split", "(", "'.'", ")", ")", ")", ")", "rev2", "=", "historicalRevision", "(", "self", ",", "serial", ")", "else", ":", "rev2", "=", "self", "return", "self", ".", "manage_historyCompare", "(", "rev1", ",", "rev2", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/History.py#L183-L200
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/interfaces.py
python
IOrderedContainer.moveObjectsByDelta
(ids, delta, subset_ids=None)
Move specified sub-objects by delta. If delta is higher than the possible maximum, objects will be moved to the bottom. If delta is lower than the possible minimum, objects will be moved to the top. If subset_ids is not None, delta will be interpreted relative to the subset specified by a sequence of ids. The position of objects that are not part of this subset will not be changed. The order of the objects specified by ids will always be preserved. So if you don't want to change their original order, make sure the order of ids corresponds to their original order. If an object with id doesn't exist an error will be raised. Permission -- Manage properties Returns -- Number of moved sub-objects
Move specified sub-objects by delta.
[ "Move", "specified", "sub", "-", "objects", "by", "delta", "." ]
def moveObjectsByDelta(ids, delta, subset_ids=None): """ Move specified sub-objects by delta. If delta is higher than the possible maximum, objects will be moved to the bottom. If delta is lower than the possible minimum, objects will be moved to the top. If subset_ids is not None, delta will be interpreted relative to the subset specified by a sequence of ids. The position of objects that are not part of this subset will not be changed. The order of the objects specified by ids will always be preserved. So if you don't want to change their original order, make sure the order of ids corresponds to their original order. If an object with id doesn't exist an error will be raised. Permission -- Manage properties Returns -- Number of moved sub-objects """
[ "def", "moveObjectsByDelta", "(", "ids", ",", "delta", ",", "subset_ids", "=", "None", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/interfaces.py#L40-L60