def munge_source(v):
    """Take Python source code, return a pair of its parameters and the rest of it dedented"""
    lines = v.split('\n')
    if not lines:
        return tuple(), ''
    firstline = lines[0].lstrip()
    while firstline == '' or firstline[0] == '@':
        del lines[0]
        firstline = lines[0].lstrip()
    if not lines:
        return tuple(), ''
    params = tuple(
        parm.strip() for parm in
        sig_ex.match(lines[0]).group(1).split(',')
    )
    del lines[0]
    if not lines:
        return params, ''
    # hack to allow 'empty' functions
    if lines and lines[-1].strip() == 'pass':
        del lines[-1]
    return params, dedent('\n'.join(lines))
Take Python source code, return a pair of its parameters and the rest of it dedented