Example #1
0
 def get_non_annotated_source(self):
     """
     gets the non annotated source of a symbol
     :return: the symbol's source as a string
     """
     return self.get_source(
         access_attribute(self.get_non_annotated_source.__name__))
Example #2
0
 def get_annotated_source(self, module_annotated_data_items):
     """
     gets the annotated source of a symbol
     :return: the symbol's source as a string
     """
     return self.get_source(
         access_attribute(self.get_annotated_source.__name__),
         module_annotated_data_items)
def replace(project_symbols):
    """
       replace old source with non annotated signatures
       :param project_symbols: symbols we will use to write out new source code
       :return: bool
       """
    for module_symbols in project_symbols:
        if not write_new_source(module_symbols,
                                access_attribute("get_non_annotated_source")):
            return False
    return True
def restore(project_symbols_annotated_data_items):
    """
    restores old source from a non annotated to an annotated form
    :param project_symbols_annotated_data_items: set of module symbols associated wth annotated DataItems from our backing store
    :return: bool
    """
    for module_symbols, module_annotated_data_items in project_symbols_annotated_data_items.items(
    ):
        if not write_new_source(module_symbols,
                                access_attribute("get_annotated_source"),
                                module_annotated_data_items):
            return False
    return True
Example #5
0
 def get_annotated_source(self, old_project_symbols):
     """
     gets the annotated source of a module
     :return: the modules's annotated source as a string
     """
     return self.get_source(access_attribute(self.get_annotated_source.__name__), old_project_symbols)
Example #6
0
 def get_non_annotated_source(self):
     """
     gets the non annotated source of a module
     :return: the modules's non annotated source as a string
     """
     return self.get_source(access_attribute(self.get_non_annotated_source.__name__))
Example #7
0
import inspect
import os
import re

from picidae import access_attribute

from pavo_cristatus.constants import DECORATOR_STRING
from pavo_cristatus.python_file import PythonFile

PYTHON_EXTENSION = ".py"

access_interaction_callable = access_attribute("interact")


def create_data_item_id(module_qualname, symbol_qualname):
    return "{0}.{1}".format(module_qualname, symbol_qualname)


def convert_python_file_to_module_qualname(project_root_path, python_file):
    split_file_name = os.path.splitext(python_file.file_name)

    if project_root_path == python_file.package_path:
        length = len(python_file.package_path)
        span = (length, length)
    else:
        try:
            # Windows path separator cases issues with re, so we temporarily get rid of it
            normalized_project_root_path = project_root_path.replace("\\", "/")
            normalized_package_path = python_file.package_path.replace(
                "\\", "/")
            match = re.search(normalized_project_root_path,
Example #8
0
from pavo_cristatus.project_loader import project_loader
from pavo_cristatus.dependency_injection.ploceidae_configurator import pavo_cristatus_dependency_wrapper

from picidae import access_attribute

dependency_module_name = "project_loader"

__all__ = [dependency_module_name]

pavo_cristatus_dependency_wrapper(
    resolvable_name="annotated_" + dependency_module_name,
    transformation=access_attribute("load_annotated_project"))(
        lambda: project_loader)

pavo_cristatus_dependency_wrapper(
    resolvable_name="non_annotated_" + dependency_module_name,
    transformation=access_attribute("load_non_annotated_project"))(
        lambda: project_loader)
Example #9
0
from pavo_cristatus.dependency_injection.ploceidae_configurator import pavo_cristatus_dependency_wrapper
from picidae import lazily_echo, access_attribute

from pavo_cristatus.symbol_signature_replacer import symbol_signature_replacer

dependency_module_name = "symbol_signature_replacer"

__all__ = [dependency_module_name]

pavo_cristatus_dependency_wrapper(
    resolvable_name=dependency_module_name,
    transformation=access_attribute("interaction"))(
        lambda: symbol_signature_replacer)