Merge branch 'master' of github.com:gullevek/reverse_geolocate
This commit is contained in:
@@ -644,144 +644,178 @@ parser = argparse.ArgumentParser(
|
|||||||
|
|
||||||
# xmp folder (or folders), or file (or files)
|
# xmp folder (or folders), or file (or files)
|
||||||
# note that the target directory or file needs to be writeable
|
# note that the target directory or file needs to be writeable
|
||||||
parser.add_argument('-i', '--include-source',
|
parser.add_argument(
|
||||||
required=True,
|
'-i',
|
||||||
nargs='*',
|
'--include-source',
|
||||||
action=writable_dir_folder,
|
required=True,
|
||||||
dest='xmp_sources',
|
nargs='*',
|
||||||
metavar='XMP SOURCE FOLDER',
|
action=writable_dir_folder,
|
||||||
help='The source folder or folders with the XMP files that need reverse geo encoding to be set. Single XMP files can be given here'
|
dest='xmp_sources',
|
||||||
)
|
metavar='XMP SOURCE FOLDER',
|
||||||
|
help='The source folder or folders with the XMP files that need reverse geo encoding to be set. Single XMP files can be given here'
|
||||||
|
)
|
||||||
# exclude folders
|
# exclude folders
|
||||||
parser.add_argument('-x', '--exclude-source',
|
parser.add_argument(
|
||||||
nargs='*',
|
'-x',
|
||||||
action=writable_dir_folder,
|
'--exclude-source',
|
||||||
dest='exclude_sources',
|
nargs='*',
|
||||||
metavar='EXCLUDE XMP SOURCE FOLDER',
|
action=writable_dir_folder,
|
||||||
help='Folders and files that will be excluded.'
|
dest='exclude_sources',
|
||||||
)
|
metavar='EXCLUDE XMP SOURCE FOLDER',
|
||||||
|
help='Folders and files that will be excluded.'
|
||||||
|
)
|
||||||
|
|
||||||
# LR database (base folder)
|
# LR database (base folder)
|
||||||
# get .lrcat file in this folder
|
# get .lrcat file in this folder
|
||||||
parser.add_argument('-l', '--lightroom',
|
parser.add_argument(
|
||||||
# required=True,
|
'-l',
|
||||||
action=readable_dir,
|
'--lightroom',
|
||||||
dest='lightroom_folder',
|
# required=True,
|
||||||
metavar='LIGHTROOM FOLDER',
|
action=readable_dir,
|
||||||
help='Lightroom catalogue base folder'
|
dest='lightroom_folder',
|
||||||
)
|
metavar='LIGHTROOM FOLDER',
|
||||||
|
help='Lightroom catalogue base folder'
|
||||||
|
)
|
||||||
|
|
||||||
# strict LR check with base path next to the file base name
|
# strict LR check with base path next to the file base name
|
||||||
parser.add_argument('-s', '--strict',
|
parser.add_argument(
|
||||||
dest='lightroom_strict',
|
'-s',
|
||||||
action='store_true',
|
'--strict',
|
||||||
help='Do strict check for Lightroom files including Path in query'
|
dest='lightroom_strict',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Do strict check for Lightroom files including Path in query'
|
||||||
|
)
|
||||||
|
|
||||||
# set behaviour override
|
# set behaviour override
|
||||||
# FLAG: default: only set not filled
|
# FLAG: default: only set not filled
|
||||||
# other: overwrite all or overwrite if one is missing, overwrite specifc field (as defined below)
|
# other: overwrite all or overwrite if one is missing, overwrite specifc field (as defined below)
|
||||||
# fields: Location, City, State, Country, CountryCode
|
# fields: Location, City, State, Country, CountryCode
|
||||||
parser.add_argument('-f', '--field',
|
parser.add_argument(
|
||||||
action='append',
|
'-f',
|
||||||
type=str.lower, # make it lowercase for check
|
'--field',
|
||||||
choices=['overwrite', 'location', 'city', 'state', 'country', 'countrycode'],
|
action='append',
|
||||||
dest='field_controls',
|
type=str.lower, # make it lowercase for check
|
||||||
metavar='<overwrite, location, city, state, country, countrycode>',
|
choices=['overwrite', 'location', 'city', 'state', 'country', 'countrycode'],
|
||||||
help='On default only set fields that are not set yet. Options are: '\
|
dest='field_controls',
|
||||||
'Overwrite (write all new), Location, City, State, Country, CountryCode. '\
|
metavar='<overwrite, location, city, state, country, countrycode>',
|
||||||
'Multiple can be given for combination overwrite certain fields only or set only certain fields. '\
|
help='On default only set fields that are not set yet. Options are: '\
|
||||||
'If with overwrite the field will be overwritten if already set, else it will be always skipped.'
|
'Overwrite (write all new), Location, City, State, Country, CountryCode. '\
|
||||||
)
|
'Multiple can be given for combination overwrite certain fields only or set only certain fields. '\
|
||||||
|
'If with overwrite the field will be overwritten if already set, else it will be always skipped.'
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument('-d', '--fuzzy-cache',
|
parser.add_argument(
|
||||||
type=str.lower,
|
'-d',
|
||||||
action=distance_values,
|
'--fuzzy-cache',
|
||||||
nargs='?',
|
type=str.lower,
|
||||||
const='10m', # default is 10m
|
action=distance_values,
|
||||||
dest='fuzzy_distance',
|
nargs='?',
|
||||||
metavar='FUZZY DISTANCE',
|
const='10m', # default is 10m
|
||||||
help='Allow fuzzy distance cache lookup. Optional distance can be given, '\
|
dest='fuzzy_distance',
|
||||||
'if not set default of 10m is used. '\
|
metavar='FUZZY DISTANCE',
|
||||||
'Allowed argument is in the format of 12m or 12km'
|
help='Allow fuzzy distance cache lookup. Optional distance can be given, '\
|
||||||
)
|
'if not set default of 10m is used. '\
|
||||||
|
'Allowed argument is in the format of 12m or 12km'
|
||||||
|
)
|
||||||
|
|
||||||
# Google Maps API key to overcome restrictions
|
# Google Maps API key to overcome restrictions
|
||||||
parser.add_argument('-g', '--google',
|
parser.add_argument(
|
||||||
dest='google_api_key',
|
'-g',
|
||||||
metavar='GOOGLE API KEY',
|
'--google',
|
||||||
help='Set a Google API Maps key to overcome the default lookup limitations'
|
dest='google_api_key',
|
||||||
)
|
metavar='GOOGLE API KEY',
|
||||||
|
help='Set a Google API Maps key to overcome the default lookup limitations'
|
||||||
|
)
|
||||||
|
|
||||||
# use open street maps
|
# use open street maps
|
||||||
parser.add_argument('-o', '--openstreetmap',
|
parser.add_argument(
|
||||||
dest='use_openstreetmap',
|
'-o',
|
||||||
action='store_true',
|
'--openstreetmap',
|
||||||
help='Use openstreetmap instead of Google'
|
dest='use_openstreetmap',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Use openstreetmap instead of Google'
|
||||||
|
)
|
||||||
|
|
||||||
# email of open street maps requests
|
# email of open street maps requests
|
||||||
parser.add_argument('-e', '--email',
|
parser.add_argument(
|
||||||
dest='email',
|
'-e',
|
||||||
metavar='EMIL ADDRESS',
|
'--email',
|
||||||
help='An email address for OpenStreetMap'
|
dest='email',
|
||||||
)
|
metavar='EMIL ADDRESS',
|
||||||
|
help='An email address for OpenStreetMap'
|
||||||
|
)
|
||||||
|
|
||||||
# write api/email settings to config file
|
# write api/email settings to config file
|
||||||
parser.add_argument('-w', '--write-settings',
|
parser.add_argument(
|
||||||
dest='config_write',
|
'-w',
|
||||||
action='store_true',
|
'--write-settings',
|
||||||
help='Write Google API or OpenStreetMap email to config file'
|
dest='config_write',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Write Google API or OpenStreetMap email to config file'
|
||||||
|
)
|
||||||
|
|
||||||
# only read data and print on screen, do not write anything
|
# only read data and print on screen, do not write anything
|
||||||
parser.add_argument('-r', '--read-only',
|
parser.add_argument(
|
||||||
dest='read_only',
|
'-r',
|
||||||
action='store_true',
|
'--read-only',
|
||||||
help='Read current values from the XMP file only, do not read from LR or lookup any data and write back'
|
dest='read_only',
|
||||||
)
|
action='store_true',
|
||||||
|
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
|
# only list unset ones
|
||||||
parser.add_argument('-u', '--unset-only',
|
parser.add_argument(
|
||||||
dest='unset_only',
|
'-u',
|
||||||
action='store_true',
|
'--unset-only',
|
||||||
help='Only list unset XMP files'
|
dest='unset_only',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Only list unset XMP files'
|
||||||
|
)
|
||||||
|
|
||||||
# only list unset GPS codes
|
# only list unset GPS codes
|
||||||
parser.add_argument('-p', '--unset-gps-only',
|
parser.add_argument(
|
||||||
dest='unset_gps_only',
|
'-p',
|
||||||
action='store_true',
|
'--unset-gps-only',
|
||||||
help='Only list unset XMP files for GPS fields'
|
dest='unset_gps_only',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Only list unset XMP files for GPS fields'
|
||||||
|
)
|
||||||
|
|
||||||
# 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(
|
||||||
dest='no_autoadjust',
|
'-a',
|
||||||
action='store_true',
|
'--no-autoadjust',
|
||||||
help='Don\'t try to auto adjust columns'
|
dest='no_autoadjust',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Don\'t try to auto adjust columns'
|
||||||
|
)
|
||||||
|
|
||||||
# compact view, compresses columns down to a minimum
|
# compact view, compresses columns down to a minimum
|
||||||
parser.add_argument('-c', '--compact',
|
parser.add_argument(
|
||||||
dest='compact_view',
|
'-c',
|
||||||
action='store_true',
|
'--compact',
|
||||||
help='Very compact list view'
|
dest='compact_view',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Very compact list view'
|
||||||
|
)
|
||||||
|
|
||||||
# Do not create backup files
|
# Do not create backup files
|
||||||
parser.add_argument('-n', '--nobackup',
|
parser.add_argument(
|
||||||
dest='no_xmp_backup',
|
'-n',
|
||||||
action='store_true',
|
'--nobackup',
|
||||||
help='Do not create a backup from the XMP file'
|
dest='no_xmp_backup',
|
||||||
)
|
action='store_true',
|
||||||
|
help='Do not create a backup from the XMP file'
|
||||||
|
)
|
||||||
|
|
||||||
# verbose args for more detailed output
|
# verbose args for more detailed output
|
||||||
parser.add_argument('-v', '--verbose',
|
parser.add_argument(
|
||||||
action='count',
|
'-v',
|
||||||
dest='verbose',
|
'--verbose',
|
||||||
help='Set verbose output level'
|
action='count',
|
||||||
)
|
dest='verbose',
|
||||||
|
help='Set verbose output level'
|
||||||
|
)
|
||||||
|
|
||||||
# debug flag
|
# debug flag
|
||||||
parser.add_argument('--debug', action='store_true', dest='debug', help='Set detailed debug output')
|
parser.add_argument('--debug', action='store_true', dest='debug', help='Set detailed debug output')
|
||||||
@@ -1012,8 +1046,8 @@ for xmp_file_source in args.xmp_sources:
|
|||||||
# 2) file is not in exclude list
|
# 2) file is not in exclude list
|
||||||
# 3) full folder is not in exclude list
|
# 3) full folder is not in exclude list
|
||||||
if file.endswith(".xmp") and ".BK." not in file \
|
if file.endswith(".xmp") and ".BK." not in file \
|
||||||
and "{}/{}".format(root, file) not in args.exclude_sources \
|
and "{}/{}".format(root, file) not in args.exclude_sources \
|
||||||
and root.rstrip('/') not in [x.rstrip('/') for x in args.exclude_sources]:
|
and root.rstrip('/') not in [x.rstrip('/') for x in args.exclude_sources]:
|
||||||
if "{}/{}".format(root, file) not in work_files:
|
if "{}/{}".format(root, file) not in work_files:
|
||||||
work_files.append("{}/{}".format(root, file))
|
work_files.append("{}/{}".format(root, file))
|
||||||
count['all'] += 1
|
count['all'] += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user