def stage_attributes(self, attribute: str, unit_value: str,
                      bespoke_unit_tag: int, bespoke_sub_theme: int,
                      description: str) -> db.Model:
     """
     Stage Attributes
     :param attribute: Attribute
     :param unit_value: Unit Value
     :param bespoke_unit_tag: Unit Id
     :param bespoke_sub_theme: SubTheme Id
     :param description: Attributes Description
     :return: Attribute instance
     """
     _a = Attributes._get_by_name_unit_unitvalue(attribute,
                                                 bespoke_unit_tag,
                                                 unit_value)
     if _a:
         logger.info(
             '{} attribute with Unit ID: {} and Unit Value: {} already exists'
             .format(attribute, str(bespoke_unit_tag), unit_value))
         return _a
     a = Attributes(id=str(uuid.uuid4()),
                    name=attribute,
                    table_name=(attribute + '_' +
                                str(uuid.uuid4()).replace('-', '_')),
                    sub_theme=bespoke_sub_theme,
                    unit=bespoke_unit_tag,
                    unit_value=str(unit_value),
                    description=description)
     a = a.save()
     return a
Esempio n. 2
0
    def stage_attributes(self, attribute: str, unit_value: str,
                         bespoke_unit_tag: int, bespoke_sub_theme: int,
                         description: str):
        _a = Attributes._get_by_name_unit_unitvalue(attribute,
                                                    bespoke_unit_tag,
                                                    unit_value)
        if _a:
            print(attribute, 'attribute with Unit ID:', str(bespoke_unit_tag),
                  'and Unit Value:', unit_value, 'already exists')
            return _a

        a = Attributes(id=str(uuid.uuid4()),
                       name=attribute,
                       table_name=(attribute + '_' +
                                   str(uuid.uuid4()).replace('-', '_')),
                       sub_theme=bespoke_sub_theme,
                       unit=bespoke_unit_tag,
                       unit_value=str(unit_value),
                       description=description)
        a = a.save()
        return a