python类floatformat()的实例源码

models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def commission_records_orders(self):
        for v in Valuta.objects.all():
            yield v, floatformat(Orders.sum_from_commission(v.value), -8), v.pk
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def commission_records(self):
        for v in Valuta.objects.all():
            yield v, floatformat(self._commission_records(v.value), -8), v.pk
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def balance_left(self):
        return mark_safe("<span>{amo}<span> {pos}".format(**{"amo":floatformat(self.amount_left, -8), "pos":self.pair.left}))
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def balance_right(self):
        return mark_safe("<span>{amo}</span> {pos}".format(**{"amo":floatformat(self.amount_right, -8), "pos":self.pair.right}))
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def w_total_transaction(self):
        return "%s%s %s" % (self.action, floatformat(self._total_transaction, -8), self.valuta)
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def w_commission(self):
        if self.min_commission > _Zero and (self.value * self.commission / D(100)) < self.min_commission:
            return u"{commission} {valuta}".format(**{"commission":floatformat(self.min_commission, -8), "valuta": self.valuta})
        elif self.max_commission > _Zero and (self.value * self.commission / D(100)) > self.max_commission:
            return u"{commission} {valuta}".format(**{"commission":floatformat(self.max_commission, -8), "valuta": self.valuta})
        else:
            return u"{commission}%".format(**{"commission":self.commission,})
models.py 文件源码 项目:extrade 作者: aza7 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def total_admin(self):
        v = normalized(self.value - self._commission_debit, where="DOWN")
        return floatformat(v, -8)
humanize.py 文件源码 项目:producthunt 作者: davidgengler 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:django-rtc 作者: scifiswapnil 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:geekpoint 作者: Lujinghu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:django-next-train 作者: bitpixdigital 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:LatinSounds_AppEnviaMail 作者: G3ek-aR 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:DjangoZeroToHero 作者: RayParra 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
humanize.py 文件源码 项目:Roboism 作者: markroxor 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
serializers.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_percentage(self, obj):
        return floatformat(obj['share']*100, -2)
serializers.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_display_share(self, obj):
        return floatformat(obj['share']*100)
models.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def display_fee(self, amount=None):
        if amount is None:
            amount = self.pay
        if not amount:
            return ''
        if self.currency in CURRENCY_SYMBOLS:
            return '{}{}'.format(CURRENCY_SYMBOLS[self.currency], floatformat(amount, arg=-2))
        return amount or ''
models.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def display_fee(self, amount=None):
        if amount is None:
            amount = self.fee
        if self.currency in CURRENCY_SYMBOLS:
            return '{}{}'.format(CURRENCY_SYMBOLS[self.currency], floatformat(amount, arg=-2))
        return amount or ''
tunga_export_payments.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def handle(self, *args, **options):
        """
        Update periodic update events and send notifications for upcoming update events.
        """
        # command to run: python manage.py tunga_export_payments

        participant_payments = ParticipantPayment.objects.filter(participant__task__paid=True)

        print('participant_payments', len(participant_payments))
        with open('developer_payments.csv', 'wb') as csvfile:
            spamwriter = csv.writer(csvfile, delimiter=',',
                                    quotechar='"', quoting=csv.QUOTE_MINIMAL)
            spamwriter.writerow([
                'Task', 'Fee', 'Developer', 'Dev BTC Address', 'BTC Sent', 'Task BTC Address', 'Invoice Date',
                'Paid By', 'URL', 'Developer Invoice', 'Client Invoice'
            ])

            for payment in participant_payments:
                row = [
                    payment.participant.task.summary, 'EUR {}'.format(floatformat(payment.participant.task.fee, -2)),
                    payment.participant.user.display_name, payment.destination,
                    'BTC {}'.format(floatformat(payment.btc_sent, -6)), payment.participant.task.btc_address,
                    payment.participant.task.taskinvoice_set.first().created_at.strftime("%d %b, %Y"),
                    payment.participant.task.user.display_name,
                    '{}/work/{}'.format(TUNGA_URL, payment.participant.task.id),
                    '{}/api/task/{}/download/invoice/?format=pdf&type=developer'.format(TUNGA_URL, payment.participant.task.id),
                    '{}/api/task/{}/download/invoice/?format=pdf&type=client'.format(TUNGA_URL, payment.participant.task.id)
                ]
                spamwriter.writerow(row)
humanize.py 文件源码 项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value


问题


面经


文章

微信
公众号

扫码关注公众号