New option to only list unset data

With the -u flag only XMP data that has unset or missing data will be
listed
This commit is contained in:
2018-03-08 14:12:32 +09:00
parent 134aff004a
commit e4e52927da
2 changed files with 35 additions and 17 deletions

View File

@@ -27,7 +27,7 @@ reverse_geolocate.py [-h] -i
[-l LIGHTROOM FOLDER] [-s] [-l LIGHTROOM FOLDER] [-s]
[-f <overwrite, location, city, state, country, countrycode>] [-f <overwrite, location, city, state, country, countrycode>]
[-g GOOGLE API KEY] [-o] [-e EMIL ADDRESS] [-w] [-g GOOGLE API KEY] [-o] [-e EMIL ADDRESS] [-w]
[-r] [-a] [-c] [-n] [-v] [--debug] [--test] [-r] [-u] [-a] [-c] [-n] [-v] [--debug] [--test]
### Arguments ### Arguments
@@ -43,6 +43,7 @@ Argument | Argument Value | Description
-e, --email | email address | For OpenStreetMap with a large number of access -e, --email | email address | For OpenStreetMap with a large number of access
-g, --google | Google Maps API Key | If available, to avoid the access limitations to the reverse location lookup -g, --google | Google Maps API Key | If available, to avoid the access limitations to the reverse location lookup
-r, --read-only | | Read only data from the XMP files and print them out. No LR DB connection is done or any map lookups -r, --read-only | | Read only data from the XMP files and print them out. No LR DB connection is done or any map lookups
-u, --unset-only | | Only list XMP files with missing data
-a, --no-autoadjust | | Do not try to auto adjust column width to terminal column width -a, --no-autoadjust | | Do not try to auto adjust column width to terminal column width
-c, --compact | | Do extra compact view -c, --compact | | Do extra compact view
-w, --write-settings | | Write the Google API key or the OpenStreetMap email into the settings file -w, --write-settings | | Write the Google API key or the OpenStreetMap email into the settings file

View File

@@ -474,6 +474,13 @@ parser.add_argument('-r', '--read-only',
help = 'Read current values from the XMP file only, do not read from LR or lookup any data and write back' help = 'Read current values from the XMP file only, do not read from LR or lookup any data and write back'
) )
# only list unset ones
parser.add_argument('-u', '--unset-only',
dest = 'unset_only',
action = 'store_true',
help = 'Only list unset XMP files'
)
# don't try to do auto adjust in list view # don't try to do auto adjust in list view
parser.add_argument('-a', '--no-autoadjust', parser.add_argument('-a', '--no-autoadjust',
dest = 'no_autoadjust', dest = 'no_autoadjust',
@@ -520,9 +527,12 @@ if not args.verbose:
# init exclude source to list if not set # init exclude source to list if not set
if not args.exclude_sources: if not args.exclude_sources:
args.exclude_sources = [] args.exclude_sources = []
# init args unset (for list view) with 0 if unset
# if not args.unset_only:
# args.unset = 0
if args.debug: if args.debug:
print("### ARGUMENT VARS: I: {incl}, X: {excl}, L: {lr}, F: {fc}, M: {osm}, G: {gp}, E: {em}, R: {read}, A: {adj}, C: {cmp}, N: {nbk}, W: {wrc}, V: {v}, D: {d}, T: {t}".format( print("### ARGUMENT VARS: I: {incl}, X: {excl}, L: {lr}, F: {fc}, M: {osm}, G: {gp}, E: {em}, R: {read}, U: {us}, A: {adj}, C: {cmp}, N: {nbk}, W: {wrc}, V: {v}, D: {d}, T: {t}".format(
incl = args.xmp_sources, incl = args.xmp_sources,
excl = args.exclude_sources, excl = args.exclude_sources,
lr = args.lightroom_folder, lr = args.lightroom_folder,
@@ -531,6 +541,7 @@ if args.debug:
gp = args.google_api_key, gp = args.google_api_key,
em = args.email, em = args.email,
read = args.read_only, read = args.read_only,
us = args.unset,
adj = args.no_autoadjust, adj = args.no_autoadjust,
cmp = args.compact_view, cmp = args.compact_view,
nbk = args.no_xmp_backup, nbk = args.no_xmp_backup,
@@ -651,6 +662,7 @@ cur = ''
# count variables # count variables
count = { count = {
'all': 0, 'all': 0,
'listed': 0,
'read': 0, 'read': 0,
'map': 0, 'map': 0,
'cache': 0, 'cache': 0,
@@ -904,6 +916,8 @@ for xmp_file in work_files:
if args.debug: if args.debug:
print("### => XMP: {}:{} => {}".format(xmp_fields[xmp_field], xmp_field, data_set[xmp_field])) print("### => XMP: {}:{} => {}".format(xmp_fields[xmp_field], xmp_field, data_set[xmp_field]))
if args.read_only: if args.read_only:
# view only if list all or if data is unset
if not args.unset_only or (args.unset_only and '' in data_set.values()):
# for read only we print out the data formatted # for read only we print out the data formatted
# headline check, do we need to print that # headline check, do we need to print that
count['read'] = printHeader(header_line.format(page_no = page_no, page_all = page_all), count['read'], header_repeat) count['read'] = printHeader(header_line.format(page_no = page_no, page_all = page_all), count['read'], header_repeat)
@@ -919,6 +933,7 @@ for xmp_file in work_files:
location = shortenString(data_set['Location'], width = format_length['location']), location = shortenString(data_set['Location'], width = format_length['location']),
path = shortenPath(xmp_file, format_length['path'], path_only = True) path = shortenPath(xmp_file, format_length['path'], path_only = True)
)) ))
count['listed'] += 1
else: else:
# create a duplicate copy for later checking if something changed # create a duplicate copy for later checking if something changed
data_set_original = data_set.copy() data_set_original = data_set.copy()
@@ -1043,6 +1058,8 @@ if use_lightroom:
# end stats only if we write # end stats only if we write
print("{}".format('=' * 39)) print("{}".format('=' * 39))
print("XMP Files found : {:9,}".format(count['all'])) print("XMP Files found : {:9,}".format(count['all']))
if args.read_only:
print("XMP Files listed : {:9,}".format(count['listed']))
if not args.read_only: if not args.read_only:
print("Updated : {:9,}".format(count['changed'])) print("Updated : {:9,}".format(count['changed']))
print("Skipped : {:9,}".format(count['skipped'])) print("Skipped : {:9,}".format(count['skipped']))