changed print_memories_info() to print_memory_info()

This commit is contained in:
lmluk
2024-09-03 15:04:00 +02:00
parent 53f263a8d8
commit 52357cfd96

29
main.py
View File

@@ -7,18 +7,27 @@ def get_img_filename(image: json):
def get_memory_location(memory: json): def get_memory_location(memory: json):
return memory['location'] if 'location' in memory else 'N/A' return memory['location'] if 'location' in memory else 'N/A'
def print_memories_info(data: json): def print_memory_info(memory: json):
n = 0 """
for i in data: Takes a memory object from the ``memories.json`` file and prints out all necessarily information like:
print("\nBeReal Nr. %s: " % n) - names from the images
print(" - Time Taken: %s\n - Front Image: %s\n - Back Image: %s\n - Location: %s" - the taken time
% (i['takenTime'], - the location if available
get_img_filename(i['frontImage']), get_img_filename(i['backImage']), """
get_memory_location(i))) print(" - BeReal Moment: %s\n - Time Taken: %s\n - Front Image: %s\n - Back Image: %s\n - Location: %s\n - isLate: %s"
n+=1 % (memory['berealMoment'],
memory['takenTime'],
get_img_filename(memory['frontImage']), get_img_filename(memory['backImage']),
get_memory_location(memory),
memory['isLate']))
if __name__ == '__main__': if __name__ == '__main__':
f = open('memories.json') f = open('memories.json')
print_memories_info(json.load(f)) n = 0
for i in json.load(f):
print("\nBeReal Nr. %s: " % n)
print_memory_info(i)
n+=1
f.close() f.close()