'Get the fields to include/exclude for the specified table.
@param tablename: the tablename
@return: tuple of lists (include, exclude) of fields to
include or exclude. None indicates "all fields",
whereas an empty list indicates "no fields".'

def get_fields(self, tablename):

    ANY = 'ANY'
    default = (None, None)
    tree = self.tree
    if (not tree):
        return default
    if (self.select is None):
        self.__inspect()
    def find_match(items, tablename, default):
        if (tablename in items):
            match = items[tablename]
        else:
            match = False
            maxlen = 0
            for (tn, fields) in items.iteritems():
                if ('*' in tn):
                    m = re.match(tn.replace('*', '.*'), tablename)
                    if (not m):
                        continue
                    l = m.span()[(-1)]
                    if (l > maxlen):
                        match = fields
            if (match is False):
                match = items.get(ANY, default)
        return match
    select = find_match(self.select, tablename, None)
    skip = find_match(self.skip, tablename, set())
    if skip:
        if select:
            include = [fn for fn in select if (fn not in skip)]
            exclude = [fn for fn in skip if (fn not in select)]
        else:
            include = None
            exclude = list(skip)
    else:
        include = (list(select) if select else None)
        exclude = []
    return (include, exclude)
