2 Commits

Author SHA1 Message Date
19a8c2b997 Fix for [Bug with exempi 2.5.0 #1]
With exempi 2.5.0 when the get_property was called on an unset one, it
crashed with "unkown error".

Fix with checking if property exists before actually getting the
property
2019-04-01 20:58:45 +09:00
217cd87feb Update output info if update is from cache
on write change the output message from only "UPDATED" to also show if
it was read from cache by "UPDATED FROM CACHE"
2018-06-11 23:50:32 +09:00

View File

@@ -1102,7 +1102,11 @@ for xmp_file in work_files:
# read fields from the XMP file and store in hash
xmp.parse_from_str(strbuffer)
for xmp_field in xmp_fields:
data_set[xmp_field] = xmp.get_property(xmp_fields[xmp_field], xmp_field)
# need to check if propert exist or it will the exempi routine will fail
if xmp.does_property_exist(xmp_fields[xmp_field], xmp_field):
data_set[xmp_field] = xmp.get_property(xmp_fields[xmp_field], xmp_field)
else:
data_set[xmp_field] = ''
if args.debug:
print("### => XMP: {}:{} => {}".format(xmp_fields[xmp_field], xmp_field, data_set[xmp_field]))
if args.read_only:
@@ -1188,6 +1192,7 @@ for xmp_file in work_files:
# run this through the overwrite checker to get unset if we have a forced overwrite
has_unset = False
failed = False
from_cache = False
for loc in data_set_loc:
if checkOverwrite(data_set[loc], loc, args.field_controls):
has_unset = True
@@ -1226,6 +1231,7 @@ for xmp_file in work_files:
maps_location = reverseGeolocate(latitude=data_set['GPSLatitude'], longitude=data_set['GPSLongitude'], map_type=map_type)
# cache data with Lat/Long
data_cache[cache_key] = maps_location
from_cache = False
else:
maps_location = data_cache[best_match_latlong]
# cache this one, because the next one will match this one too
@@ -1233,10 +1239,12 @@ for xmp_file in work_files:
data_cache[cache_key] = maps_location
count['cache'] += 1
count['fuzzy_cache'] += 1
from_cache = True
else:
# load location from cache
maps_location = data_cache[cache_key]
count['cache'] += 1
from_cache = True
# overwrite sets (note options check here)
if args.debug:
print("### Map Location ({}): {}".format(map_type, maps_location))
@@ -1280,7 +1288,10 @@ for xmp_file in work_files:
fptr.write(xmp.serialize_to_str(omit_packet_wrapper=True))
else:
print("[TEST] Would write {} ".format(data_set, xmp_file), end='')
print("[UPDATED]")
if from_cache:
print("[UPDATED FROM CACHE]")
else:
print("[UPDATED]")
count['changed'] += 1
elif failed:
print("[FAILED]")