Merge pull request #125 from jmathai/cr2-support-gh-124

gh-124 Add support for cr2 files
This commit is contained in:
Jaisen Mathai 2016-09-04 16:20:39 -07:00 committed by GitHub
commit fe6121e43b
2 changed files with 55 additions and 1 deletions

View File

@ -30,7 +30,7 @@ class Photo(Media):
__name__ = 'Photo'
#: Valid extensions for photo files.
extensions = ('arw', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2')
extensions = ('arw', 'cr2', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2')
def __init__(self, source=None):
super(Photo, self).__init__(source)

View File

@ -498,3 +498,57 @@ def test_set_metadata_on_arw():
assert metadata['date_taken'] == helper.time_convert((2007, 4, 8, 17, 41, 18, 6, 98, 0)), metadata['date_taken']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_get_metadata_from_cr2():
temporary_folder, folder = helper.create_working_folder()
photo_file = helper.get_file('photo.cr2')
origin = '%s/photo.cr2' % folder
if not photo_file:
photo_file = helper.download_file('photo.cr2', folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('cr2 file not downlaoded')
# downloading for each test is costly so we save it in the working directory
file_path_save_as = helper.get_file_path('photo.cr2')
if os.path.isfile(photo_file):
shutil.copyfile(photo_file, file_path_save_as)
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
metadata = photo.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert((2005, 10, 29, 16, 14, 44, 5, 302, 0)), metadata['date_taken']
def test_set_metadata_on_cr2():
temporary_folder, folder = helper.create_working_folder()
photo_file = helper.get_file('photo.cr2')
origin = '%s/photo.cr2' % folder
if not photo_file:
photo_file = helper.download_file('photo.cr2', folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('cr2 file not downlaoded')
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert((2005, 10, 29, 16, 14, 44, 5, 302, 0)), metadata['date_taken']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']