drepr.program_generation.main#
Functions
|
Generate the code to execute the given class plan. |
|
|
|
Generate a program to convert the given D-REPR to a target format |
|
Classes
|
|
|
- class FileOutput(fpath: 'Path', format: 'OutputFormat')[source]#
Bases:
object- Parameters:
fpath (Path) –
format (OutputFormat) –
- 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:
desc (DRepr) –
exec_plan (ClassesMapExecutionPlan) –
output (drepr.program_generation.main.FileOutput | drepr.program_generation.main.MemoryOutput) –
debuginfo (bool) –
- 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:
- Iterate over the subject values
If the subject is uri and it has missing values, if the uri is missing, we skip this record
Begin record
- Iterate over target property & value
- If not target.can_have_missing_values:
- Iterate over objprop values:
Write property
- Else:
- 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)
- End the record – if the subject is blank node,
and we do not write any data, we abort, otherwise, we commit
- Parameters:
program (Program) –
parent_ast (AST) –
writer (Writer) –
desc (DRepr) –
classplan (ClassMapPlan) –
debuginfo (bool) –
- 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:
parent_ast (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
program (Program) –
desc (DRepr) –
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) –