When removing the async calls I ended up wiping information on a callback, so moving...
[theonering] / src / util / misc.py
index 7abecf3..47924fa 100644 (file)
@@ -6,7 +6,6 @@ import sys
 import cPickle
 
 import functools
-import itertools
 import contextlib
 import inspect
 
@@ -231,6 +230,7 @@ def deprecated_api(func):
        def newFunc(*args, **kwargs):
                warnings.warn("Call to deprecated function %s." % func.__name__, category=DeprecationWarning)
                return func(*args, **kwargs)
+
        _append_docstring(newFunc, "\n@deprecated")
        return newFunc
 
@@ -411,6 +411,22 @@ def ExpHandler(handler = print_handler, *exceptions):
        return wrapper
 
 
+def into_debugger(func):
+       """
+       >>> validate_decorator(into_debugger)
+       """
+
+       @functools.wraps(func)
+       def newFunc(*args, **kwargs):
+               try:
+                       return func(*args, **kwargs)
+               except:
+                       import pdb
+                       pdb.post_mortem()
+
+       return newFunc
+
+
 class bindclass(object):
        """
        >>> validate_decorator(bindclass)
@@ -624,3 +640,16 @@ def lexical_scope(*args):
                for key in (x for x in f_locals.keys() if x not in saved):
                        del f_locals[key]
                del frame
+
+
+def strip_number(prettynumber):
+       """
+       function to take a phone number and strip out all non-numeric
+       characters
+
+       >>> strip_number("+012-(345)-678-90")
+       '01234567890'
+       """
+       import re
+       uglynumber = re.sub('\D', '', prettynumber)
+       return uglynumber