'Extracts table name and constraints from given .table file.
@param file_str: the name of a .table file.
@return: (table_name, constraint_iter) where constraint_iter yields
the names of tables on which this table depends.'

def get_table_info(self, file_str):

    try:
        table_file = open(os.path.join(self.dbdir_str, file_str), 'r')
    except:
        raise ValueError, ("Couldn't    read    file    %s" % file_str)
    table_name = file_str.split('.', 1)[0].split('_', 1)[1]
    def constraint_iter():
        '    Find    constraint    lines    in    the    file,    yield    the    primary    table    name.\n\n                                                Constraint    lines    contain    the    word    REFERENCES    and    the    following\n                                                term    (minus    punctuation)    is    the    primary    table    name    for    this\n                                                foreign    key    reference.\n                                                '
        for line in table_file:
            terms = self.cleanup(line).split()
            try:
                primary_index = (terms.index('REFERENCES') + 1)
            except:
                continue
            if (len(terms) > primary_index):
                primary_name = terms[primary_index]
                (yield primary_name)
    return (table_name, constraint_iter)
