1313 StatementPeriod ,
1414)
1515
16- from .regex import SUMMARY_DATE_RE , SUMMARY_ROW_RE
16+ from .regex import SCHEME_TAIL_RE , SUMMARY_DATE_RE , SUMMARY_ROW_RE
1717from .utils import isin_search
1818
1919
@@ -43,6 +43,11 @@ def process_summary_text(text):
4343 for line in lines :
4444 if len (folios ) > 0 and re .search ("Total" , line , re .I ):
4545 break
46+ scheme_tail = ""
47+ if m := re .search (SCHEME_TAIL_RE , line , re .DOTALL | re .MULTILINE ):
48+ scheme_tail = m .group (1 ).strip ()
49+ line = line .replace (scheme_tail , "" )
50+ scheme_tail = re .sub (r"\s+" , " " , scheme_tail ).strip ()
4651 if m := re .search (SUMMARY_ROW_RE , line , re .DOTALL | re .MULTILINE | re .I ):
4752 folio = m .group ("folio" ).strip ()
4853 if current_folio is None or current_folio != folio :
@@ -55,7 +60,10 @@ def process_summary_text(text):
5560 PANKYC = "N/A" ,
5661 schemes = [],
5762 )
58- scheme = re .sub (r"\(formerly.+?\)" , "" , m .group ("name" ), flags = re .I | re .DOTALL ).strip ()
63+ scheme = m .group ("name" )
64+ if scheme_tail != "" :
65+ scheme = " " .join ([scheme , scheme_tail ])
66+ scheme = re .sub (r"\(formerly.+?\)" , "" , scheme , flags = re .I | re .DOTALL ).strip ()
5967 rta = m .group ("rta" ).strip ()
6068 rta_code = m .group ("code" ).strip ()
6169 isin_ = m .group ("isin" )
0 commit comments