attachment_filename -> download_name

This commit is contained in:
Kikimanox
2022-08-29 23:31:59 +02:00
parent 77c5473142
commit 246c60de02
2 changed files with 6 additions and 4 deletions
+3 -3
View File
@@ -132,7 +132,7 @@ def get_conllu(file_id): # noqa: E501
:rtype: str
"""
try:
return send_file(util.get_conllu_file_path_by_id(file_id), attachment_filename=f'{file_id}.conllu')
return send_file(util.get_conllu_file_path_by_id(file_id), download_name=f'{file_id}.conllu')
except FileNotFoundError as e:
return "The conllu with this ID doesn't exist.", 404
@@ -148,7 +148,7 @@ def get_file(file_id): # noqa: E501
:rtype: List[bytearray]
"""
try:
return send_file(util.get_original_file_path_by_id(file_id), attachment_filename=f'{file_id}.xml')
return send_file(util.get_original_file_path_by_id(file_id), download_name=f'{file_id}.xml')
except FileNotFoundError as e:
return "The file with this ID doesn't exist.", 404
@@ -164,6 +164,6 @@ def oss_besedilo_po_id_get(file_id): # noqa: E501
:rtype: str
"""
try:
return send_file(util.get_original_file_path_by_id(file_id), attachment_filename=f'{file_id}.xml')
return send_file(util.get_original_file_path_by_id(file_id), download_name=f'{file_id}.xml')
except FileNotFoundError as e:
return "The file with this ID doesn't exist.", 404
+3 -1
View File
@@ -175,8 +175,10 @@ def get_files_by_keywords(kljucnebesede):
kljucnebesede = [k.lower() for k in kljucnebesede]
# Temporary solution until connection with mariadb is fixed
ngrams_path = "classla_OS2022/ngrams/" if is_docker() else "../mnt/ssd/ds_ftp/classla_OS2022/ngrams/"
print("Looping trough ngrams")
for path, dirs, files, in os.walk(ngrams_path):
for _file in files:
for i, _file in enumerate(files):
if i % 200 == 0: print(f"{i}/{len(files)}")
file = f'{ngrams_path}{_file}'
data = pd.read_csv(file, sep='\t')
amount = len(data[data['ngram_len'] == 1 & data['gram_text'].str.lower().isin(kljucnebesede)])