aboutsummaryrefslogtreecommitdiff
path: root/bin/importer.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-03-13 20:17:51 +0100
committerSébastien Dailly <sebastien@dailly.me>2025-04-08 18:39:49 +0200
commit9e2dbe43abe97c4e60b158e5fa52172468a2afb8 (patch)
treef58276e500d8ab0b84cdf74cc36fc73d4bca3892 /bin/importer.ml
parent0bdc640331b903532fb345930e7078752ba54a2d (diff)
Declare the files to load from an external configuration file
Diffstat (limited to 'bin/importer.ml')
-rw-r--r--bin/importer.ml20
1 files changed, 11 insertions, 9 deletions
diff --git a/bin/importer.ml b/bin/importer.ml
index 0da2ab7..260d83b 100644
--- a/bin/importer.ml
+++ b/bin/importer.ml
@@ -33,6 +33,7 @@ module Args = struct
let load_conf : string -> ImporterSyntax.t =
fun file ->
+ let dirname = Filename.dirname file in
match Filename.extension file with
| _ -> (
let (conf : (ImporterSyntax.t, string) result) =
@@ -51,7 +52,16 @@ module Args = struct
Error error_msg
in
- ImportConf.t_of_toml configuration_file
+
+ ImportConf.t_of_toml
+ ~context:
+ {
+ checkFile =
+ (fun f -> Sys.file_exists (Filename.concat dirname f));
+ loadFile =
+ (fun f -> Otoml.Parser.from_file (Filename.concat dirname f));
+ }
+ configuration_file
in
match conf with
| Error e ->
@@ -238,14 +248,6 @@ let () =
let sqlfile = Filename.concat dirname (prefix ^ ".sqlite") in
let conf = { conf with mapping_date = creation_date sqlfile } in
- (* Ensure that all the files exists *)
- List.iter process_order ~f:(fun (mapping : Analyse.t) ->
- let source = Analyse.table mapping in
- (* First, check *)
- if not (Sys.file_exists source.Table.file) then begin
- ignore @@ exists @@ Filename.concat dirname source.Table.file
- end);
-
(* The configuration is loaded and valid, we create the errors log file *)
let log_error = ImportErrors.log ~with_bom:conf.bom prefix dirname in