parameters: (cls, routes)
return_statement: return cls(merged_routes)
docstring: Create RouteList from elliptics route table.
  
          It slightly mangles route list by explicitly inserting start and end of
          hash-ring and also merging adj. routes for the same into one.
docstring_summary: Create RouteList from elliptics route table.
docstring_tokens: Create RouteList from elliptics route table .
function: def from_routes(cls, routes):
          """
          Create RouteList from elliptics route table.
  
          It slightly mangles route list by explicitly inserting start and end of
          hash-ring and also merging adj. routes for the same into one.
          """
          routes_dict = dict()
  
          # splits all routes between groups
          for r in routes:
              if r.id.group_id in routes_dict:
                  routes_dict[r.id.group_id].append(Route(r.id, r.address, r.backend_id))
              else:
                  routes_dict[r.id.group_id] = [Route(r.id, r.address, r.backend_id)]
  
          # merges adj. ids for same address
          smallest_id = [0] * 64
          biggest_id = [255] * 64
          merged_routes = []
          for group in routes_dict:
              # sorts routes inside one group
              group_routes = sorted(routes_dict[group], key=lambda route: route.id)
              last = (group_routes[-1].address,
                      group_routes[-1].backend_id)
  
              # Insert implicit first route if needed
              if group_routes[0].id.id != smallest_id:
                  route = Route(Id(smallest_id, group), *last)
                  group_routes.insert(0, route)
  
              # Insert implicit last route if needed
              if group_routes[-1].id.id != biggest_id:
                  route = Route(Id(biggest_id, group), *last)
                  group_routes.append(route)
  
              # Extend route list
              merged_routes.extend(group_routes)
  
          # Sort results by key
          merged_routes.sort(key=lambda route: route.id)
  
          # Return RouteList from sorted and merged routes
          return cls(merged_routes)
function_tokens: def from_routes ( cls , routes ) : routes_dict = dict ( ) # splits all routes between groups for r in routes : if r . id . group_id in routes_dict : routes_dict [ r . id . group_id ] . append ( Route ( r . id , r . address , r . backend_id ) ) else : routes_dict [ r . id . group_id ] = [ Route ( r . id , r . address , r . backend_id ) ] # merges adj. ids for same address smallest_id = [ 0 ] * 64 biggest_id = [ 255 ] * 64 merged_routes = [ ] for group in routes_dict : # sorts routes inside one group group_routes = sorted ( routes_dict [ group ] , key = lambda route : route . id ) last = ( group_routes [ - 1 ] . address , group_routes [ - 1 ] . backend_id ) # Insert implicit first route if needed if group_routes [ 0 ] . id . id != smallest_id : route = Route ( Id ( smallest_id , group ) , * last ) group_routes . insert ( 0 , route ) # Insert implicit last route if needed if group_routes [ - 1 ] . id . id != biggest_id : route = Route ( Id ( biggest_id , group ) , * last ) group_routes . append ( route ) # Extend route list merged_routes . extend ( group_routes ) # Sort results by key merged_routes . sort ( key = lambda route : route . id ) # Return RouteList from sorted and merged routes return cls ( merged_routes )