(channel_data: list, chn_type: str, cfg_list: list)
| 326 | classifier.classify(channel_name, channel_address, new_line) |
| 327 | |
| 328 | def sort_channel_data(channel_data: list, chn_type: str, cfg_list: list) -> list: |
| 329 | if not channel_data: |
| 330 | return channel_data |
| 331 | |
| 332 | if chn_type in ORDERED_CHANNEL_TYPES: |
| 333 | cfg_index_map = {cfg_name: idx for idx, cfg_name in enumerate(cfg_list)} |
| 334 | def _ordered_key(line): |
| 335 | name = line.split(',')[0] if ',' in line else "" |
| 336 | return cfg_index_map.get(name, len(cfg_list)) |
| 337 | return sorted(channel_data, key=_ordered_key) |
| 338 | else: |
| 339 | def _dict_key(line): |
| 340 | name = line.split(',')[0] if ',' in line else "" |
| 341 | pure_name = re.sub(r'[^\w\u4e00-\u9fff]', '', name) |
| 342 | return pure_name if pure_name else name |
| 343 | return sorted(channel_data, key=_dict_key) |
| 344 | |
| 345 | def generate_live_text(classifier: ChannelClassifier, main_dict: dict) -> tuple[list, list]: |
| 346 | bj_time = datetime.now(timezone.utc) + timedelta(hours=8) |
no outgoing calls
no test coverage detected