Exemple #1
0
def _create_module_dep(module: Module, document: provo.ProvBundle, suffix=""):
    document.entity("module{}{}".format(module.id, suffix),
                    [(provo.PROV_LABEL, module.name),
                     (provo.PROV_TYPE, "moduleDependency"),
                     ("version", module.version),
                     (provo.PROV_LOCATION, truncate(module.path)),
                     ("codeHash", module.code_hash),
                     ("id", module.id) if suffix else (None, None)])
Exemple #2
0
def _create_env_attr(document: provo.ProvBundle,
                     env_attr: EnvironmentAttr,
                     suffix=""):
    document.entity("environmentAttribute{}{}".format(env_attr.id, suffix),
                    [(provo.PROV_LABEL, env_attr.name),
                     (provo.PROV_VALUE, truncate(env_attr.value)),
                     (provo.PROV_TYPE, "environmentAttribute"),
                     ("id", env_attr.id) if suffix else (None, None)])
def _return_value(activation, document):
    if activation.return_value is not None and activation.return_value != "None":
        document.entity("funcAct{}ReturnValue".format(activation.id),
                        [(provo.PROV_VALUE, truncate(activation.return_value)),
                         (provo.PROV_TYPE, "returnValue")])

        document.wasGeneratedBy(
            "funcAct{}ReturnValue".format(activation.id),
            "functionActivation{}".format(activation.id), activation.finish,
            "funcAct{}RetValGeneration".format(activation.id))
def _function_definitions(document, function):
    doc_string = truncate(function.docstring.strip().replace("\n", " "))

    document.activity(
        "functionDefinition{}".format(function.id), None, None,
        [(provo.PROV_LABEL, function.name),
         (provo.PROV_TYPE, "functionDefinition"),
         ("codeHash", function.code_hash), ("firstLine", function.first_line),
         ("lastLine", function.last_line),
         ("docString",
          doc_string if len(function.docstring.strip()) > 0 else None)])
def _argument_activation(activation, document):
    args = list(activation.arguments)
    if args:
        for arg in args:  # type: ObjectValue
            document.entity("argumentActivation{}".format(arg.id),
                            [(provo.PROV_LABEL, arg.name),
                             (provo.PROV_VALUE, truncate(arg.value)),
                             (provo.PROV_TYPE, "argumentActivation")])

            document.used(
                "functionActivation{}".format(arg.function_activation_id),
                "argumentActivation{}".format(arg.id), activation.start,
                "funcAct{}UsedArgAct{}".format(activation.id, arg.id),
                [(provo.PROV_ROLE, "argument"),
                 (provo.PROV_TYPE, "argumentActivation")])
def _global_activation(activation, document):
    globs = list(activation.globals)
    if globs:
        for glob in globs:  # type: ObjectValue
            document.entity("globalActivation{}".format(glob.id),
                            [(provo.PROV_LABEL, glob.name),
                             (provo.PROV_VALUE, truncate(glob.value)),
                             (provo.PROV_TYPE, "globalActivation")])

            document.used(
                "functionActivation{}".format(glob.function_activation_id),
                "globalActivation{}".format(glob.id), activation.start,
                "funcAct{}UsedGlobalAct{}".format(activation.id, glob.id),
                [(provo.PROV_ROLE, "global"),
                 (provo.PROV_TYPE, "globalActivation")])