-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new exe to export keys and images from a base
- Loading branch information
Elie Canonici Merle
committed
Sep 23, 2024
1 parent
c996e73
commit 6872732
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executables | ||
(names gwimages) | ||
(libraries geneweb.gwdb-versioned geneweb.sosa_zarith geneweb) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executables | ||
(names gwimages) | ||
(libraries geneweb) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let key_of_person base p = | ||
let surname = Name.lower (Gwdb.p_surname base p) in | ||
let first_name = Name.lower (Gwdb.p_first_name base p) in | ||
let occ = string_of_int (Gwdb.get_occ p) in | ||
String.concat "." [surname; first_name; occ] | ||
|
||
let line_of_person base p = | ||
let key = key_of_person base p in | ||
let image = Gwdb.sou base (Gwdb.get_image p) in | ||
Printf.sprintf "%s %s\n" key image | ||
|
||
let has_image p = | ||
not (Gwdb.is_empty_string (Gwdb.get_image p)) | ||
|
||
let output_images_of_base oc base = | ||
Gwdb.Collection.iter begin fun p -> | ||
if has_image p then | ||
let line = line_of_person base p in | ||
output_string oc line | ||
else () | ||
end (Gwdb.persons base) | ||
|
||
let () = | ||
let bname = ref "" in | ||
let output_file = ref "" in | ||
let anonfun i = bname := i in | ||
let speclist = [ | ||
"-o", Arg.String (fun s -> output_file := s), "set the output file" | ||
] | ||
in | ||
let usage = "Usage: " ^ Sys.argv.(0) ^ " -o file base" in | ||
Arg.parse speclist anonfun usage; | ||
if !bname <> "" && !output_file <> "" then begin | ||
Secure.set_base_dir (Filename.dirname !bname); | ||
Lock.control_retry (Files.lock_file !bname) ~onerror:Lock.print_error_and_exit @@ fun () -> | ||
let base = Gwdb.open_base !bname in | ||
let oc = open_out !output_file in | ||
output_images_of_base oc base; | ||
close_out oc; | ||
Gwdb.close_base base | ||
end | ||
else begin | ||
Arg.usage speclist usage ; | ||
exit 2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let () = | ||
let bname = ref "" in | ||
let output_file = ref "" in | ||
let anonfun i = bname := i in | ||
let speclist = [ | ||
"-o", Arg.String (fun s -> output_file := s), "set the output file" | ||
] | ||
let usage = "Usage: " ^ Sys.argv.(0) ^ " -o file base" in | ||
Arg.parse speclist anonfun usage; | ||
in | ||
() |