From 45368aa2f6ef5e2c309dda89724e62c9101ae468 Mon Sep 17 00:00:00 2001 From: "qichi.liang" Date: Mon, 29 Dec 2025 03:38:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=88=86?= =?UTF-8?q?=E9=9A=94=E7=AC=A6=E7=8F=AD=E6=AC=A1=E6=95=B0=E6=8D=AE=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E9=97=AE=E9=A2=98=EF=BC=8828=E5=8F=B7=E5=A4=9C?= =?UTF-8?q?=E7=8F=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parser.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/parser.py b/src/parser.py index 9d420c0..37e08df 100644 --- a/src/parser.py +++ b/src/parser.py @@ -60,7 +60,27 @@ class HandoverLogParser: 船次日志列表(已合并同日期同班次同船名的记录) """ logs = [] - blocks = text.split(self.SEPARATOR) + + # 预处理:移除分隔符行(只保留内容分隔符,去掉单行的) + # 分隔符应该是独立一行,且前后有内容的 + lines = text.split('\n') + processed_lines = [] + i = 0 + while i < len(lines): + line = lines[i] + if line.strip() == self.SEPARATOR: + # 检查是否是单行分隔符(前后都是分隔符或空行) + prev_is_sep = i > 0 and lines[i-1].strip() == self.SEPARATOR + next_is_sep = i < len(lines)-1 and lines[i+1].strip() == self.SEPARATOR + if not (prev_is_sep and next_is_sep): + # 单行分隔符,跳过 + i += 1 + continue + processed_lines.append(line) + i += 1 + + processed_text = '\n'.join(processed_lines) + blocks = processed_text.split(self.SEPARATOR) for block in blocks: if not block.strip() or '日期:' not in block: