From 69d14b233702247476de8fbb1b9bf4a63f73cc7e Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Thu, 19 Aug 2021 10:49:35 +0300 Subject: [PATCH] photos in config order, always modify config if new files appear --- mirva/mirva.py | 25 ++++++++++++++++--------- setup.py | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/mirva/mirva.py b/mirva/mirva.py index 4077b78..50496f0 100755 --- a/mirva/mirva.py +++ b/mirva/mirva.py @@ -24,41 +24,44 @@ class Mirva: self.create_config() print("Exiting. Check config.") return + self.create_config() self.get_config() self.create_posts() self.write_index() self.write_mediums() def create_config(self): - print("Creating config: {}".format(os.path.join(self.options.folder,self.config_file))) config = configparser.ConfigParser() config.read(self.config_file) + config_changed = False if not "SITE" in config: config["SITE"] = { "title": "", "sub_title": "", "intro": "", } + config_changed = True for f in self.file_list: if not f in config: config[f] = {"title": f, "description": ""} + config_changed = True - with open(self.config_file, "wt") as fp: - config.write(fp) + if config_changed: + print("Modified config: {}".format(os.path.join(self.options.folder,self.config_file))) + with open(self.config_file, "wt") as fp: + config.write(fp) def create_posts(self): self.posts = [] - for f in self.file_list: - if not f in self.config: - post = self.get_post(f, f, "") - else: + for c in self.config: + if c in self.file_list: post = self.get_post( - f, self.config[f]["title"], self.config[f]["description"] + c, self.config[c]["title"], self.config[c]["description"] ) - self.posts.append(post) + self.posts.append(post) def get_config(self): self.config = configparser.ConfigParser() @@ -218,6 +221,8 @@ function create_button(direction, to) {{ pass for f in ("style.css", "arrow_up.png", "arrow_down.png", "banner.jpg", "mirva.ico"): + if os.path.exists(os.path.join(self.resource_dir, f)): + continue shutil.copy( os.path.join(self.resource_src, f), os.path.join(self.resource_dir, f) ) @@ -251,6 +256,8 @@ function create_button(direction, to) {{ "85", outfile, ] + sys.stdout.write(".") subprocess.call(convargs) + diff --git a/setup.py b/setup.py index bfe2dc9..bf05e69 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( ], package_data={'':['resources/*']}, include_package_data=True, - version = '20210601', + version = '20210819', description = 'A tool to create a web gallery from a folder of images.', author = 'Ville Rantanen', author_email = 'ville.q.rantanen@gmail.com',