]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaMisc.ml
added choose_uri method to console, used by the interpreter to implement the
[helm.git] / helm / matita / matitaMisc.ml
index c3b83fd472f31453181f1598fd786f88d24ff442..094f965e0ae20d02aff1ae0130d82899b4d729a3 100644 (file)
@@ -49,12 +49,13 @@ let strip_trailing_blanks =
   let rex = Pcre.regexp "\\s*$" in
   fun s -> Pcre.replace ~rex s
 
-let empty_mathml =
-  let doc =
-    Misc.domImpl#createDocument ~namespaceURI:(Some Misc.mathml_ns)
-      ~qualifiedName:(Gdome.domString "math") ~doctype:None
-  in
-  doc#get_documentElement
+let empty_mathml () =
+  Misc.domImpl#createDocument ~namespaceURI:(Some Misc.mathml_ns)
+    ~qualifiedName:(Gdome.domString "math") ~doctype:None
+
+let empty_boxml () =
+  Misc.domImpl#createDocument ~namespaceURI:(Some Misc.boxml_ns) 
+    ~qualifiedName:(Gdome.domString "box") ~doctype:None
 
 exception History_failure
 
@@ -130,3 +131,19 @@ class ['a] browser_history ?memento size init =
     method save = (Array.copy data, hd, tl, cur)
   end
 
+let dbd_instance =
+  let dbd = lazy (
+    Mysql.quick_connect
+      ~host:(Helm_registry.get "db.host")
+      ~user:(Helm_registry.get "db.user")
+      ~database:(Helm_registry.get "db.database")
+      ())
+  in
+  fun () -> Lazy.force dbd
+
+let singleton f =
+  let instance = lazy (f ()) in
+  fun () -> Lazy.force instance
+
+let mkdirs = List.iter (fun d -> ignore (Unix.system ("mkdir -p " ^ d)))
+