Exemplo n.º 1
0
def interact(project_symbols_annotated_data_items):
    if symbol_signature_restorer.restore(project_symbols_annotated_data_items):
        return PavoCristatusResult(project_symbols_annotated_data_items,
                                   PavoCristatusStatus.SUCCESS)
    else:
        return PavoCristatusResult(project_symbols_annotated_data_items,
                                   PavoCristatusStatus.FAILURE,
                                   "could not restore symbols")
Exemplo n.º 2
0
def interact(project_root):
    """
    :param project_root: root of the project source
    :return: a set of ModuleSymbols within a result that will be manipulated with in the PavoCristatusMonad
    """
    try:
        return PavoCristatusResult(load_annotated_project(project_root),
                                   PavoCristatusStatus.SUCCESS)
    except Exception as ex:
        return PavoCristatusResult(None, PavoCristatusStatus.FAILURE, str(ex))
Exemplo n.º 3
0
def interact(project_symbols_annotated_data_items, presentation_strategy):
    """
    interaction that presents annotated symbols
    :param project_symbols_annotated_data_items: all the necessary information for the presentation_strategy to work
    :param presentation_strategy: the way in which the annotated symbol data will be presented
    :return: a bool within a result that will be manipulated with in the PavoCristatusMonad
    """
    if presentation_strategy(project_symbols_annotated_data_items):
        return PavoCristatusResult(True, PavoCristatusStatus.SUCCESS)
    else:
        return PavoCristatusResult(False, PavoCristatusStatus.FAILURE,
                                   "could not replace symbols")
def interact(project_root_path):
    """
    loads non annotated symbols from a project
    :param project_root_path: the project root of the source
    :return: a set of ModuleSymbols within a result that will be manipulated with in the PavoCristatusMonad
    """
    try:
        return PavoCristatusResult(
            load_non_annotated_project(project_root_path),
            PavoCristatusStatus.SUCCESS)
    except Exception as ex:
        return PavoCristatusResult(None, PavoCristatusStatus.FAILURE,
                                   ex.message)
Exemplo n.º 5
0
def interact(project_symbols):
    """
    write out new symbol signatures for target source
    :param project_symbols: symbols we will use to write out new source code
    :return: a set of ModuleSymbols within a result that will be manipulated with in the PavoCristatusMonad
    """
    if symbol_signature_replacer.replace(project_symbols):
        return PavoCristatusResult(project_symbols,
                                   PavoCristatusStatus.SUCCESS)
    else:
        return PavoCristatusResult(project_symbols,
                                   PavoCristatusStatus.FAILURE,
                                   "could not replace symbols")
 def test_type_missmatch_after_invocation_raises_exception(self):
     bindee_function = lambda _: PavoCristatusResult(
         bool(), PavoCristatusStatus.SUCCESS)
     bindee_definition = BindeeDefinition(bindee_function,
                                          get_type_check(str),
                                          get_type_check(str))
     bindee = HigherOrderBindee(bindee_definition)
     bindee(str())
 def test_type_missmatch_before_invocation_raises_exception(self):
     bindee_function = lazily_compose_given_functions(
         echo,
         lambda x: PavoCristatusResult(x, PavoCristatusStatus.SUCCESS))
     bindee_definition = BindeeDefinition(bindee_function,
                                          get_type_check(str),
                                          get_type_check(str))
     bindee = HigherOrderBindee(bindee_definition)
     bindee(bool())
 def interact(self, project_symbols):
     """
     :param project_symbols: a dictionary of modules associated with their symbols
     :return: bool
     """
     accumulator = self.get_accumulator()
     for module_symbols in project_symbols:
         for symbol_object in module_symbols.symbol_objects:
             if not self.operation(module_symbols, symbol_object,
                                   self.repository, accumulator):
                 return PavoCristatusResult(
                     project_symbols, PavoCristatusStatus.FAILURE,
                     "failed with operation {0}".format(self.operation))
             for nested_symbol in symbol_object.nested_symbols:
                 if not self.operation(module_symbols, nested_symbol,
                                       self.repository, accumulator):
                     return PavoCristatusResult(
                         project_symbols, PavoCristatusStatus.FAILURE,
                         "failed with operation {0}".format(self.operation))
     # needs to be an explicit check for equality for False (TODO: fix this)
     ret = accumulator
     if accumulator == False:
         ret = project_symbols
     return PavoCristatusResult(ret, PavoCristatusStatus.SUCCESS)