diff --git a/sigal/gallery.py b/sigal/gallery.py index 64dbc86..03b2a40 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -41,7 +41,7 @@ from . import image, video from .compat import UnicodeMixin, strxfrm from .image import process_image, get_exif_tags from .log import colored, BLUE -from .settings import get_thumb, get_orig +from .settings import get_thumb from .utils import copy, check_or_create_dir, url_from_path from .video import process_video from .writer import Writer @@ -66,10 +66,10 @@ class Media(UnicodeMixin): extensions = () def __init__(self, filename, path, settings): - self.filename = filename - self.url = filename + self.src_filename = self.filename = self.url = filename + self.path = path self.settings = settings - self.file_path = join(path, filename) + self.src_path = join(settings['source'], path, filename) self.dst_path = join(settings['destination'], path, filename) @@ -82,10 +82,10 @@ class Media(UnicodeMixin): self.date = None def __repr__(self): - return "<%s>(%r)" % (self.__class__.__name__, self.file_path) + return "<%s>(%r)" % (self.__class__.__name__, str(self)) def __unicode__(self): - return self.file_path + return join(self.path, self.filename) @property def big(self): @@ -93,7 +93,7 @@ class Media(UnicodeMixin): album directory). """ if self.settings['keep_orig']: - return get_orig(self.settings, self.filename) + return os.path.join(self.settings['orig_dir'], self.src_filename) else: return None @@ -137,7 +137,8 @@ class Video(Media): def __init__(self, filename, path, settings): super(Video, self).__init__(filename, path, settings) base = splitext(filename)[0] - self.file_path = join(path, base + '.webm') + self.src_filename = filename + self.filename = self.url = base + '.webm' self.dst_path = join(settings['destination'], path, base + '.webm') diff --git a/sigal/settings.py b/sigal/settings.py index 1354334..b5c5010 100644 --- a/sigal/settings.py +++ b/sigal/settings.py @@ -94,13 +94,6 @@ def get_thumb(settings, filename): name + settings['thumb_suffix'] + ext) -def get_orig(settings, filename): - """Return the path to the original image.""" - - path, filen = os.path.split(filename) - return os.path.join(path, settings['orig_dir'], filen) - - def read_settings(filename=None): """Read settings from a config file in the source_dir root.""" diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 6aad7c4..ea957af 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -55,7 +55,7 @@ REF = { 'thumbnail': ('video/thumbnails/' 'stallman software-freedom-day-low.tn.jpg'), 'subdirs': [], - 'medias': ['stallman software-freedom-day-low.ogv'] + 'medias': ['stallman software-freedom-day-low.webm'] } } @@ -67,7 +67,6 @@ def test_media(settings): thumb = join('thumbnails', '11.tn.jpg') assert m.filename == '11.jpg' - assert m.file_path == file_path assert m.src_path == join(settings['source'], file_path) assert m.dst_path == join(settings['destination'], file_path) assert m.thumb_name == thumb @@ -83,9 +82,13 @@ def test_media_orig(settings): assert m.big is None settings['keep_orig'] = True - m = Media('11.jpg', 'dir1/test1', settings) + m = Image('11.jpg', 'dir1/test1', settings) assert m.big == 'original/11.jpg' + m = Video('file.ogv', 'video', settings) + assert m.filename == 'file.webm' + assert m.big == 'original/file.ogv' + def test_image(settings, tmpdir): settings['destination'] = str(tmpdir) @@ -101,7 +104,7 @@ def test_video(settings, tmpdir): settings['destination'] = str(tmpdir) m = Video('stallman software-freedom-day-low.ogv', 'video', settings) file_path = join('video', 'stallman software-freedom-day-low.webm') - assert m.file_path == file_path + assert str(m) == file_path assert m.dst_path == join(settings['destination'], file_path) os.makedirs(join(settings['destination'], 'video', 'thumbnails')) diff --git a/tests/test_settings.py b/tests/test_settings.py index 50e5d51..b763d13 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -2,7 +2,7 @@ import os -from sigal.settings import read_settings, get_thumb, get_orig +from sigal.settings import read_settings, get_thumb CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -31,14 +31,6 @@ def test_get_thumb(settings): assert get_thumb(settings, src) == ref -def test_get_orig(settings): - tests = [('example.jpg', 'original/example.jpg'), - ('test/example.jpg', 'test/original/example.jpg'), - ('test/t/example.jpg', 'test/t/original/example.jpg')] - for src, ref in tests: - assert get_orig(settings, src) == ref - - def test_img_sizes(tmpdir): """Test that image size is swaped if needed."""