summaryrefslogtreecommitdiff
path: root/geneticone/helper.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--geneticone/helper.py23
1 files changed, 13 insertions, 10 deletions
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. <necoro@necoro.net> 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: