Merge pull request #59 from Kraymer/master

Fix pyflakes warnings reported in non-test files. gh-40
This commit is contained in:
Jaisen Mathai 2016-01-05 09:58:57 -08:00
commit 8e3e5d63f5
8 changed files with 31 additions and 48 deletions

View File

@ -99,10 +99,10 @@ class FileSystem:
# This helps when re-running the program on file which were already
# processed.
base_name = re.sub(
'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}-',
'',
metadata['base_name']
)
'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}-',
'',
metadata['base_name']
)
if(len(base_name) == 0):
base_name = metadata['base_name']
@ -116,13 +116,12 @@ class FileSystem:
base_name = '%s-%s' % (base_name, title_sanitized)
file_name = '%s-%s.%s' % (
time.strftime(
'%Y-%m-%d_%H-%M-%S',
metadata['date_taken']
),
base_name,
metadata['extension']
)
time.strftime(
'%Y-%m-%d_%H-%M-%S',
metadata['date_taken']
),
base_name,
metadata['extension'])
return file_name.lower()
"""
@ -170,9 +169,9 @@ class FileSystem:
if('move' in kwargs):
move = kwargs['move']
allowDuplicate = False
allow_duplicate = False
if('allowDuplicate' in kwargs):
allowDuplicate = kwargs['allowDuplicate']
allow_duplicate = kwargs['allowDuplicate']
metadata = media.get_metadata()
@ -191,7 +190,7 @@ class FileSystem:
# If duplicates are not allowed and this hash exists in the db then we
# return
if(allowDuplicate is False and db.check_hash(checksum) is True):
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,

View File

@ -3,9 +3,7 @@ from ConfigParser import ConfigParser
import fractions
import pyexiv2
import math
import requests
import sys
import urllib
from elodie import constants
@ -30,8 +28,8 @@ def coordinates_by_name(name):
cached_coordinates = db.get_location_coordinates(name)
if(cached_coordinates is not None):
return {
'latitude': cached_coordinates[0],
'longitude': cached_coordinates[1]
'latitude': cached_coordinates[0],
'longitude': cached_coordinates[1]
}
# If the name is not cached then we go ahead with an API lookup
@ -63,8 +61,8 @@ def coordinates_by_name(name):
break
return {
'latitude': use_location['lat'],
'longitude': use_location['lng']
'latitude': use_location['lat'],
'longitude': use_location['lng']
}
return None

View File

@ -108,10 +108,10 @@ class Db(object):
[longitude, latitude, data['long'], data['lat']]
)
R = 6371000 # radius of the earth in m
x = (lon2 - lon1) * cos(0.5*(lat2+lat1))
r = 6371000 # radius of the earth in m
x = (lon2 - lon1) * cos(0.5 * (lat2 + lat1))
y = lat2 - lat1
d = R * sqrt(x*x + y*y)
d = r * sqrt(x * x + y * y)
# Use if closer then threshold_km reuse lookup
if(d <= threshold_m and d < last_d):
name = data['name']

View File

@ -1 +0,0 @@
from media import *

View File

@ -4,18 +4,14 @@ Media package that's a parent class for media objects
"""
# load modules
from datetime import datetime
from distutils.spawn import find_executable
from elodie import constants
from fractions import Fraction
from sys import argv
import mimetypes
import os
import pyexiv2
import re
import subprocess
import time
class Media(object):
@ -241,7 +237,7 @@ class Media(object):
stdout=subprocess.PIPE,
shell=True
)
streamdata = process_output.communicate()[0]
process_output.communicate()
if(process_output.returncode != 0):
return False
@ -299,7 +295,7 @@ class Media(object):
self.metadata[key] = kwargs[key]
@classmethod
def get_class_by_file(Media, _file, classes):
def get_class_by_file(cls, _file, classes):
extension = os.path.splitext(_file)[1][1:].lower()
for i in classes:

View File

@ -3,12 +3,7 @@ Author: Jaisen Mathai <jaisen@jmathai.com>
Photo package that handles all photo operations
"""
# load modules
from datetime import datetime
from sys import argv
import imghdr
import mimetypes
import LatLon
import os
import pyexiv2
@ -228,5 +223,5 @@ class Photo(Media):
@returns, tuple
"""
@classmethod
def get_valid_extensions(Photo):
return Photo.extensions
def get_valid_extensions(cls):
return cls.extensions

View File

@ -6,10 +6,8 @@ Video package that handles all video operations
# load modules
from distutils.spawn import find_executable
import tempfile
from sys import argv
from datetime import datetime
import mimetypes
import os
import re
import shutil
@ -91,7 +89,6 @@ class Video(Media):
# conversion in the local timezone
# If the time is not found in EXIF we update EXIF
seconds_since_epoch = min(os.path.getmtime(source), os.path.getctime(source)) # noqa
time_found_in_exif = False
exif_data = self.get_exif()
for key in ['Creation Date', 'Media Create Date']:
date = re.search('%s +: +([0-9: ]+)' % key, exif_data)
@ -106,7 +103,6 @@ class Video(Media):
)
if(exif_seconds_since_epoch < seconds_since_epoch):
seconds_since_epoch = exif_seconds_since_epoch
time_found_in_exif = True
break
except:
pass
@ -279,7 +275,7 @@ class Video(Media):
stdout=subprocess.PIPE,
shell=True
)
streamdata = write_process.communicate()[0]
write_process.communicate()
if(write_process.returncode != 0):
if(constants.debug is True):
print 'Failed to generate plist file'
@ -368,7 +364,7 @@ class Video(Media):
stdout=subprocess.PIPE,
shell=True
)
streamdata = update_process.communicate()[0]
update_process.communicate()
if(update_process.returncode != 0):
if(constants.debug is True):
print '%s did not complete successfully' % avmetareadwrite_command # noqa
@ -385,8 +381,8 @@ class Video(Media):
check_metadata['latitude'] is None and
check_metadata['longitude'] is None
) or (
'time' in kwargs and
check_metadata['date_taken'] is None
'time' in kwargs and
check_metadata['date_taken'] is None
)
):
if(constants.debug is True):
@ -408,8 +404,8 @@ class Video(Media):
@returns, tuple
"""
@classmethod
def get_valid_extensions(Video):
return Video.extensions
def get_valid_extensions(cls):
return cls.extensions
class Transcode(object):

View File

@ -13,7 +13,7 @@ import plistlib
class Plist(object):
def __init__(self, source):
if(path.isfile(source) == False):
if not path.isfile(source):
raise IOError('Could not load plist file %s' % source)
self.source = source