本文整理匯總了Python中operator.ior方法的典型用法代碼示例。如果您正苦於以下問題:Python operator.ior方法的具體用法?Python operator.ior怎麽用?Python operator.ior使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類operator
的用法示例。
在下文中一共展示了operator.ior方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testIOr
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def testIOr(self):
self.augmentedAssignCheck(operator.ior)
示例2: delete
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def delete(self, session_id, data_keys, devices=None, _tell=False):
if not devices:
devices = functools.reduce(
operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set())
else:
devices = self._normalize_devices(devices)
devices = self._normalize_devices(devices)
for dev_type in devices:
handler = self.get_storage_handler(dev_type)
handler.delete(session_id, data_keys, _tell=_tell)
示例3: pin_data_keys
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def pin_data_keys(self, session_id, data_keys, token, devices=None):
if not devices:
devices = functools.reduce(
operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set())
else:
devices = self._normalize_devices(devices)
pinned = set()
for dev in devices:
handler = self.get_storage_handler(dev)
if not getattr(handler, '_spillable', False):
continue
keys = handler.pin_data_keys(session_id, data_keys, token)
pinned.update(keys)
return list(pinned)
示例4: unpin_data_keys
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def unpin_data_keys(self, session_id, data_keys, token, devices=None):
if not devices:
devices = functools.reduce(
operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set())
else:
devices = self._normalize_devices(devices)
for dev in devices:
handler = self.get_storage_handler(dev)
if not getattr(handler, '_spillable', False):
continue
handler.unpin_data_keys(session_id, data_keys, token)
示例5: get_ins_mask
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def get_ins_mask(self, instructions):
return reduce(ior, instructions)
示例6: get_iregex_filter
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def get_iregex_filter(expression, *fields, mapping=None, logger=None, values=None):
ret = Q()
for dis in expression.split(' || '):
cond = Q()
for con in dis.split(' && '):
r = con.strip()
fs = fields
suff = '__iregex'
if ':' in r and mapping:
k, v = r.split(':', 1)
if k in mapping:
mapped = mapping[k]
try:
fs = mapped['fields']
r = mapped['func'](v) if 'func' in mapped else v
suff = mapped.get('suff', '')
if callable(suff):
suff = suff(r)
except Exception as e:
if logger:
logger.error(f'Field "{k}" has error: {e}')
continue
if values is not None:
values.setdefault(k, []).append(r)
if isinstance(r, str):
r = verify_regex(r, logger=logger)
cond &= functools.reduce(operator.ior, (Q(**{f'{field}{suff}': r}) for field in fs))
ret |= cond
return ret
示例7: test_ior_array
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def test_ior_array(self):
self.check_array_array_op(operator.ior)
示例8: test_broadcasted_ior
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def test_broadcasted_ior(self):
self.check_array_broadcasted_op(operator.ior)
示例9: object_hook
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def object_hook(obj):
_isoformat = obj.get('_isoformat')
if _isoformat is not None:
return datetime.datetime.fromisoformat(_isoformat)
_bytes = obj.get('_bytes')
if _bytes is not None:
return bytes.fromhex(_bytes)
_enum = obj.get('_enum')
if _enum is not None:
cls, flags = _enum.split('.')
flags = map(lambda i: RouterFlags[i], flags.split('|'))
return reduce(ior, flags)
return obj
示例10: __init__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def __init__(self, hass, device, endpoint):
"""Initialize the light."""
self._device = device
self._endpoint = endpoint
self._is_on = False
self._brightness = 0
a = self._device.get_attribute(endpoint, 6, 0)
if a:
self._is_on = a.get('value', False)
ieee = device.ieee or device.addr # compatibility
entity_id = 'zigate_{}_{}'.format(ieee,
endpoint)
self.entity_id = ENTITY_ID_FORMAT.format(entity_id)
import zigate
supported_features = set()
supported_features.add(SUPPORT_TRANSITION)
for action_type in device.available_actions(endpoint)[endpoint]:
if action_type == zigate.ACTIONS_LEVEL:
supported_features.add(SUPPORT_BRIGHTNESS)
elif action_type == zigate.ACTIONS_COLOR:
supported_features.add(SUPPORT_COLOR)
elif action_type == zigate.ACTIONS_TEMPERATURE:
supported_features.add(SUPPORT_COLOR_TEMP)
elif action_type == zigate.ACTIONS_HUE:
supported_features.add(SUPPORT_HUE_COLOR)
self._supported_features = reduce(ior, supported_features)
hass.bus.listen('zigate.attribute_updated', self._handle_event)
示例11: test_update_operator
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def test_update_operator(self): # test |= operator
self.assertSingleValueOperator(lambda s, o: operator.ior(s, o))
self.assertMultipleValuesOperator(
lambda s, o: operator.ior(s, functools.reduce(operator.ior, [t.copy() for t in o])))
示例12: __ior__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def __ior__(self, other):
return Expression((self, other), operator.ior)
示例13: _get_reduce_op
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def _get_reduce_op(self, reduce_nodes):
require(len(reduce_nodes) == 2)
require(isinstance(reduce_nodes[0], ir.Assign))
require(isinstance(reduce_nodes[1], ir.Assign))
require(isinstance(reduce_nodes[0].value, ir.Expr))
require(isinstance(reduce_nodes[1].value, ir.Var))
rhs = reduce_nodes[0].value
if rhs.op == 'inplace_binop':
if rhs.fn in ('+=', operator.iadd):
return Reduce_Type.Sum
if rhs.fn in ('|=', operator.ior):
return Reduce_Type.Or
if rhs.fn in ('*=', operator.imul):
return Reduce_Type.Prod
if rhs.op == 'call':
func = find_callname(self.state.func_ir, rhs, self.state.typemap)
if func == ('min', 'builtins'):
if isinstance(self.state.typemap[rhs.args[0].name], numba.core.typing.builtins.IndexValueType):
return Reduce_Type.Argmin
return Reduce_Type.Min
if func == ('max', 'builtins'):
if isinstance(self.state.typemap[rhs.args[0].name], numba.core.typing.builtins.IndexValueType):
return Reduce_Type.Argmax
return Reduce_Type.Max
raise GuardException # pragma: no cover
示例14: __ior__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def __ior__(self, other):
return operator.ior(self._wrapped(), other)
示例15: _ior
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ior [as 別名]
def _ior(self, bs):
return self._inplace_logical_helper(bs, operator.ior)