From 852850d2e6c295e992f143a9001ec7f5428271b4 Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Mon, 7 Nov 2016 20:34:25 -0800 Subject: [PATCH] gh-145 Fix configparser unit test error for python 2 and 3 --- elodie/filesystem.py | 29 ++++++++++++++++++++--------- elodie/geolocation.py | 4 ++-- elodie/tests/requirements.txt | 6 +++--- requirements.txt | 9 +++++---- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/elodie/filesystem.py b/elodie/filesystem.py index 0bb0aa8..01912d2 100644 --- a/elodie/filesystem.py +++ b/elodie/filesystem.py @@ -196,15 +196,26 @@ class FileSystem(object): print('Could not get checksum for %s. Skipping...' % _file) return - # If duplicates are not allowed and this hash exists in the db then we - # return - if(allow_duplicate is False and db.check_hash(checksum) is True): - if(constants.debug is True): - print('%s already exists at %s. Skipping...' % ( - _file, - db.get_hash(checksum) - )) - return + # If duplicates are not allowed then we check if we've seen this file + # before via checksum. We also check that the file exists at the + # location we believe it to be. + # If we find a checksum match but the file doesn't exist where we + # believe it to be then we write a debug log and proceed to import. + checksum_file = db.get_hash(checksum) + if(allow_duplicate is False and checksum_file is not None): + if(os.path.isfile(checksum_file)): + if(constants.debug is True): + print('%s already exists at %s. Skipping...' % ( + _file, + checksum_file + )) + return + else: + if(constants.debug is True): + print('%s matched checksum but file not found at %s. Importing again...' % ( # noqa + _file, + checksum_file + )) self.create_directory(dest_directory) diff --git a/elodie/geolocation.py b/elodie/geolocation.py index a8251d5..1befd9b 100644 --- a/elodie/geolocation.py +++ b/elodie/geolocation.py @@ -4,11 +4,11 @@ from __future__ import division from future import standard_library from past.utils import old_div +standard_library.install_aliases() # noqa + from os import path from configparser import ConfigParser -standard_library.install_aliases() # noqa - import requests import urllib.request import urllib.parse diff --git a/elodie/tests/requirements.txt b/elodie/tests/requirements.txt index 0e75cd6..f9fc4eb 100644 --- a/elodie/tests/requirements.txt +++ b/elodie/tests/requirements.txt @@ -1,4 +1,4 @@ -r ../../requirements.txt -flake8>=2.2.5,<3.0 -mock>=1.3.0,<2.0 -nose>=1.3.7,<2.0 +flake8==2.6.2 +mock==1.3.0 +nose==1.3.7 diff --git a/requirements.txt b/requirements.txt index c5489ae..c0da3c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -click>=6.2,<7.0 -requests>=2.9.1,<3.0 -send2trash>=1.3.0,<2.0 -future +click==6.6 +requests==2.11.1 +Send2Trash==1.3.0 +future==0.16.0 +configparser==3.5.0