util.stanza: Soften dependency on util.termcolours

Tue, 06 Oct 2009 19:17:28 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 06 Oct 2009 19:17:28 +0100
changeset 1932
af8cdbb63b13
parent 1931
f203330eb82e
child 1933
3884a0aac4d7

util.stanza: Soften dependency on util.termcolours

util/stanza.lua file | annotate | diff | comparison | revisions
--- a/util/stanza.lua	Tue Oct 06 18:05:31 2009 +0100
+++ b/util/stanza.lua	Tue Oct 06 19:17:28 2009 +0100
@@ -6,7 +6,6 @@
 -- COPYING file in the source package for more information.
 --
 
-
 local t_insert      =  table.insert;
 local t_concat      =  table.concat;
 local t_remove      =  table.remove;
@@ -28,7 +27,15 @@
 local os            =            os;
 
 local do_pretty_printing = not os.getenv("WINDIR");
-local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring;
+local getstyle, getstring;
+if do_pretty_printing then
+	local ok, termcolours = pcall(require, "util.termcolours");
+	if ok then
+		getstyle, getstring = termcolours.getstyle, termcolours.getstring;
+	else
+		do_pretty_printing = nil;
+	end
+end
 
 local log = require "util.logger".init("stanza");
 

mercurial