dlab_core.routing

Module Contents

LC_ERR_ARGUMENT_TYPE_DICT = Argument must be of type dict.[source]
exception RoutingException[source]

Bases: dlab_core.domain.exceptions.DLabException

Base class for Routing exceptions

exception RouteArgumentTypeException[source]

Bases: dlab_core.routing.RoutingException

exception RouteArgumentKeyException[source]

Bases: dlab_core.routing.RoutingException

exception RouteArgumentValueException[source]

Bases: dlab_core.routing.RoutingException

exception RouteInvokeCallableException[source]

Bases: dlab_core.routing.RoutingException

class CLIRoute(invoke, arguments)[source]

Bases: object

invoke[source]
Rtype invoke:callable
Return invoke:method that will be invoked by router
arguments[source]
Rtype arguments:
 dict
Return arguments:
 dict of arguments, where key is index of argument and value - the argument itself
static validate_arguments_dict(key, value)[source]
class CLIRouter(routes=())[source]

Bases: object

add(self, route)[source]
Parameters:route (CLIRoute) – Cli route.
match(self, args)[source]
Parameters:args (list) – command, split into an array of strings

:rtype Route :return route matched by all parameters with maximum match size

static extract_maximum_match(routes)[source]
static match_args(route_args, cli_args)[source]
Parameters:
  • route_args (dict) – dict of route args
  • cli_args (list) – cli arguments
Return type:

bool

:returns True or False depending on matching cli args to routing args

If maximum route arguments index is less then cli args count and values from cli equal corresponding indexes values return True