From a551cbd4e331dd40cdb1acbdb225d6290bd6dfd7 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sat, 27 Jul 2013 22:21:43 +0200 Subject: [PATCH] Still bug corrections... Tests continue :) --- pre-commit.py | 61 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/pre-commit.py b/pre-commit.py index 79262de..ce87ee1 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -191,13 +191,15 @@ for filename in list(added_files): try: int(filename[4:8]) - years_list.append(filename[4:8]) + if filename[4:8] not in years_list: + years_list.append(filename[4:8]) except ValueError: direct_copy = True try: - int(filename[8:10]) - months_list.append(filename[8:10]) + int(filename[9:11]) + if filename[9:11] not in months_list: + months_list.append(filename[9:11]) except ValueError: pass @@ -226,13 +228,15 @@ for filename in list(modified_files): continue try: int(filename[4:8]) - years_list.append(filename[4:8]) + if filename[4:8] not in years_list: + years_list.append(filename[4:8]) except ValueError: direct_copy = True try: - int(filename[8:10]) - months_list.append(filename[8:10]) + int(filename[9:11]) + if filename[9:11] not in months_list: + months_list.append(filename[9:11]) except ValueError: pass @@ -260,13 +264,15 @@ for filename in list(deleted_files): try: int(filename[4:8]) - years_list.append(filename[4:8]) + if filename[4:8] not in years_list: + years_list.append(filename[4:8]) except ValueError: direct_delete = True try: - int(filename[8:10]) - months_list.append(filename[8:10]) + int(filename[9:11]) + if filename[9:11] not in months_list: + months_list.append(filename[9:11]) except ValueError: pass @@ -423,7 +429,7 @@ for filename in deleted_files: last_articles = latest_articles("raw/", int(params["NB_ARTICLES_INDEX"])) tags_full_list = list_directory("gen/tags") -# Generate html for each article +# Generate html for each article (gen/ dir) for filename in added_files+modified_files: try: with open(filename, 'r') as fh: @@ -464,7 +470,8 @@ for filename in added_files+modified_files: "\t\t

"+title+"

\n" "\t\t"+article+"\n" "\t\t

"+date_readable+"

\n" - "\t\n") + "\t\n" + "\n") print("[INFO] (GEN ARTICLES) Article "+filename[4:]+" generated") except IOError: sys.exit("[ERROR] An error occurred when writing generated HTML for " @@ -487,7 +494,7 @@ except IOError: header = header.replace("@tags", tags_header, 1) header = header.replace("@blog_url", params["BLOG_URL"], 1) articles_header = "