feat: basic style and layout

images de la nef et facades
This commit is contained in:
Matthieu Bessat 2022-09-29 19:00:28 +02:00
parent 6bc5fded11
commit 056c9345c9
86 changed files with 625 additions and 92 deletions

View file

@ -7,32 +7,44 @@ import os
import shutil
import magic
import mimetypes
import json
DEFAULT_TAGS = ['crypte']
SOURCE_DIR = './to_import_crypte/'
DEFAULT_TAGS = ['interieur-nef']
SOURCE_DIR = './to_import_interieur_nef/'
CONTENT_DIR = '../content/images/'
# get the current index for the outputdir
content_dir_files = os.listdir(CONTENT_DIR)
current_index = 1
if len(content_dir_files) > 0:
current_index = max(sorted([int(r) for r in content_dir_files]))+1
id_lists = []
for dir in content_dir_files:
try:
dir_as_integer = int(dir)
except ValueError:
continue
id_lists.append(dir_as_integer)
current_index = max(sorted(id_lists))+1
print(f"current index is {current_index}")
processed_images = []
to_import_files = os.listdir(SOURCE_DIR)
created_dirs = []
final_image_list = []
for original_file_name in to_import_files:
print(f'> {current_index} loading {original_file_name}')
new_dir_name = str(current_index).zfill(5) + '/'
# new_dir_name = str(current_index).zfill(5) + '/'
new_dir_name = str(current_index) + '/'
if os.path.exists(CONTENT_DIR + new_dir_name):
continue
os.mkdir(CONTENT_DIR + new_dir_name)
created_dirs.append(new_dir_name)
image_old_path = SOURCE_DIR + original_file_name
mime_type = magic.from_file(image_old_path, mime=True)
@ -65,14 +77,19 @@ for original_file_name in to_import_files:
image_md.write("title: Image\n")
image_md.write(f"original_name: {img['original_name']}\n")
image_md.write(f"mime_type: {img['mime_type']}\n")
image_md.write(f"tags: {img['tags']}\n")
image_md.write(f"imtags:\n")
for t in img['tags']:
image_md.write(f" - {t}\n")
image_md.write("---\n")
image_md.write("\n")
# description about the image goes after (like the legend)
image_md.close()
final_image_list.append(img)
current_index += 1
print(json.dumps(created_dirs))
print(json.dumps(final_image_list))
# import json
# import pathlib