def parse_subscribe_destination(entity): """ Parse subscribe destination. """ entity = entity.encode() destination = dict() destination["original"] = entity if entity.startswith("/queue/"): destination["exchange"] = {"name": ""} destination["queue"] = { "name": entity[7:], "durable": True, "exclusive": False, "auto_delete": False } elif entity.startswith("/topic/"): destination["routing_key"] = entity[7:] destination["exchange"] = {"name": "amq.topic"} destination["queue"] = { "durable": False, "auto_delete": True, "exclusive": True } else: for element in _SEP_CHARS.split(entity): if not element: continue (key, val) = element.split("=") if _SUBSCRIBE_DEST_RECURSIVE.match(key): val = parse_sender_destination(unquote(val)) elif val == "false": val = False elif val == "true": val = True destination[key] = val return destination
def parse_subscribe_destination(entity): """ Parse subscribe destination. """ entity = entity.encode() destination = dict() destination["original"] = entity if entity.startswith("/queue/"): destination["exchange"] = {"name": ""} destination["queue"] = {"name": entity[7:], "durable": True, "exclusive": False, "auto_delete": False} elif entity.startswith("/topic/"): destination["routing_key"] = entity[7:] destination["exchange"] = {"name": "amq.topic"} destination["queue"] = {"durable": False, "auto_delete": True, "exclusive": True} else: for element in _SEP_CHARS.split(entity): if not element: continue (key, val) = element.split("=") if _SUBSCRIBE_DEST_RECURSIVE.match(key): val = parse_sender_destination(unquote(val)) elif val == "false": val = False elif val == "true": val = True destination[key] = val return destination
def get_cmd(self, sub_command): """ Return a command given the sub command. :param sub_command: the sub-command """ if self._opts["control"] is not None: # standard use case if self._opts[sub_command] is None: base = self._opts["control"].split() base.append(sub_command) else: base = self._opts[sub_command].split() else: # other use case base = self._opts[sub_command].split() base = [unquote(token) for token in base] return base