[Assorted-commits] SF.net SVN: assorted:[1016] python-commons/trunk/src/commons/misc.py
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-10-14 03:33:17
|
Revision: 1016 http://assorted.svn.sourceforge.net/assorted/?rev=1016&view=rev Author: yangzhang Date: 2008-10-14 03:32:58 +0000 (Tue, 14 Oct 2008) Log Message: ----------- added cleartimeout; changed wrap from function to method Modified Paths: -------------- python-commons/trunk/src/commons/misc.py Modified: python-commons/trunk/src/commons/misc.py =================================================================== --- python-commons/trunk/src/commons/misc.py 2008-10-10 22:21:12 UTC (rev 1015) +++ python-commons/trunk/src/commons/misc.py 2008-10-14 03:32:58 UTC (rev 1016) @@ -7,6 +7,7 @@ __all__ = ''' TerminalController +cleartimeout days default_if_none generate_bit_fields @@ -18,7 +19,6 @@ tc timeout_exception wall_clock -wrap_color '''.split() # @@ -108,6 +108,8 @@ signal(SIGALRM, handle) alarm(secs) +def cleartimeout(): alarm(0) + # # Functional # @@ -297,18 +299,17 @@ if s == '$$': return s else: return getattr(self, s[2:-1]) + def wrap(self, s, color): + """ + Wraps L{s} in L{color} (resets color to NORMAL at the end). + """ + return self.render( '${%s}%s${NORMAL}' % (color, s) ) + remove_colors_pat = re.compile('\033\\[[0-9;]*m') def remove_colors(s): 'Removes ANSI escape codes (e.g. those for terminal colors).' return remove_colors_pat.sub('', s) -tc = TerminalController() -def wrap_color(s, color, tc = tc): - """ - Wraps L{s} in L{color} (resets color to NORMAL at the end). - """ - return tc.render( '${%s}%s${NORMAL}' % (color, s) ) - import unittest class color_test( unittest.TestCase ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |