Check if a file or a folder exists

def check_exists(path, type='file'):
    """ Check if a file or a folder exists """

    if type == 'file':
        if not os.path.isfile(path):
            raise RuntimeError('The file `%s` does not exist.' % path)
    else:
        if not os.path.isdir(path):
            raise RuntimeError('The folder `%s` does not exist.' % path)

    return True