Skip to content

Commit

Permalink
store functionality of meta data done
Browse files Browse the repository at this point in the history
  • Loading branch information
vgoehler committed Mar 3, 2020
1 parent bd290df commit 7f9a3bc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/python_eulerian_video_magnification/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import json
import os.path
from datetime import datetime

from python_eulerian_video_magnification.mode import Mode

Expand All @@ -21,7 +22,8 @@ def __init__(self, file_name: str, output_folder: str,
'levels': levels,
'amplification': amplification,
'mode': mode.name,
'suffix': suffix
'suffix': suffix,
'date': None,
}

@staticmethod
Expand All @@ -32,3 +34,10 @@ def output_file_name(filename: str, suffix: str, path: str, generate_json=False)

def __getitem__(self, item):
return self.__data[item]

def save_meta_data(self):
"""stores the meta data dictionary as a json"""
self.__data['date'] = str(datetime.now())
with open(self.__data['meta_target'], 'w') as fp:
json.dump(self.__data, fp=fp, sort_keys=True, indent=4, separators=(',', ': '))

19 changes: 18 additions & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os.path

from python_eulerian_video_magnification.metadata import MetaData
from python_eulerian_video_magnification.mode import Mode

Expand Down Expand Up @@ -32,4 +34,19 @@ def test_for_data_as_expected():
'target': "/out/put/gob_color_evm.avi",
'meta_target': "/out/put/gob_color_evm.json", 'low': 0.1, 'high': 2.1,
'levels': 4,
'amplification': 23, 'mode': 'COLOR', 'suffix': 'color'}
'amplification': 23, 'mode': 'COLOR', 'suffix': 'color', 'date': None}


def test_json_save(tmp_path):
sut = MetaData(
file_name="/fu/bar/gob.avi",
output_folder=str(tmp_path),
mode=Mode.COLOR,
suffix="color",
low=0.1,
high=2.1,
levels=4,
amplification=23
)
sut.save_meta_data()
assert os.path.exists(sut['meta_target'])

0 comments on commit 7f9a3bc

Please sign in to comment.