fix event loop conflict
This commit is contained in:
@@ -9,7 +9,7 @@ import re
|
||||
from dataclasses import dataclass
|
||||
from functools import wraps
|
||||
from hashlib import md5
|
||||
from typing import Any, Union,List
|
||||
from typing import Any, Union, List
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
@@ -176,19 +176,20 @@ def truncate_list_by_token_size(list_data: list, key: callable, max_token_size:
|
||||
return list_data[:i]
|
||||
return list_data
|
||||
|
||||
|
||||
def list_of_list_to_csv(data: List[List[str]]) -> str:
|
||||
output = io.StringIO()
|
||||
writer = csv.writer(output)
|
||||
writer.writerows(data)
|
||||
return output.getvalue()
|
||||
|
||||
|
||||
def csv_string_to_list(csv_string: str) -> List[List[str]]:
|
||||
output = io.StringIO(csv_string)
|
||||
reader = csv.reader(output)
|
||||
return [row for row in reader]
|
||||
|
||||
|
||||
|
||||
|
||||
def save_data_to_file(data, file_name):
|
||||
with open(file_name, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
@@ -253,13 +254,14 @@ def xml_to_json(xml_file):
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def process_combine_contexts(hl, ll):
|
||||
header = None
|
||||
list_hl = csv_string_to_list(hl.strip())
|
||||
list_ll = csv_string_to_list(ll.strip())
|
||||
|
||||
if list_hl:
|
||||
header=list_hl[0]
|
||||
header = list_hl[0]
|
||||
list_hl = list_hl[1:]
|
||||
if list_ll:
|
||||
header = list_ll[0]
|
||||
@@ -268,19 +270,17 @@ def process_combine_contexts(hl, ll):
|
||||
return ""
|
||||
|
||||
if list_hl:
|
||||
list_hl = [','.join(item[1:]) for item in list_hl if item]
|
||||
list_hl = [",".join(item[1:]) for item in list_hl if item]
|
||||
if list_ll:
|
||||
list_ll = [','.join(item[1:]) for item in list_ll if item]
|
||||
list_ll = [",".join(item[1:]) for item in list_ll if item]
|
||||
|
||||
combined_sources_set = set(
|
||||
filter(None, list_hl + list_ll)
|
||||
)
|
||||
combined_sources_set = set(filter(None, list_hl + list_ll))
|
||||
|
||||
combined_sources = [",\t".join(header)]
|
||||
|
||||
for i, item in enumerate(combined_sources_set, start=1):
|
||||
combined_sources.append(f"{i},\t{item}")
|
||||
|
||||
|
||||
combined_sources = "\n".join(combined_sources)
|
||||
|
||||
return combined_sources
|
||||
|
Reference in New Issue
Block a user