From 4867d4d311a64be0e54947724b4be226e667c708 Mon Sep 17 00:00:00 2001 From: Nathan Ostgard Date: Fri, 8 Jan 2016 10:04:45 -0800 Subject: [PATCH] gh-69 Allow import to trash files --- .travis.yml | 2 +- docs/requirements.txt | 1 + elodie.py | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59726e8..098fa3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - "sudo apt-get update -qq" - "sudo apt-get install python-dev python-pip python-pyexiv2 libimage-exiftool-perl -y" install: - - "sudo pip install docopt LatLon mock nose requests" + - "sudo pip install docopt LatLon mock nose requests send2trash" # command to run tests # test mapquest key before_script: diff --git a/docs/requirements.txt b/docs/requirements.txt index 4e910d9..8b44d9f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,4 +2,5 @@ LatLon docopt requests mock +send2trash sphinx diff --git a/elodie.py b/elodie.py index 929e3bf..61bf135 100755 --- a/elodie.py +++ b/elodie.py @@ -6,6 +6,7 @@ import sys from datetime import datetime from docopt import docopt +from send2trash import send2trash # Verify that external dependencies are present first, so the user gets a # more user-friendly error instead of an ImportError traceback. @@ -27,7 +28,7 @@ def usage(): """Return usage message """ return """ -Usage: elodie.py import --destination= [--source=] [--file=] [--album-from-folder] [INPUT ...] +Usage: elodie.py import --destination= [--source=] [--file=] [--album-from-folder] [--trash] [INPUT ...] elodie.py update [--time=] [--location=] [--album=] [--title=] INPUT ... -h --help show this @@ -37,7 +38,7 @@ DB = Db() FILESYSTEM = FileSystem() -def import_file(_file, destination, album_from_folder): +def import_file(_file, destination, album_from_folder, trash): """Set file metadata and move it to destination. """ if not os.path.exists(_file): @@ -64,6 +65,8 @@ def import_file(_file, destination, album_from_folder): media, allowDuplicate=False, move=False) if dest_path: print '%s -> %s' % (_file, dest_path) + if trash: + send2trash(_file) def _import(params): @@ -85,7 +88,8 @@ def _import(params): files.add(path) for current_file in files: - import_file(current_file, destination, params['--album-from-folder']) + import_file(current_file, destination, params['--album-from-folder'], + params['--trash']) def update_location(media, file_path, location_name):