def get_route_to(self, destination="<STR_LIT>", protocol="<STR_LIT>"):
routes = {}<EOL>if not isinstance(destination, py23_compat.string_types):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if protocol and isinstance(destination, py23_compat.string_types):<EOL><INDENT>protocol = protocol.lower()<EOL><DEDENT>if protocol == "<STR_LIT>":<EOL><INDENT>protocol = "<STR_LIT>"  <EOL><DEDENT>_COMMON_PROTOCOL_FIELDS_ = [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>]  <EOL>_BOOLEAN_FIELDS_ = [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>]  <EOL>_PROTOCOL_SPECIFIC_FIELDS_ = {<EOL>"<STR_LIT>": [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>],<EOL>"<STR_LIT>": ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>}<EOL>routes_table = junos_views.junos_protocol_route_table(self.device)<EOL>rt_kargs = {"<STR_LIT>": destination}<EOL>if protocol and isinstance(destination, py23_compat.string_types):<EOL><INDENT>rt_kargs["<STR_LIT>"] = protocol<EOL><DEDENT>try:<EOL><INDENT>routes_table.get(**rt_kargs)<EOL><DEDENT>except RpcTimeoutError:<EOL><INDENT>raise CommandTimeoutException(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>except RpcError as rpce:<EOL><INDENT>if len(rpce.errs) > <NUM_LIT:0> and "<STR_LIT>" in rpce.errs[<NUM_LIT:0>]:<EOL><INDENT>raise CommandErrorException(<EOL>"<STR_LIT>".format(<EOL>proto=rpce.errs[<NUM_LIT:0>]["<STR_LIT>"]<EOL>)<EOL>)<EOL><DEDENT>raise CommandErrorException(rpce)<EOL><DEDENT>except Exception as err:<EOL><INDENT>raise CommandErrorException(<EOL>"<STR_LIT>".format(err=err)<EOL>)<EOL><DEDENT>routes_items = routes_table.items()<EOL>for route in routes_items:<EOL><INDENT>d = {}<EOL>d = {elem[<NUM_LIT:0>]: elem[<NUM_LIT:1>] for elem in route[<NUM_LIT:1>]}<EOL>destination = d.pop("<STR_LIT>", "<STR_LIT>")<EOL>prefix_length = d.pop("<STR_LIT>", <NUM_LIT:32>)<EOL>destination = "<STR_LIT>".format(d=destination, p=prefix_length)<EOL>d.update({key: False for key in _BOOLEAN_FIELDS_ if d.get(key) is None})<EOL>as_path = d.get("<STR_LIT>")<EOL>if as_path is not None:<EOL><INDENT>d["<STR_LIT>"] = (<EOL>as_path.split("<STR_LIT>")[<NUM_LIT:0>]<EOL>.replace("<STR_LIT>", "<STR_LIT>")<EOL>.replace("<STR_LIT:I>", "<STR_LIT>")<EOL>.strip()<EOL>)<EOL><DEDENT>if d.get("<STR_LIT>") is None:<EOL><INDENT>d["<STR_LIT>"] = "<STR_LIT>"<EOL><DEDENT>route_protocol = d.get("<STR_LIT>").lower()<EOL>if protocol and protocol != route_protocol:<EOL><INDENT>continue<EOL><DEDENT>communities = d.get("<STR_LIT>")<EOL>if communities is not None and type(communities) is not list:<EOL><INDENT>d["<STR_LIT>"] = [communities]<EOL><DEDENT>d_keys = list(d.keys())<EOL>all_protocol_attributes = {<EOL>key: d.pop(key) for key in d_keys if key not in _COMMON_PROTOCOL_FIELDS_<EOL>}<EOL>protocol_attributes = {<EOL>key: value<EOL>for key, value in all_protocol_attributes.items()<EOL>if key in _PROTOCOL_SPECIFIC_FIELDS_.get(route_protocol, [])<EOL>}<EOL>d["<STR_LIT>"] = protocol_attributes<EOL>if destination not in routes.keys():<EOL><INDENT>routes[destination] = []<EOL><DEDENT>routes[destination].append(d)<EOL><DEDENT>return routes<EOL>
Return route details to a specific destination, learned from a certain protocol.