1. Python / Говнокод #6117

    −97

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    if row[0].find('lk_s_du') > -1 or row[0].find('lk_s_su') > -1:
        price = ''
        if row[6] == 'incoming_external':
            if tariff['ie_price_second'] == 0:
                price = row[5] * tariff['ie_price_first'] / 102400
            elif ie_global > tariff['ie_price_switch']:
                price = row[5] * tariff['ie_price_second'] / 102400
            else:
                price = overhead(tariff['ie_price_switch']-ie_global,tariff['ie_price_switch'])*tariff['ie_price_first'] / 102400 + hev((row[5]+ie_global-tariff['ie_price_switch']))*tariff['ie_price_second'] / 102400
            ie_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        if row[6] == 'internal':
            if tariff['il_price_second'] == 0:
                price = row[5] * tariff['il_price_first'] / 102400
            elif il_global > tariff['il_price_switch']:
                price = row[5] * tariff['il_price_second'] / 102400
            else:
                price = overhead(tariff['il_price_switch']-il_global,tariff['il_price_switch'])*tariff['il_price_first'] / 102400 + hev((row[5]+il_global-tariff['il_price_switch']))*tariff['il_price_second'] / 102400
            il_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        if row[6] == 'outgoing_any':
            if tariff['oe_price_second'] == 0:
                price = row[5] * tariff['oe_price_first'] / 102400
            elif oe_global > tariff['oe_price_switch']:
                price = row[5] * tariff['oe_price_second'] / 102400
            else:
                price = overhead(tariff['oe_price_switch']-oe_global,tariff['oe_price_switch'])*tariff['oe_price_first'] / 102400 + hev((row[5]+oe_global-tariff['oe_price_switch']))*tariff['oe_price_second'] / 102400
            oe_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        price = str(price).replace('.',',')

    Черная магия непосредственно тарификации интернет-трафика.

    Запостил: spaceoflabview, 29 Марта 2011

    Комментарии (7) RSS

    Добавить комментарий