1. camlspotter
  2. opycaml

Source

opycaml / xapi.ml

(* Extended API which may be useful and should be integrated into Api *)

open Api

let (%) = Dict.getItemString
let (%!) x = Dict.getItemString (Dict.coerce x)

let (!:>) = Object.obj

let call_obj o = Object.call (Callable.coerce o)

let call_obj_ o ?kwd xs = Object.call (Callable.coerce o) ?kwd xs |> ignore

let dict_of_alist kvs =
  let d = Dict.new_ () in
  List.iter (fun (k,v) -> Dict.setItem d k v) kvs;
  d
  
let dict_of_klist kvs =
  kvs |> List.map (fun (s,o) -> Py.String.fromString s, o) |> dict_of_alist

let import_module name = Module.getDict (Import.importModule name)