Пример #1
0
def unicode_function(im):
    m = MetaModel.get_model_by_id(im.model_id).name
    if m == 'VideoCardMemoryQuantity':
        value = im.value
        if value % 1024 == 0:
            return '{} GB'.format(value / 1024)
        elif value > 512 and (value - 512) % 1024 == 0:
            return '{}.5 GB'.format((value - 512) / 1024)
        else:
            return '{} MB'.format(value)
Пример #2
0
def unicode_function(im):
    m = MetaModel.get_model_by_id(im.model_id).name
    if m == 'LightTube':
        specs = [str(im.l_type)]

        if im.consumption:
            if im.equivalent_power:
                specs.append(u'{} - {}W'.format(
                    im.consumption.quantize(0),
                    im.equivalent_power.quantize(0)))
            else:
                specs.append(u'{}W'.format(im.consumption.quantize(0)))
        else:
            if im.equivalent_power:
                specs.append(u'{}W Equivalente'.format(
                    im.equivalent_power.quantize(0)))

        specs.append(str(im.light_type))
        specs.append(str(im.length))

        name_value = im.name
        if name_value is None:
            name_value = ''

        result = u'{} {} {} ({})'.format(im.technology, im.brand, name_value,
                                         ' / '.join(specs))
        return ' '.join(result.split())
    if m == 'LightProjector':
        specs = []

        if im.consumption:
            if im.equivalent_power:
                specs.append(u'{} - {}W'.format(
                    im.consumption.quantize(0),
                    im.equivalent_power.quantize(0)))
            else:
                specs.append(u'{}W'.format(im.consumption.quantize(0)))
        else:
            if im.equivalent_power:
                specs.append(u'{}W Equivalente'.format(
                    im.equivalent_power.quantize(0)))

        specs.append(str(im.light_type))

        if im.has_movement_sensor:
            specs.append(u'Con sensor de movimimiento')

        name_value = im.name
        if name_value is None:
            name_value = ''

        result = u'{} {} {} ({})'.format(im.technology, im.brand, name_value,
                                         ' / '.join(specs))
        return ' '.join(result.split())
    if m == 'Lamp':
        specs = [str(im.socket), im.format.short_name]

        if im.consumption:
            if im.equivalent_power:
                specs.append(u'{} - {}W'.format(
                    im.consumption.quantize(0),
                    im.equivalent_power.quantize(0)))
            else:
                specs.append(u'{}W'.format(im.consumption.quantize(0)))
        else:
            if im.equivalent_power:
                specs.append(u'{}W Equivalente'.format(
                    im.equivalent_power.quantize(0)))

        specs.append(str(im.light_type))

        name_value = im.name
        if name_value is None:
            name_value = ''

        result = u'{} {} {} ({})'.format(im.l_type, im.brand, name_value,
                                         ' / '.join(specs))
        return ' '.join(result.split())
    if m == 'MemoryCardCapacity':
        if im.value % 1000 == 0:
            return u'{} TB'.format(im.value / 1000)
        elif im.value > 1000 and (im.value - 500) % 1000 == 0:
            return u'{}.5 TB'.format((im.value - 500) / 1000)
        else:
            return u'{} GB'.format(im.value)
    if m == 'MemoryCard':
        name_value = im.name
        if name_value is None:
            name_value = ''

        result = u'{} {} {} {}'.format(im.brand, name_value, im.type,
                                       im.capacity)

        if im.rated_speed.value:
            result += u' {}'.format(im.rated_speed)
        elif im.x_speed.value:
            result += u' {}'.format(im.x_speed)

        if im.sku:
            result += u' ({})'.format(im.sku)

        return result
    if m == 'UsbFlashDriveCapacity':
        if im.value % 1000 == 0:
            return u'{} TB'.format(im.value / 1000)
        elif im.value > 1000 and (im.value - 500) % 1000 == 0:
            return u'{}.5 TB'.format((im.value - 500) / 1000)
        else:
            return u'{} GB'.format(im.value)
    if m == 'UsbFlashDrive':
        if im.sku:
            return u'{} {} {} ({})'.format(im.line, im.name, im.capacity,
                                           im.sku)
        else:
            return u'{} {} {}'.format(im.line, im.name, im.capacity)