/usr/lib/python2.7/dist-packages/zmq/sugar/constants.py is in python-zmq 14.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | """0MQ Constants."""
# Copyright (c) PyZMQ Developers.
# Distributed under the terms of the Modified BSD License.
from zmq.backend import constants
from zmq.utils.constant_names import (
base_names,
switched_sockopt_names,
int_sockopt_names,
int64_sockopt_names,
bytes_sockopt_names,
fd_sockopt_names,
ctx_opt_names,
msg_opt_names,
)
#-----------------------------------------------------------------------------
# Python module level constants
#-----------------------------------------------------------------------------
__all__ = [
'int_sockopts',
'int64_sockopts',
'bytes_sockopts',
'ctx_opts',
'ctx_opt_names',
]
int_sockopts = set()
int64_sockopts = set()
bytes_sockopts = set()
fd_sockopts = set()
ctx_opts = set()
msg_opts = set()
if constants.VERSION < 30000:
int64_sockopt_names.extend(switched_sockopt_names)
else:
int_sockopt_names.extend(switched_sockopt_names)
_UNDEFINED = -9999
def _add_constant(name, container=None):
"""add a constant to be defined
optionally add it to one of the sets for use in get/setopt checkers
"""
c = getattr(constants, name, _UNDEFINED)
if c == _UNDEFINED:
return
globals()[name] = c
__all__.append(name)
if container is not None:
container.add(c)
return c
for name in base_names:
_add_constant(name)
for name in int_sockopt_names:
_add_constant(name, int_sockopts)
for name in int64_sockopt_names:
_add_constant(name, int64_sockopts)
for name in bytes_sockopt_names:
_add_constant(name, bytes_sockopts)
for name in fd_sockopt_names:
_add_constant(name, fd_sockopts)
for name in ctx_opt_names:
_add_constant(name, ctx_opts)
for name in msg_opt_names:
_add_constant(name, msg_opts)
# ensure some aliases are always defined
aliases = [
('DONTWAIT', 'NOBLOCK'),
('XREQ', 'DEALER'),
('XREP', 'ROUTER'),
]
for group in aliases:
undefined = set()
found = None
for name in group:
value = getattr(constants, name, -1)
if value != -1:
found = value
else:
undefined.add(name)
if found is not None:
for name in undefined:
globals()[name] = found
__all__.append(name)
|