@classmethod
    def _preprocess_tags(cls, tags):
        if not tags:
            return tags
        tags = {k.strip().lower(): v for k, v in tags.iteritems()}
        tags = {k: v for k, v in tags.iteritems()
                if len(k) in range(2, 64) and v >= 0}
        # answer to the ultimate question of life, the universe,
        # the optimal number of considerable tags and everything
        limit = 42
        if len(tags) > limit:
            # tags with scores
            if any(tags.itervalues()):
                min_val = max(tags.itervalues()) / 3
                tags = {k: v for k, v in tags.iteritems() if v >= min_val}
                tags = sorted(tags.iteritems(), key=operator.itemgetter(1),
                              reverse=1)  # best tags
            # tags without scores
            else:
                tags = sorted(tags.iteritems(), key=len)  # shortest tags
            tags = {k: v for k, v in tags[:limit]}
        return tags
connection rolls back before close
dataset/ETHPy150Open YetAnotherNerd/whatlastgenre/wlg/dataprovider.py/DataProvider._preprocess_tags--crossover with--dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/cx_Oracle-5.1.2/test/uConnection.py/TestConnection.testRollbackOnClose