Formatting

This commit is contained in:
Dominik Reh
2022-10-15 15:32:23 +02:00
parent 2f0d18a73f
commit b8b0673e2d
2 changed files with 11 additions and 7 deletions

View File

@@ -10,19 +10,23 @@ EMB_PATH = os.path.join(FILE_DIR, 'embeddings')
# The path to the temporary file
TEMP_PATH = os.path.join(FILE_DIR, 'tags/temp')
def get_wildcards():
"""Returns a list of all wildcards"""
return filter(lambda f: f.endswith(".txt"), os.listdir(WILDCARD_PATH))
def get_embeddings():
"""Returns a list of all embeddings"""
return filter(lambda f: f.endswith(".bin") or f.endswith(".pt"), os.listdir(EMB_PATH))
def write_to_temp_file(name, data):
"""Writes the given data to a temporary file"""
with open(os.path.join(TEMP_PATH, name), 'w') as f:
f.write(('\n'.join(data)))
# Check if the temp path exists and create it if not
if not os.path.exists(TEMP_PATH):
os.makedirs(TEMP_PATH)
@@ -41,4 +45,4 @@ if os.path.exists(WILDCARD_PATH):
if os.path.exists(EMB_PATH):
embeddings = get_embeddings()
if embeddings:
write_to_temp_file('emb.txt', embeddings)
write_to_temp_file('emb.txt', embeddings)