List files for an installed package

def list_files(package, conn=None):
    '''
    List files for an installed package
    '''
    close = False
    if conn is None:
        close = True
        conn = init()

    data = conn.execute('SELECT package FROM packages WHERE package=?', (package, ))
    if not data.fetchone():
        if close:
            conn.close()
        return None

    ret = []
    data = conn.execute('SELECT path, sum FROM files WHERE package=?', (package, ))
    for file_ in data.fetchall():
        ret.append(file_)
    if close:
        conn.close()

    return ret