Skip to content

Commit

Permalink
removed pipe_exception_handler (did more harm than good most of the t…
Browse files Browse the repository at this point in the history
…ime)
  • Loading branch information
0101 committed Sep 2, 2013
1 parent 9a0d42d commit 2bcc41b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 55 deletions.
16 changes: 0 additions & 16 deletions pipetools/debug.py
@@ -1,4 +1,3 @@
from contextlib import contextmanager
from itertools import imap, chain


Expand All @@ -22,21 +21,6 @@ def get_name(f):
return f.__name__ if hasattr(f, '__name__') else repr(f)


@contextmanager
def pipe_exception_handler(name):
try:
yield
except Exception, ex:
message = '%s\n in %s' % (ex, name())
try:
# some exceptions might be bit more complicated to construct
# in which case... we're screwed
pipe_exception = type(ex)(message)
raise pipe_exception
except:
raise


def repr_args(*args, **kwargs):
return ', '.join(chain(
imap('{0!r}'.format, args),
Expand Down
9 changes: 3 additions & 6 deletions pipetools/main.py
@@ -1,7 +1,6 @@
from functools import partial, wraps

from pipetools.debug import get_name, set_name, repr_args
from pipetools.debug import pipe_exception_handler


class Pipe(object):
Expand Down Expand Up @@ -29,8 +28,7 @@ def compose(first, second):
name = lambda: '{0} | {1}'.format(get_name(first), get_name(second))

def composite(*args, **kwargs):
with pipe_exception_handler(lambda: 'pipe | ' + name()):
return second(first(*args, **kwargs))
return second(first(*args, **kwargs))
return set_name(name, composite)

@classmethod
Expand Down Expand Up @@ -66,9 +64,8 @@ def compose(first, second):
name = lambda: '{0} ?| {1}'.format(get_name(first), get_name(second))

def composite(*args, **kwargs):
with pipe_exception_handler(lambda: 'maybe ?| ' + name()):
result = first(*args, **kwargs)
return None if result is None else second(result)
result = first(*args, **kwargs)
return None if result is None else second(result)
return set_name(name, composite)

def __call__(self, *args, **kwargs):
Expand Down
33 changes: 0 additions & 33 deletions test_pipetools/test_debug.py

This file was deleted.

0 comments on commit 2bcc41b

Please sign in to comment.