From 8d698c7fd778dc1de2f827ef3091ddf3cd47d76e Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sat, 21 Oct 2006 13:10:53 +0000 Subject: nomsg --- geneticone/helper.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'geneticone/helper.py') diff --git a/geneticone/helper.py b/geneticone/helper.py index a1acf42..780893e 100644 --- a/geneticone/helper.py +++ b/geneticone/helper.py @@ -9,24 +9,28 @@ # # Written by Necoro d.M. et.al. -import traceback, textwrap, os.path +import traceback, os.path DEBUG = True def set_debug (d): + """Sets the global DEBUG variable. Do not set it by your own - always use this function. + + @param d: True to enable debugging; False otherwise + @type d: boolean""" + global DEBUG DEBUG = d def debug(*args, **kwargs): """Prints a debug message including filename and lineno. A variable number of positional arguments are allowed. - If lineno(obj0, obj1, obj2) is called, the text part of the output - looks like the output from print obj0, obj1, obj2 . - The optional keyword "wrap" causes the message to be line-wrapped. The - argument to "wrap" should be "1" or "True". "name" is another optional - keyword parameter. - (This function is adapted from Edward Jones as published under: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/279155)""" + If debug(obj0, obj1, obj2) is called, the text part of the output + looks like the output from print obj0, obj1, obj2. + + If you pass the optional keyword-argument "name", it is used for the function-name instead of the original one.""" + if not DEBUG : return @@ -41,15 +45,14 @@ def debug(*args, **kwargs): text = 'In %s (%s:%s): %s' % (kwargs["name"], a, b, text) else: text = 'In %s (%s:%s): %s' % (c, a, b, text) - #if wrap: - # text = textwrap.fill(text) text = "***DEBUG*** %s ***DEBUG***" % text print text def am_i_root (): - """Returns True if the current user is root, False otherwise.""" + """Returns True if the current user is root, False otherwise. + @rtype: boolean""" if os.getuid() == 0: return True else: -- cgit v1.2.3-54-g00ecf