Fix ID generation for relative paths (#35)

So far, there was implicit assumption on the used paths being absolute.

Co-authored-by: Inga Ulusoy <inga.ulusoy@uni-heidelberg.de>
Этот коммит содержится в:
Dominic Kempf 2022-12-13 11:33:34 +01:00 коммит произвёл GitHub
родитель 81838d0b86
Коммит ef305ee94c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"image_faces": {
"filename": "/test/data/image_faces.jpg"},
"image_objects":
{"filename": "/test/data/image_objects.jpg"}
"filename": "./test/data/image_faces.jpg"},
"image_objects":
{"filename": "./test/data/image_objects.jpg"}
}

Просмотреть файл

@ -12,8 +12,8 @@ def test_find_files():
def test_initialize_dict():
result = [
"/test/data/image_faces.jpg",
"/test/data/image_objects.jpg",
"./test/data/image_faces.jpg",
"./test/data/image_objects.jpg",
]
mydict = ut.initialize_dict(result)
with open("./test/data/example_utils_init_dict.json", "r") as file:

Просмотреть файл

@ -75,8 +75,8 @@ def find_files(path=None, pattern="*.png", recursive=True, limit=20):
def initialize_dict(filelist: list) -> dict:
mydict = {}
for img_path in filelist:
id_ = img_path.split(".")[0].split("/")[-1]
mydict[id_] = {"filename": img_path}
id = os.path.splitext(os.path.basename(img_path))[0]
mydict[id] = {"filename": img_path}
return mydict