Closes gh-36 Fix bug with old references to `Media.photo_extensions` and `Media.video_extensions`
This commit is contained in:
parent
05659650df
commit
d4dde66375
|
@ -50,6 +50,13 @@ def _import(params):
|
||||||
elif(params['--file'] is not None):
|
elif(params['--file'] is not None):
|
||||||
current_file = os.path.expanduser(params['--file'])
|
current_file = os.path.expanduser(params['--file'])
|
||||||
media = Media.get_class_by_file(current_file, [Photo, Video])
|
media = Media.get_class_by_file(current_file, [Photo, Video])
|
||||||
|
|
||||||
|
if(media is None):
|
||||||
|
if(constants.debug == True):
|
||||||
|
print 'Not a supported file (%s)' % current_file
|
||||||
|
print '{"source":"%s", "error_msg":"Not a supported file"}' % current_file
|
||||||
|
return
|
||||||
|
|
||||||
if(media.__name__ == 'Video'):
|
if(media.__name__ == 'Video'):
|
||||||
filesystem.set_date_from_path_video(media)
|
filesystem.set_date_from_path_video(media)
|
||||||
|
|
||||||
|
|
|
@ -293,14 +293,9 @@ class Media(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_class_by_file(Media, _file, classes):
|
def get_class_by_file(Media, _file, classes):
|
||||||
extension = os.path.splitext(_file)[1][1:].lower()
|
extension = os.path.splitext(_file)[1][1:].lower()
|
||||||
name = None
|
|
||||||
if(extension in Media.photo_extensions):
|
|
||||||
name = 'Photo'
|
|
||||||
elif(extension in Media.video_extensions):
|
|
||||||
name = 'Video'
|
|
||||||
|
|
||||||
for i in classes:
|
for i in classes:
|
||||||
if(name == i.__name__):
|
if(extension in i.extensions):
|
||||||
return i(_file)
|
return i(_file)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -32,6 +32,21 @@ def test_get_file_path():
|
||||||
|
|
||||||
assert 'plain.jpg' in path, path
|
assert 'plain.jpg' in path, path
|
||||||
|
|
||||||
|
def test_get_class_by_file_photo():
|
||||||
|
media = Media.get_class_by_file(helper.get_file('plain.jpg'), [Photo, Video])
|
||||||
|
|
||||||
|
assert media.__name__ == 'Photo'
|
||||||
|
|
||||||
|
def test_get_class_by_file_video():
|
||||||
|
media = Media.get_class_by_file(helper.get_file('video.mov'), [Photo, Video])
|
||||||
|
|
||||||
|
assert media.__name__ == 'Video'
|
||||||
|
|
||||||
|
def test_get_class_by_file_unsupported():
|
||||||
|
media = Media.get_class_by_file(helper.get_file('text.txt'), [Photo, Video])
|
||||||
|
|
||||||
|
assert media is None
|
||||||
|
|
||||||
def is_valid():
|
def is_valid():
|
||||||
media = Media()
|
media = Media()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue