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

    0

    1. 1
    https://github.com/yuki-iptv/yuki-iptv/blob/master/usr/lib/yuki-iptv/yuki_iptv/epg_txt.py

    gazovaya_eblya, 29 Июля 2023

    Комментарии (4)
  2. Python / Говнокод #28807

    0

    1. 1
    During handling of the above exception, another exception occurred

    А бывает "Исключение возникло при обработке исключения, которое возникло при попытке обработать исключение"?

    3_dar, 27 Июня 2023

    Комментарии (21)
  3. Python / Говнокод #28796

    0

    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
    @dataclass(slots=True)
    class Govno:
        govno_index: int
        
        def patch(self, indices_dict: Dict[int, int]) -> None:
            new_index = indices_dict[self.govno_index]
            self.govno_index = new_index
    
    
    @dataclass(slots=True)
    class Mocha:
        mocha_index: int
        
        def patch(self, indices_dict: Dict[int, int]) -> None:
            new_index = indices_dict[self.govno_index]
            self.govno_index = new_index

    Метод «patch» был скопипащен из класса «Govno» в класс «Mocha». Тайпчекер никаких ошибок не показывал; все типы были выведены корректно.

    А в рантайме всё упало, что и неудивительно!

    ISO, 13 Июня 2023

    Комментарии (42)
  4. Python / Говнокод #28735

    0

    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
    from miditk.smf    import MidiSequence
    from miditk.common import constants
    from sys           import argv
    import datetime
    
    sequence = MidiSequence.fromfile(argv[1])
    dt0      = datetime.datetime(1,1,1)
    tail     = ''
    
    for time, group in sequence.events_by_time():
         ms          = datetime.timedelta(milliseconds=time)
         pretty_time = (dt0+ms).strftime('%M:%S.%f')[:-4]
         
         for ev in group:
             if ev.meta_type == constants.TEXT:
                 text = ev.data.decode('windows-1251')
                 if text and (text[0] == '@' or text[0] == '/' or text[0] == '\\'):
                     if tail: # выводим отложенный текст
                         if tail[0] == '\\': # отбиваем абзац
                             print(f'[{pt}]') 
                         if tail[0] == '@':  # шапка, убираем префиксы типа @T, @L
                             print(f'[{pt}]{tail[2:]}')
                         else:
                             print(f'[{pt}]{tail[1:]}')
                     pt = pretty_time
                     tail = text
                 else:        # откладываем текст на потом
                   tail = tail + text

    Наговнякал на коленках конь-вертер текстов песен из .KAR (.midi со словами в событиях типа 1 = TEXT) в .LRC, чтобы готовые тексты можно было использовать с проигрывателями mp3- или flac-файлов.

    Зависит от https://pypi.org/project/miditk-smf/

    ropuJIJIa, 12 Апреля 2023

    Комментарии (1324)
  5. Python / Говнокод #28655

    −1

    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
    def get_decrease_fan_speed_delta(fan_speed: float, delta: float, turn_off: bool):
        # if the fan is already running slower than minimum speed
        if fan_speed < MIN_FAN_SPEED:
            # we ignore the turn_off argument and always set the fan off
            return -fan_speed
        # if fan would be running slower than minimum speed after decreasing it by delta:
        if (fan_speed - delta) < MIN_FAN_SPEED:
            if turn_off:
                return -fan_speed  # turn the fan off
            else:
                return -fan_speed + MIN_FAN_SPEED  # make it run at minimum speed
        return -delta
    
    
    def get_increase_fan_speed_delta(fan_speed, delta):
        new_fan_speed = fan_speed + delta
        # if fan would be running faster than maximum speed
        if new_fan_speed > 100:
            return 100 - fan_speed  # cap it at 100%
        elif new_fan_speed < MIN_FAN_SPEED:
            return MIN_FAN_SPEED - fan_speed  # jump to minimum fan speed
        return delta
    
    
    def compute_fan_speed_delta(temp: float, temp_delta: float, fan_speed: float):
        if temp >= HOT:
            return get_increase_fan_speed_delta(fan_speed, 100.0)
    
        if temp <= COLD:
            # if temperature is decreasing, we slowly decrease the fan speed
            if temp_delta < 0.0:
                return get_decrease_fan_speed_delta(fan_speed, FAN_DELTA, turn_off=True)
            # if temperature is constant or increasing we don't change fan speed
            # until it rises above COLD
            return 0.0
    
        # if temperature is decreasing we decrease fan speed slowly
        if temp_delta < 0.0:
            return get_decrease_fan_speed_delta(fan_speed, FAN_DELTA, turn_off=False)
    
        # if temperature is increasing we increase fan speed slowly
        if temp_delta > 0.0:
            return get_increase_fan_speed_delta(fan_speed, FAN_DELTA)
    
        # if temperature is not changing, don't change the fan speed
        return 0.0

    GAMER, 30 Марта 2023

    Комментарии (3)
  6. Python / Говнокод #28652

    0

    1. 1
    https://gitlab.com/muzena/iptv/-/blob/master/usr/lib/astronciaiptv/astroncia_iptv.py

    тут каждая строчка - это говнокод

    ACTPE9I, 27 Марта 2023

    Комментарии (2)
  7. Python / Говнокод #28638

    0

    1. 1
    AttributeError: type object 'datetime.datetime' has no attribute 'from_timestamp'. Did you mean: 'fromtimestamp'?

    ISO, 19 Марта 2023

    Комментарии (24)
  8. Python / Говнокод #28622

    −9

    1. 1
    саша степуро негр

    правда

    sashastepuronegro, 04 Марта 2023

    Комментарии (4)
  9. Python / Говнокод #28621

    −8

    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
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    print('1 часть тут, 2 в описании')
    import re
    q = int(input())
    b = input()
    v = 0
    flag = True
    if v == 0:
        c = len(re.findall('q', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('w', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('e', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('r', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('t', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('y', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('u', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('i', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('o', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('p', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('a', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('s', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('d', b))
        if c > 1:
            print("NO")
            flag = False
            quit()
        else:
            v = 3
        c = len(re.findall('f', b))

    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('g', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('h', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('j', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('k', b))
    if c > 1:
    print("NO")
    flag = False
    quit
    else:
    v = 3
    c = len(re.findall('l', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('m', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('n', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('b', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('v', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('c', b))
    if c > 1:
    print("NO")
    flag = False
    quit()
    else:
    v = 3
    c = len(re.findall('x', b))
    if c > 1:
    flag = False
    quit()
    print("NO")
    else:
    v = 3
    c = len(re.findall('z', b))
    if c > 1:
    flag = False
    print("NO")
    quit()
    else:
    v = 3
    if flag == True:
    print("YES")

    sashastepuronegro, 04 Марта 2023

    Комментарии (3)
  10. Python / Говнокод #28618

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    def auth_2FA(request):
        mail = request.POST.get('mail')
        user = User.objects.get(email=mail)
        code2FA = request.POST.get('code2FA')
        if pyotp.TOTP(user.secret).verify(code2FA):
            auth.login(request, user)
            return redirect(settings.HOME_PAGE)
        else:
            ...

    # Безопасность
    Django, двухфакторка.
    Защиты от перебора нет, пароль не проверяется. Зная только mail можно залогиниться перебрав код из 6 цифр

    Doorman5302, 01 Марта 2023

    Комментарии (12)