clean up
This commit is contained in:
parent
45648f15c1
commit
6b4bd04c6a
2 changed files with 28 additions and 26 deletions
|
|
@ -5,7 +5,7 @@
|
|||
(libraries cmdliner bos fmt mirage-crypto ptime mte vif))
|
||||
|
||||
(executable
|
||||
(public_name gen_signatures_registry)
|
||||
(name gen_signatures_registry)
|
||||
(modules gen_signatures_registry)
|
||||
(public_name gen_taler_signatures)
|
||||
(name gen_taler_signatures)
|
||||
(modules gen_taler_signatures)
|
||||
(libraries angstrom bos fmt))
|
||||
|
|
|
|||
|
|
@ -51,12 +51,7 @@ module Recfile = struct
|
|||
let parse s = parse_string ~consume:All recfile s
|
||||
end
|
||||
|
||||
let url =
|
||||
"https://git-www.gnunet.org/gana.git/plain/gnunet-signatures/registry.rec"
|
||||
|
||||
let registry_file = "registry.rec"
|
||||
|
||||
let download () =
|
||||
let download ~output ~url =
|
||||
let open Bos in
|
||||
let res =
|
||||
OS.Cmd.run
|
||||
|
|
@ -65,7 +60,7 @@ let download () =
|
|||
% "--silent"
|
||||
% "--show-error"
|
||||
% "-o"
|
||||
% registry_file
|
||||
% output
|
||||
% "-X"
|
||||
% "GET"
|
||||
% url)
|
||||
|
|
@ -74,8 +69,6 @@ let download () =
|
|||
| Error (`Msg s) -> Fmt.failwith "download failure: %s" s
|
||||
| Ok () -> ()
|
||||
|
||||
let read_file file = In_channel.with_open_bin file In_channel.input_all
|
||||
|
||||
type purpose = {
|
||||
number: int32;
|
||||
name: string;
|
||||
|
|
@ -100,13 +93,7 @@ let parse_purposes records =
|
|||
| _ -> None)
|
||||
|> List.filter (fun v -> v.number >= 1000_l)
|
||||
|
||||
let () =
|
||||
download ();
|
||||
let content = read_file registry_file in
|
||||
match Recfile.parse content with
|
||||
| Error msg -> Fmt.failwith "Recfile parse error: %s" msg
|
||||
| Ok records ->
|
||||
let purposes = parse_purposes records in
|
||||
let print_module purposes =
|
||||
let header =
|
||||
{|(* This file was generated from the GANA database:
|
||||
https://git-www.gnunet.org/gana.git/tree/gnunet-signatures/registry.rec *)|}
|
||||
|
|
@ -116,3 +103,18 @@ let () =
|
|||
in
|
||||
Fmt.pr "%s\n\n%a@." header (Fmt.list ~sep:Fmt.nop pp) purposes;
|
||||
()
|
||||
|
||||
(* --- *)
|
||||
|
||||
let url =
|
||||
"https://git-www.gnunet.org/gana.git/plain/gnunet-signatures/registry.rec"
|
||||
|
||||
let main () =
|
||||
let tmp_file = Bos.OS.File.tmp "registry.rec.%s" |> Result.get_ok in
|
||||
download ~output:(Fpath.to_string tmp_file) ~url;
|
||||
let content = Bos.OS.File.read tmp_file |> Result.get_ok in
|
||||
match Recfile.parse content with
|
||||
| Error msg -> Fmt.failwith "Recfile parse error: %s" msg
|
||||
| Ok records -> print_module (parse_purposes records)
|
||||
|
||||
let () = main ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue