summaryrefslogtreecommitdiff
path: root/geneticone/helper.py
diff options
context:
space:
mode:
authornecoro <>2006-10-21 13:10:53 +0000
committernecoro <>2006-10-21 13:10:53 +0000
commit8d698c7fd778dc1de2f827ef3091ddf3cd47d76e (patch)
tree6d6941d89a36c61b42cb2c48fee12aa4b064e655 /geneticone/helper.py
parentf1f6fb18232258b5de3267a1cae2e483cd5f7ba7 (diff)
downloadportato-8d698c7fd778dc1de2f827ef3091ddf3cd47d76e.tar.gz
portato-8d698c7fd778dc1de2f827ef3091ddf3cd47d76e.tar.bz2
portato-8d698c7fd778dc1de2f827ef3091ddf3cd47d76e.zip
nomsg
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: