refactor: move ifind pool helpers to feature service
This commit is contained in:
@@ -117,6 +117,30 @@ class PoolServiceMixin:
|
||||
finally:
|
||||
self._ifind_event_lock.release()
|
||||
|
||||
@staticmethod
|
||||
def _ifind_field(row: dict[str, Any], tokens: tuple[str, ...]) -> Any:
|
||||
for key, value in row.items():
|
||||
label = str(key or "")
|
||||
if any(token.casefold() == label.casefold() for token in tokens):
|
||||
return value
|
||||
for key, value in row.items():
|
||||
label = str(key or "")
|
||||
if any(token in label for token in tokens):
|
||||
return value
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def _ifind_row_code(cls, row: dict[str, Any]) -> str:
|
||||
value = cls._ifind_field(row, ("股票代码", "证券代码", "代码", "thscode"))
|
||||
match = re.search(r"(?<!\d)(\d{6})(?!\d)", str(value or ""))
|
||||
if match:
|
||||
return match.group(1)
|
||||
for value in row.values():
|
||||
match = re.search(r"(?<!\d)(\d{6})\.(?:SH|SZ|BJ)(?![A-Z])", str(value or ""), re.I)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return ""
|
||||
|
||||
@staticmethod
|
||||
def _normalize_ifind_event_time(value: Any) -> str:
|
||||
text = str(value or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user