drepr.program_generation.main#

Functions

gen_classplan_executor(program, parent_ast, ...)

Generate the code to execute the given class plan.

gen_classprop_body(program, desc, ...)

param parent_ast:

the parent AST that above iterating subject values -- this is good to detect continue statement is okay to skip to the next subject/record

gen_program(desc, exec_plan, output, debuginfo)

Generate a program to convert the given D-REPR to a target format

get_subj_val_for_static_class(class_id)

Classes

FileOutput(fpath, format)

MemoryOutput(format)

class FileOutput(fpath: 'Path', format: 'OutputFormat')[source]#

Bases: object

Parameters:
fpath: Path#
format: OutputFormat#
class MemoryOutput(format: 'OutputFormat')[source]#

Bases: object

Parameters:

format (OutputFormat) –

format: OutputFormat#
gen_program(desc: DRepr, exec_plan: ClassesMapExecutionPlan, output: drepr.program_generation.main.FileOutput | drepr.program_generation.main.MemoryOutput, debuginfo: bool) AST[source]#

Generate a program to convert the given D-REPR to a target format

Parameters:
Return type:

AST

gen_classplan_executor(program: Program, parent_ast: AST, writer: Writer, desc: DRepr, classplan: ClassMapPlan, debuginfo: bool)[source]#

Generate the code to execute the given class plan. Below is the pseudo code:

  1. Iterate over the subject values
    1. If the subject is uri and it has missing values, if the uri is missing, we skip this record

    2. Begin record

    3. Iterate over target property & value
      1. If not target.can_have_missing_values:
        1. Iterate over objprop values:
          1. Write property

      2. Else:
        1. If target edge is optional:
          iterate over objprop values:
          if objprop value is not missing:

          write property

        else:

        (1) —- has_record = False iterate over objprop values:

        if objprop value is not missing:

        has_record = True write property

        if not has_record:

        abort the record

        —- (2)

    4. End the record – if the subject is blank node,

      and we do not write any data, we abort, otherwise, we commit

Parameters:
gen_classprop_body(program: Program, desc: DRepr, parent_ast: AST, ast: AST, writer: Writer, is_buffered: bool, is_subj_blank: bool, classprop: drepr.planning.class_map_plan.DataProp | drepr.planning.class_map_plan.BlankObject | drepr.planning.class_map_plan.IDObject | drepr.planning.class_map_plan.SingletonObject | drepr.planning.class_map_plan.LiteralProp, debuginfo: bool)[source]#
Parameters:
get_subj_val_for_static_class(class_id)[source]#