File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
+ import re
2
3
import requests
3
4
4
5
def main ():
@@ -24,10 +25,17 @@ def main():
24
25
response .raise_for_status ()
25
26
issue = response .json ()
26
27
27
- # Парсим тело issue
28
+ # Извлечение тела issue
28
29
body = issue .get ("body" , "" )
29
- subject = next ((line .split (": " )[1 ] for line in body .splitlines () if line .startswith ("Предмет" )), None )
30
- error_number = next ((line .split (": " )[1 ] for line in body .splitlines () if line .startswith ("Номер с ошибкой" )), None )
30
+ if not body :
31
+ raise ValueError ("Тело issue пустое. Убедитесь, что issue создано с корректным шаблоном." )
32
+
33
+ # Парсим тело issue
34
+ subject_match = re .search (r"(?i)^### Предмет\s*(.+)$" , body , re .MULTILINE )
35
+ error_number_match = re .search (r"(?i)^### Номер с ошибкой\s*(.+)$" , body , re .MULTILINE )
36
+
37
+ subject = subject_match .group (1 ).strip () if subject_match else None
38
+ error_number = error_number_match .group (1 ).strip () if error_number_match else None
31
39
32
40
if not subject or not error_number :
33
41
raise ValueError ("Не удалось извлечь 'Предмет' или 'Номер с ошибкой' из тела issue." )
You can’t perform that action at this time.
0 commit comments