Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
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-файлов.
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
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")