summaryrefslogtreecommitdiff
path: root/src/util.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.ml')
-rw-r--r--src/util.ml13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/util.ml b/src/util.ml
index de85e3e..c4bbd96 100644
--- a/src/util.ml
+++ b/src/util.ml
@@ -1,5 +1,6 @@
(** The unavoidable module for functions that don't fit anywhere else *)
+(** Find a child node in xml-lite *)
let find_xml_child name xml =
let find_aux e =
match e with
@@ -10,17 +11,23 @@ let find_xml_child name xml =
| Xml.Element (_, _, children) -> Vylist.find find_aux children
| Xml.PCData _ -> None
-(* Dirty pretty printer *)
-let string_of_path path =
+(** Convert a list of strings to a string of unquoted, space separated words *)
+let string_of_list ss =
let rec aux xs acc =
match xs with
| [] -> acc
| x :: xs' -> aux xs' (Printf.sprintf "%s %s" acc x)
in
- match path with
+ match ss with
| [] -> ""
| x :: xs -> Printf.sprintf "%s%s" x (aux xs "")
+(** Convert a list of strings to JSON *)
+let json_of_list ss =
+ let ss = List.map (fun x -> `String x) ss in
+ Yojson.Safe.to_string (`List ss)
+
+(** Convert a relative path to an absolute path based on the current working directory *)
let absolute_path relative_path =
FilePath.make_absolute (Sys.getcwd ()) relative_path