function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self, columns): self.columns = columns self.pretty_tbl_cols = ["Table", "Column Name", "Type"] self.use_schema = False for col in columns: if col.schema and not self.use_schema: self.use_schema = True self.pretty_tbl_cols.insert(0...
yhat/db.py
[ 1220, 116, 1220, 33, 1414337817 ]
def _tablify(self): tbl = PrettyTable(self.pretty_tbl_cols) for col in self.pretty_tbl_cols: tbl.align[col] = "l" for col in self.columns: row_data = [col.table, col.name, col.type] if self.use_schema: row_data.insert(0, col.schema) ...
yhat/db.py
[ 1220, 116, 1220, 33, 1414337817 ]
def _repr_html_(self): return self._tablify().get_html_string()
yhat/db.py
[ 1220, 116, 1220, 33, 1414337817 ]
def cmp(x, y): if x<y: return -1 if x>y: return 1 return 0
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def describe_filter_method(filter_by): if callable(filter_by): return "matching a function called {}".format(filter_by.__name__) if isinstance(filter_by, six.string_types): return "containing the string {!r}".format(filter_by) if have_ham and isinstance(filter_by, hamcres...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __init__(self, value, x, y, table, properties=None): self.value = value # of appropriate type self.x = x # column number self.y = y # row number self.table = table if properties is None: self.properties = {} else: self.properties = propertie...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __eq__(self, rhs): """See _XYCell.__hash__ for equality conditions""" return hash(self) == hash(rhs)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __repr__(self): return "_XYCell(%r, %r, %r)" % \ (self.value, self.x, self.y)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def lookup(self, header_bag, direction, strict=False): """ Given a single cell (usually a value), a bag containing the headers of a particular type for that cell, and the direction in which to search for the relevant header e.g. for value cell V, searching up: [ ] ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def junction_coord(cells, direction=DOWN): """ Under the hood: given two cells and a favoured direction, get the position of the cell with the column of one and the row of the other: A---->+ | ^ | | | | ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def shift(self, x=0, y=0): """Get the cell which is offset from this cell by x columns, y rows""" if not isinstance(x, int): assert y == 0, \ "_XYCell.shift: x=%r not integer and y=%r specified" % (x, y) return self.shift(x[0], x[1]) return self.table.get_...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def pprint(self, *args, **kwargs): return contrib_excel.pprint(self, *args, **kwargs)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def filter_one(self, filter_by): return contrib_excel.filter_one(self, filter_by)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __init__(self, table): self.__store = set() self.table = table
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __eq__(self, other): """Compare two bags: they are equal if: * their table are the same table (object) * they contain the same set of cells""" if not isinstance(other, CoreBag): return False return (self.table is other.table and self.__store ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __repr__(self): return repr(self.__store)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def singleton(cls, cell, table): """ Construct a bag with one cell in it """ bag = cls(table=table) bag.add(cell) return bag
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def unordered(self): """ Obtain an unordered iterator over this bag. iter(bag) is sorted on demand, and therefore inefficient if being done repeatedly where order does not matter. """ return (Bag.singleton(c, table=self.table) for c in self.__store)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def unordered_cells(self): """ Analogous to the `unordered` property, except that it returns _XYCells instead of Bags. """ return iter(self.__store)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def yx(cell): return cell.y, cell.x
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __sub__(self, rhs): """Bags quack like sets. Implements - operator.""" return self.difference(rhs)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __or__(self, rhs): """Bags quack like sets. Implements | operator. For mathematical purity, + (__add__) isn't appropriate""" return self.union(rhs)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __and__(self, rhs): return self.intersection(rhs)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def select(self, function): """Select cells from this bag's table based on the cells in this bag. e.g. bag.select(lambda bag_cell, table_cell: bag_cell.y == table_cell.y and bag_cell.value == table_cell.value) would give cells in the table with the same name o...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def filter(self, filter_by): """ Returns a new bag containing only cells which match the filter_by predicate. filter_by can be: a) a callable, which takes a cell as a parameter and returns True if the cell should be returned, such as `lambda cell: cell valu...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def assert_one(self, message="assert_one() : {} cells in bag, not 1"): """Chainable: raise an error if the bag contains 0 or 2+ cells. Otherwise returns the original (singleton) bag unchanged.""" if len(self.__store) == 1: return self elif len(self.__store) == 0: ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def _cell(self): """Under the hood: get the cell inside a singleton bag. It's an error for it to not contain precisely one cell.""" try: xycell = list(self.assert_one().__store)[0] except AssertionError: l = len(list(self.__store)) raise XYPathError...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def value(self): """Getter for singleton's cell value""" return self._cell.value
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def x(self): """Getter for singleton's cell column number""" return self._cell.x
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def y(self): """Getter for singleton's cell row number""" return self._cell.y
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def properties(self): """Getter for singleton's cell properties""" return self._cell.properties
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def from_list(cells): """ Make a non-bag iterable of cells into a Bag. Some magic may be lost, especially if it's zero length. TODO: This should probably be part of the core __init__ class. TODO: Don't do a piece-by-piece insertion, just slap the whole listed iterab...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def fill(self, direction, stop_before=None): """Should give the same output as fill, except it doesn't support non-cardinal directions or stop_before. Twenty times faster than fill in test_ravel.""" if direction in (UP_RIGHT, DOWN_RIGHT, UP_LEFT, U...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def _fill(self, direction, stop_before=None): """ If the bag contains only one cell, select all cells in the direction given, excluding the original cell. For example, from a column heading cell, you can "fill down" to get all the values underneath it. If you provide a stop_befo...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def waffle(self, other, *args, **kwargs): bag = Bag(table=self.table) for (selfbag, otherbag, junction_cell) in self.junction(other, *args, **kwargs): bag.add(junction_cell._cell) return bag
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def extrude(self, dx, dy): """ Extrude all cells in the bag by (dx, dy), by looking For example, given the bag with a cell at (0, 0): {(0, 0)} .extrude(2, 0) gives the bag with the cells (to the right): {(0, 0), (1, 0), (2, 0)} .extrude(0, -2) gives t...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def same_col(self, bag): """ Select cells in this bag which are in the same row as a cell in the other `bag`. """ # TODO: make less crap all_x = set() for cell in bag.unordered_cells: all_x.add(cell.x) return self.filter(lambda c: c.x in all_x)
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def __init__(self, name=""): super(Table, self).__init__(table=self) self._x_index = defaultdict(lambda: Bag(self)) self._y_index = defaultdict(lambda: Bag(self)) self._max_x = -1 self._max_y = -1 self.sheet = None self.name = name
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def rows(self): """Get bags containing each row's cells, in order""" for row_num in range(0, self._max_y + 1): # inclusive yield self._y_index[row_num]
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def col(self, column): if isinstance(column, six.string_types): c_num = contrib_excel.excel_column_number(column, index=0) return self.col(c_num) else: assert isinstance(column, int) return self._x_index[column]
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def get_at(self, x=None, y=None): """Directly get a singleton bag via indices. Faster than Bag.filter""" # we use .get() here to avoid new empty Bags being inserted # into the index stores when a non-existant coordinate is requested. assert isinstance(x, int) or x is None, "get_at takes ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def from_filename(filename, table_name=None, table_index=None): """Wrapper around from_file_object to handle extension extraction""" # NOTE: this is a messytables table name extension = os.path.splitext(filename)[1].strip('.') with open(filename, 'rb') as f: return Table.from...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def from_file_object(fobj, extension='', table_name=None, table_index=None): """Load table from file object, you must specify a table's name or position number. If you don't know these, try from_messy.""" # NOTE this is a messytables table name if (table_name ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def from_messy(messy_rowset): """Import a rowset (table) from messytables, e.g. to work with each table in turn: tables = messytables.any.any_tableset(fobj) for mt_table in tables: xy_table = xypath.Table.from_messy(mt_table) ...""" ...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def from_iterable(table, value_func=lambda cell: cell, properties_func=lambda cell: {}, name=None): """Make a table from a pythonic table structure. The table must be an iterable which returns rows (in top-to-bottom order), which in turn are iter...
scraperwiki/xypath
[ 44, 6, 44, 8, 1369323312 ]
def _environ_path(name): """Split an environment variable into a path-like list elements""" if name in os.environ: return os.environ[name].split(":") return []
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def __init__(self, path): super(LibraryLoader.Lookup, self).__init__() self.access = dict(cdecl=ctypes.CDLL(path, self.mode))
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def has(self, name, calling_convention="cdecl"): """Return True if this given calling convention finds the given 'name'""" if calling_convention not in self.access: return False return hasattr(self.access[calling_convention], name)
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def __init__(self): self.other_dirs = []
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def getpaths(self, libname): """Return a list of paths where the library might be found.""" if os.path.isabs(libname): yield libname else: # search through a prioritized series of locations for the library # we first search any specific directories identified...
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def getplatformpaths(self, libname): if os.path.pathsep in libname: names = [libname] else: names = [fmt % libname for fmt in self.name_formats] for directory in self.getdirs(libname): for name in names: yield os.path.join(directory, name)
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def getdirs(libname): """Implements the dylib search as specified in Apple documentation: http://developer.apple.com/documentation/DeveloperTools/Conceptual/ DynamicLibraries/Articles/DynamicLibraryUsageGuidelines.html Before commencing the standard search, the method first checks ...
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def __init__(self): dict.__init__(self) self.order = 0
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def extend(self, directories): """Add a list of directories to our set""" for a_dir in directories: self.add(a_dir)
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def _get_ld_so_conf_dirs(self, conf, dirs): """ Recursive function to help parse all ld.so.conf files, including proper handling of the `include` directive. """ try: with open(conf) as fileobj: for dirname in fileobj: dirname = dir...
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def getplatformpaths(self, libname): if self._ld_so_cache is None: self._create_ld_so_cache() result = self._ld_so_cache.get(libname, set()) for i in result: # we iterate through all found paths for library, since we may have # actually found multiple archite...
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def __init__(self, path): super(WindowsLibraryLoader.Lookup, self).__init__(path) self.access["stdcall"] = ctypes.windll.LoadLibrary(path)
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def add_library_search_dirs(other_dirs): """ Add libraries to search paths. If library paths are relative, convert them to absolute with respect to this file's directory """ for path in other_dirs: if not os.path.isabs(path): path = os.path.abspath(path) load_library....
davidjamesca/ctypesgen
[ 236, 74, 236, 23, 1426209562 ]
def parse_flow(flow_line): tmp = flow_line.split() if flow_line.find(':') > 0 and len(tmp) > 8: # IPv6 layout return { 'BKT':tmp[0], 'Prot':tmp[1], 'flowid':tmp[2], 'Source':tmp[3], 'Destination':tmp[4], 'pkt':int(tmp[5]) if...
opnsense/core
[ 2303, 592, 2303, 176, 1418485430 ]
def trim_dict(payload): for key in payload: if type(payload[key]) == str: payload[key] = payload[key].strip() elif type(payload[key]) == dict: trim_dict(payload[key]) return payload
opnsense/core
[ 2303, 592, 2303, 176, 1418485430 ]
def parse_ipfw_queues(): result = dict() queuetxt = subprocess.run(['/sbin/ipfw', 'queue', 'show'], capture_output=True, text=True).stdout.strip() current_queue = None current_queue_header = False for line in ("%s\nq000000X" % queuetxt).split('\n'): if len(line) == 0: continue ...
opnsense/core
[ 2303, 592, 2303, 176, 1418485430 ]
def iter_lamps(acad, objects): for obj in acad.iter_objects(('MText', 'MLeader'), block=objects): try: text = obj.TextString except Exception: continue text = utils.unformat_mtext(text) m = re.search(ur'(?P<num>\d+)(?P<mark>.*?)\\S(?P<num_power>.*?)/.*?...
reclosedev/pyautocad
[ 375, 132, 375, 36, 1338625206 ]
def main(): acad = Autocad() objects = None if 'i' in sys.argv[1:]: objects = acad.get_selection('Select objects') lamps = defaultdict(int) for lamp in iter_lamps(acad, objects): lamps[lamp.mark] += int(lamp.number) print '-' * 79 for mark, number in sorted(lamps.ite...
reclosedev/pyautocad
[ 375, 132, 375, 36, 1338625206 ]
def __init__(self, actions, historystorage, modelstorage, delta=0.1, p_min=None, max_rounds=10000): super(Exp4P, self).__init__(historystorage, modelstorage, actions) self.n_total = 0 # number of actions (i.e. K in the paper) self.n_actions = len(self._actions) s...
ntucllab/striatum
[ 104, 35, 104, 11, 1462947998 ]
def get_action(self, context=None, n_actions=1): """Return the action to perform Parameters ---------- context : dictionary Contexts {expert_id: {action_id: expert_prediction}} of different actions. n_actions: int Number of actions wanted to ...
ntucllab/striatum
[ 104, 35, 104, 11, 1462947998 ]
def get_max_datagram_size(): #TODO return 1024
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def __init__(self, port=0): """ ctor """ self.port = port self.buff_size = get_max_datagram_size()
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def init_server(self): """ Initialize and start the server thread, if not already initialized. """ if self.server is not None: return if rosgraph.network.use_ipv6(): s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) else: s = socket...
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def shutdown(self): if self.sock is not None: self.sock.close()
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def supports(self, protocol): """ @param protocol: name of protocol @type protocol: str @return: True if protocol is supported @rtype: bool """ return protocol == UDPROS
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def get_supported(self): """ Get supported protocols """ return [[UDPROS]]
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def init_publisher(self, topic_name, protocol_params): """ Initialize this node to start publishing to a new UDP location.
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def topic_connection_handler(self, sock, client_addr, header): """ Process incoming topic connection. Reads in topic name from handshake and creates the appropriate L{TCPROSPub} handler for the connection. @param sock: socket connection @type sock: socket.socket @...
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def __init__(self, protocol, name, header): """ ctor @param name: topic name @type name: str: @param protocol: protocol implementation @param protocol: UDPROSTransportProtocol @param header: handshake header if transport handshake header was alre...
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def send_message(self, msg, seq): """ Convenience routine for services to send a message across a particular connection. NOTE: write_data is much more efficient if same message is being sent to multiple connections. Not threadsafe. @param msg: message to send @typ...
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def receive_once(self): """ block until messages are read off of socket @return: list of newly received messages @rtype: [Msg] @raise TransportException: if unable to receive message due to error """ pass
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def receive_loop(self, msgs_callback): pass
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def close(super): self(UDPROSTransport, self).close() #TODO self.done = True
MangoMangoDevelopment/neptune
[ 8, 4, 8, 2, 1454524069 ]
def __init__(self, connection, queue=None, exchange=None, routing_key=None, **kwargs): self.connection = connection self.backend = kwargs.get("backend", None) if not self.backend: self.backend = self.connection.create_backend() self.queue = queue or self.queue ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __exit__(self, e_type, e_value, e_trace): if e_type: raise e_type(e_value) self.close()
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def _generate_consumer_tag(self): """Generate a unique consumer tag. :rtype string: """ return "%s.%s%s" % ( self.__class__.__module__, self.__class__.__name__, self._next_consumer_tag())
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def _receive_callback(self, raw_message): """Internal method used when a message is received in consume mode.""" message = self.backend.message_to_python(raw_message) if self.auto_ack and not message.acknowledged: message.ack() self.receive(message.payload, message)
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def process_next(self): """**DEPRECATED** Use :meth:`fetch` like this instead: >>> message = self.fetch(enable_callbacks=True) """ warnings.warn(DeprecationWarning( "Consumer.process_next has been deprecated in favor of \ Consumer.fetch(enable_callbacks=True...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def register_callback(self, callback): """Register a callback function to be triggered by :meth:`receive`. The ``callback`` function must take two arguments: * message_data The deserialized message data * message The :class:`carrot.backends.ba...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def discard_all(self, filterfunc=None): """Discard all waiting messages. :param filterfunc: A filter function to only discard the messages this filter returns. :returns: the number of messages discarded. *WARNING*: All incoming messages will be ignored and not processed. ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def consume(self, no_ack=None): """Declare consumer.""" no_ack = no_ack or self.no_ack self.backend.declare_consumer(queue=self.queue, no_ack=no_ack, callback=self._receive_callback, consumer_tag=self.consumer_tag, ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def iterqueue(self, limit=None, infinite=False): """Infinite iterator yielding pending messages, by using synchronous direct access to the queue (``basic_get``). :meth:`iterqueue` is used where synchronous functionality is more important than performance. If you can, use :meth:`itercons...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def close(self): """Close the channel to the queue.""" self.cancel() self.backend.close() self._closed = True
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def qos(self, prefetch_size=0, prefetch_count=0, apply_global=False): """Request specific Quality of Service. This method requests a specific quality of service. The QoS can be specified for the current channel or for all channels on the connection. The particular properties and seman...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __init__(self, connection, exchange=None, routing_key=None, **kwargs): self.connection = connection self.backend = self.connection.create_backend() self.exchange = exchange or self.exchange self.routing_key = routing_key or self.routing_key for opt_name in self._init_opts: ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __enter__(self): return self
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def create_message(self, message_data, delivery_mode=None, priority=None, content_type=None, content_encoding=None, serializer=None): """With any data, serialize it and encapsulate it in a AMQP message with the proper headers set.""" delivery_mode =...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def close(self): """Close connection to queue.""" self.backend.close() self._closed = True
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __init__(self, connection, **kwargs): self.connection = connection self.exchange = kwargs.get("exchange", self.exchange) self.queue = kwargs.get("queue", self.queue) self.routing_key = kwargs.get("routing_key", self.routing_key) self.publisher = self.publisher_cls(connection,...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __exit__(self, e_type, e_value, e_trace): if e_type: raise e_type(e_value) self.close()
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def receive(self, message_data, message): """See :meth:`Consumer.receive`""" if not self.callbacks: raise NotImplementedError("No consumer callbacks registered") for callback in self.callbacks: callback(message_data, message)
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def fetch(self, **kwargs): """See :meth:`Consumer.fetch`""" return self.consumer.fetch(**kwargs)
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def __init__(self, connection, from_dict=None, consumers=None, callbacks=None, **options): self.connection = connection self.options = options self.from_dict = from_dict or {} self.consumers = [] self.callbacks = callbacks or [] self._open_consumers = {} ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def add_consumer_from_dict(self, queue, **options): """Add another consumer from dictionary configuration.""" options.setdefault("routing_key", options.pop("binding_key", None)) consumer = Consumer(self.connection, queue=queue, backend=self.backend, **options) ...
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]
def register_callback(self, callback): """Register new callback to be called when a message is received. See :meth:`Consumer.register_callback`""" self.callbacks.append(callback)
ask/carrot
[ 196, 34, 196, 12, 1237911887 ]