(** During the test, we don’t care with the file existence *) let context = ImportConf. { loadFile = (fun _ -> Otoml.array []); checkFile = (fun _ -> true) } let load' : ?dataset:(string -> Otoml.t) -> string -> (ImporterSyntax.t, string) Result.t = fun ?(dataset = fun _ -> Otoml.array []) content -> let toml = Otoml.Parser.from_string content in ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset } let load_from_file : ?dataset:(string -> Otoml.t) -> string -> (ImporterSyntax.t, string) Result.t = fun ?(dataset = fun _ -> Otoml.array []) content -> let toml = Otoml.Parser.from_file content in ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset } (** Read the configuration in toml and return the internal representation *) let load : string -> ImporterSyntax.t = fun content -> Result.get_ok (load' content) let conf = load {|[source] file = "source.xlsx" name = "source" [externals.other] intern_key = ":A" file = "other.xlsx" extern_key = ":C" allow_missing = false [externals.last_file] intern_key = ":other.A" file = "last.xlsx" extern_key = ":C" allow_missing = true [sheet] columns = [ ":A ^ '_'", ":B", ":last_file.E", ]|} let external_table_source = ImportDataTypes.Table.{ file = "source.xlsx"; tab = 1; name = "source" } let external_table_other = ImportDataTypes.Table.{ file = "other.xlsx"; tab = 1; name = "other" } let external_other = ImporterSyntax.Extern. { intern_key = Path { alias = None; column = 1 }; target = external_table_other; extern_key = Path 3; allow_missing = false; match_rule = None; } let external_table_last = ImportDataTypes.Table.{ file = "last.xlsx"; tab = 1; name = "last_file" } let external_last = ImporterSyntax.Extern. { intern_key = Path { alias = Some "other"; column = 1 }; target = external_table_last; extern_key = Path 3; allow_missing = true; match_rule = None; }