simplify Gallery parameters

This commit is contained in:
Simon
2012-10-30 00:27:12 +01:00
parent 8fbd43f4d5
commit 4d41236c2a
3 changed files with 9 additions and 8 deletions

View File

@@ -102,8 +102,9 @@ def main():
_DEFAULT_CONFIG_FILE))
# create gallery
gallery = Gallery(settings, args.input_dir)
gallery.build(args.output_dir, force=args.force)
gallery = Gallery(settings, args.input_dir, args.output_dir,
force=args.force)
gallery.build()
r = Generator(settings, args.output_dir)
r.generate()

View File

@@ -35,9 +35,11 @@ DESCRIPTION_FILE = "index.md"
class Gallery:
"Prepare images"
def __init__(self, settings, input_dir):
def __init__(self, settings, input_dir, output_dir, force=False):
self.settings = settings
self.force = force
self.input_dir = os.path.abspath(input_dir)
self.output_dir = os.path.abspath(output_dir)
self.logger = logging.getLogger(__name__)
def filelist(self):
@@ -49,12 +51,9 @@ class Gallery:
if os.path.splitext(f)[1] in self.settings['fileextlist']]
yield dirpath, dirnames, imglist
def build(self, output_dir, force=False):
def build(self):
"create image gallery"
self.output_dir = os.path.abspath(output_dir)
self.force = force
if not os.path.isdir(self.output_dir):
self.logger.info("Create output directory %s", self.output_dir)
os.makedirs(self.output_dir)

View File

@@ -16,7 +16,8 @@ class TestGallery(unittest.TestCase):
self.path = os.path.dirname(__file__)
default_conf = os.path.join(self.path, 'sample', 'sigal.conf')
settings = read_settings(default_conf)
self.gallery = Gallery(settings, os.path.join(self.path, 'sample'))
self.gallery = Gallery(settings, os.path.join(self.path, 'sample'),
os.path.join(self.path, 'output'))
def test_filelist(self):
file_generator = self.gallery.filelist()