class Priority(object):
    """Item layer priority levels.
    """

    def __init__(self, item_list):
        self._priority = dict(
            earring_front=99,
            bag_front=98,
            hairstyle_front=97,
            outwear_front=20,
            bottoms_front=19,
            dress_front=18,
            blouse_front=17,
            skirt_front=16,
            trousers_front=15,
            tops_front=14,
            shoes_right=1,
            shoes_left=1,
            body=0,
            tops_back=-14,
            trousers_back=-15,
            skirt_back=-16,
            blouse_back=-17,
            dress_back=-18,
            bottoms_back=-19,
            outwear_back=-20,
            hairstyle_back=-97,
            bag_back=-98,
            earring_back=-99,
        )
        self.clothing_start_num = 10
        if not isinstance(item_list, list):
            raise ValueError('item_list must be a list!')
        for cate in item_list:
            cate = cate.lower()
            if cate not in ('outwear', 'dress', 'blouse', 'skirt', 'trousers', 'tops', 'bottoms'):
                raise ValueError(f'Item type error. Cannot recognize {cate}')
        for i, cate in enumerate(item_list):
            cate = cate.lower()
            self._priority[f'{cate}_front'] = self.clothing_start_num - i
            self._priority[f'{cate}_back'] = -(self.clothing_start_num - i)

    @property
    def priority(self):
        return self._priority
