def __new__(cls, name, bases, d):
        names = dict()
        values = []
        trans_names = dict()
        for x in d:
            if cls.is_enum_variable(x, d[x]):
                names[d[x]] = x
                values.append(d[x])
                trans_names[d[x]] = name + u"." + x
        d['names'] = names
        d['values'] = values
        d['trans_names'] = trans_names

        # create display names
        dn = lambda x: (x[0].title() + x[1:].lower()).replace('_', ' ')
        display_names = dict([(n[0], dn(n[1])) for n in d['names'].items()])
        # update with existing ones
        display_names.update(d.get('display_names', {}))
        d['display_names'] = display_names
        d['display_choices'] = map(lambda x: (x, d['display_names'][x]),
            sorted(d['values']))
        d['slugs'] = dict([(n[0], slugify(n[1]))
            for n in d['display_names'].items()])
        d['value_for_slug'] = dict([(n[1], n[0]) for n in d['slugs'].items()])

        # adding new fields
        for name, fun in d.get('EXTRA_FIELDS', cls.EXTRA_FIELDS).iteritems():
            d[name] = fun(d)

        d['enum_dict'] = dict([(v, {'value': v}) for v in values])
        for v in d['enum_dict']:
            for l in d.get('ENUM_FIELDS', cls.ENUM_FIELDS):
                if l in d and v in d[l]:
                    d['enum_dict'][v][l[:-1]] = d[l][v]

        return type.__new__(cls, name, bases, d)
dataset/ETHPy150Open ipeirotis/Mturk-Tracker/app/utils/enum.py/EnumMetaclass.__new__/original