This commit is contained in:
parent
45648f15c1
commit
bfa075632d
1 changed files with 23 additions and 29 deletions
|
|
@ -54,27 +54,17 @@ end
|
|||
let url =
|
||||
"https://git-www.gnunet.org/gana.git/plain/gnunet-signatures/registry.rec"
|
||||
|
||||
let registry_file = "registry.rec"
|
||||
|
||||
let download () =
|
||||
let download url =
|
||||
let open Bos in
|
||||
let res =
|
||||
OS.Cmd.run
|
||||
Cmd.(
|
||||
v "curl"
|
||||
% "--silent"
|
||||
% "--show-error"
|
||||
% "-o"
|
||||
% registry_file
|
||||
% "-X"
|
||||
% "GET"
|
||||
% url)
|
||||
OS.Cmd.(
|
||||
to_string
|
||||
(run_out
|
||||
Cmd.(v "curl" % "--silent" % "--show-error" % "-X" % "GET" % url)))
|
||||
in
|
||||
match res with
|
||||
| Error (`Msg s) -> Fmt.failwith "download failure: %s" s
|
||||
| Ok () -> ()
|
||||
|
||||
let read_file file = In_channel.with_open_bin file In_channel.input_all
|
||||
| Ok registry_rec -> registry_rec
|
||||
|
||||
type purpose = {
|
||||
number: int32;
|
||||
|
|
@ -100,13 +90,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 +100,13 @@ let () =
|
|||
in
|
||||
Fmt.pr "%s\n\n%a@." header (Fmt.list ~sep:Fmt.nop pp) purposes;
|
||||
()
|
||||
|
||||
let main () =
|
||||
let registry_rec = download url in
|
||||
match Recfile.parse registry_rec 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