Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mwlib/caller.py
diff options
context:
space:
mode:
Diffstat (limited to 'mwlib/caller.py')
-rwxr-xr-xmwlib/caller.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/mwlib/caller.py b/mwlib/caller.py
new file mode 100755
index 0000000..583a123
--- /dev/null
+++ b/mwlib/caller.py
@@ -0,0 +1,20 @@
+#! /usr/bin/env python
+
+# Copyright (c) 2007-2008 PediaPress GmbH
+# See README.txt for additional licensing information.
+
+import sys
+import os
+
+def caller(n=2):
+ """return caller as string"""
+ f = sys._getframe(n)
+ return "%s:%s" % (f.f_code.co_filename, f.f_lineno)
+
+def short(n=2):
+ """return caller as string"""
+ f = sys._getframe(n)
+ return "%s:%s" % (os.path.basename(f.f_code.co_filename), f.f_lineno)
+
+def callerframe(n=2):
+ return sys._getframe(n)