/
maratn
/
CheckPDF
Обзор
Документация
Войти
/
maratn
/
CheckPDF
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
check_numbers_sheets.py
53 строки
2 KB
Marat
some fixed replace '-'
09 май 2026, 17:34
09 май 2026, 17:34
f6088ca
Код
Авторство
О чём код?
def numbers_sheets(a_list): first_sheet = 0 second_sheet = 0 thirth_sheet = 0 # new_list = [x.strip().split()[-1] if type(x) == str else x for x in a_list] new_list = [x.split() if type(x) == str else x for x in a_list] # print(a_list) for k, i in enumerate(new_list): if i[-1] == '-': i = i[-2] try: i = i.replace('-', '') except: #print(f"error replace {i}") pass try: fourth_sheet = int(i) if fourth_sheet < 0: fourth_sheet = thirth_sheet+1 first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet continue if fourth_sheet == thirth_sheet+1: first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet elif fourth_sheet == thirth_sheet: print('Repit sheet', thirth_sheet) elif fourth_sheet == thirth_sheet+2: print('lost the page number', thirth_sheet+1) first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet elif thirth_sheet > fourth_sheet: first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet elif -25 < fourth_sheet - thirth_sheet < 25: print('lost some sheets:', thirth_sheet+1, '-', fourth_sheet-1) first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet elif -25 > fourth_sheet - thirth_sheet > 25: fourth_sheet = thirth_sheet+1 first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet else: first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet except (ValueError, TypeError): fourth_sheet = thirth_sheet+1 first_sheet, second_sheet, thirth_sheet = second_sheet, thirth_sheet, fourth_sheet except Exception as e: print(f"Тип ошибки: {type(e).__name__}") print(f"An error occurred while processing {i}: {e}") return new_list if __name__ == '__main__': list_pages = [None, 'werr', 3, 4, 'ddr', 5, 6, 7,\ None, 8, 9, 'nnii', 'nnii', 'fdt', 'dttf',\ 345, -35, 15, 16, 'ert 17', 18, 20, 21, 33] n_list = numbers_sheets(list_pages)