From 198983156b7ba5f61f5007bd222e5f36dbd3af19 Mon Sep 17 00:00:00 2001 From: Nathan Ostgard Date: Thu, 7 Jan 2016 17:21:02 -0800 Subject: [PATCH 1/2] gh-60 Accept a list of inputs instead of source/file arguments --- elodie.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/elodie.py b/elodie.py index 049540d..437ab9b 100755 --- a/elodie.py +++ b/elodie.py @@ -27,8 +27,7 @@ def usage(): """Return usage message """ return """ -Usage: elodie.py import --source= --destination= [--album-from-folder] - elodie.py import --file= --destination= [--album-from-folder] +Usage: elodie.py import --destination= [--album-from-folder] INPUT ... elodie.py update [--time=] [--location=] [--album=] [--title=] INPUT ... -h --help show this @@ -41,6 +40,13 @@ FILESYSTEM = FileSystem() def import_file(_file, destination, album_from_folder): """Set file metadata and move it to destination. """ + if not os.path.exists(_file): + if constants.debug: + print 'Could not find %s' % _file + print '{"source":"%s", "error_msg":"Could not find %s"}' % \ + (_file, _file) + return + media = Media.get_class_by_file(_file, [Audio, Photo, Video]) if not media: if constants.debug: @@ -65,11 +71,13 @@ def _import(params): """ destination = os.path.expanduser(params['--destination']) - if params['--source']: - source = os.path.expanduser(params['--source']) - files = FILESYSTEM.get_all_files(source, None) - elif params['--file']: - files = [os.path.expanduser(params['--file'])] + files = set() + for path in params['INPUT']: + path = os.path.expanduser(path) + if os.path.isdir(path): + files.update(FILESYSTEM.get_all_files(path, None)) + else: + files.add(path) for current_file in files: import_file(current_file, destination, params['--album-from-folder']) From ea6a125fef08a082bf0553a8949d14ee5e9c3fb0 Mon Sep 17 00:00:00 2001 From: Nathan Ostgard Date: Fri, 8 Jan 2016 09:50:14 -0800 Subject: [PATCH 2/2] gh-60 Added --source and --file for backwards compatibility --- elodie.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/elodie.py b/elodie.py index 437ab9b..929e3bf 100755 --- a/elodie.py +++ b/elodie.py @@ -27,7 +27,7 @@ def usage(): """Return usage message """ return """ -Usage: elodie.py import --destination= [--album-from-folder] INPUT ... +Usage: elodie.py import --destination= [--source=] [--file=] [--album-from-folder] [INPUT ...] elodie.py update [--time=] [--location=] [--album=] [--title=] INPUT ... -h --help show this @@ -72,7 +72,12 @@ def _import(params): destination = os.path.expanduser(params['--destination']) files = set() - for path in params['INPUT']: + paths = set(params['INPUT']) + if params['--source']: + paths.add(params['--source']) + if params['--file']: + paths.add(params['--file']) + for path in paths: path = os.path.expanduser(path) if os.path.isdir(path): files.update(FILESYSTEM.get_all_files(path, None))