From 947a8e5b58859078ab5a260a1664610673ddf0e2 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Tue, 7 Dec 2010 13:48:40 +0530 Subject: [PATCH] Fixed except statements subtle syntax error Now fixed the except statements by wrapping multiple exceptions as a tuple. Earlier the exceptions were not wrapped in parantheses and though not a syntax error, it was not what was intended. --- biaweb_exporter.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/biaweb_exporter.py b/biaweb_exporter.py index b940867..2f1a306 100644 --- a/biaweb_exporter.py +++ b/biaweb_exporter.py @@ -132,7 +132,7 @@ def generate_search_index (dbname, conf, full_text_index = True): fhtaccess = open (htaccess_path, "w+") fhtaccess.write (biaweb_strings.searchindex_htaccess) fhtaccess.close () - except OSError, IOError: + except (OSError, IOError): return False # finally return true @@ -147,7 +147,7 @@ def copy_files_folders (conf, files_to_copy, folders_to_copy): try: os.mkdir (os.path.join (conf[5], "cgi-bin")) shutil.copy2 (search_script_path, os.path.join(conf[5], "cgi-bin")) - except IOError, OSError: + except (IOError, OSError): return False # try to copy the star rating images to destination directory if possible @@ -157,12 +157,12 @@ def copy_files_folders (conf, files_to_copy, folders_to_copy): if os.path.exists (rating_img_star): try: shutil.copy2 (rating_img_star, conf[5]) - except IOError, OSError: + except (IOError, OSError): return False if os.path.exists (rating_img_greystar): try: shutil.copy2 (rating_img_greystar, conf[5]) - except IOError, OSError: + except (IOError, OSError): return False # additional files to copy @@ -175,7 +175,7 @@ def copy_files_folders (conf, files_to_copy, folders_to_copy): full_dest = os.path.join (conf[5], dest) try: shutil.copy2 (src, full_dest) - except IOError, OSError: + except (IOError, OSError): return False # additional folders to copy @@ -187,7 +187,7 @@ def copy_files_folders (conf, files_to_copy, folders_to_copy): full_dest = os.path.join (conf[5], dest) try: shutil.copytree (src, full_dest) - except IOError, OSError: + except (IOError, OSError): return False # finally return true @@ -233,7 +233,7 @@ def generate_article_pages (dbname, conf, templates, category_str, bestrated_str try: farticle = open (os.path.join (conf[5], art[13], art[8] + ".html"), "w+") farticle.write (articlepage_str) - except OSError, IOError: + except (OSError, IOError): return False # finally return true @@ -253,7 +253,7 @@ def generate_category_indices (dbname, conf, templates, category_str, bestrated_ try: # create the category directory os.mkdir (os.path.join (conf[5], cat[3])) - except IOError, OSError: + except (IOError, OSError): return False # now get the list of articles for the specified category @@ -298,7 +298,7 @@ def generate_category_indices (dbname, conf, templates, category_str, bestrated_ fcatindex = open (os.path.join (conf[5], cat[3], "index.html"), "w+") fcatindex.write (categoryindex_str) fcatindex.close () - except OSError, IOError: + except (OSError, IOError): return False # finally return true @@ -339,7 +339,7 @@ def generate_rss_feed (dbname, conf): try: frss = open (os.path.join (conf[5], "subscribe.xml"), "w+") frss.write (rss_str) - except IOError, OSError: + except (IOError, OSError): return False # finally return true @@ -399,7 +399,7 @@ def generate_home_page (dbname, conf, templates, category_str, bestrated_str): findex = open (os.path.join (conf[5], "index.html"), "w+") findex.write (main_str) findex.close () - except IOError, OSError: + except (IOError, OSError): return False # write the style.css file in the destination directory @@ -407,7 +407,7 @@ def generate_home_page (dbname, conf, templates, category_str, bestrated_str): fstyle = open (os.path.join (conf[5], "style.css"), "w+") fstyle.write (templates[5][1]) fstyle.close () - except IOError, OSError: + except (IOError, OSError): return False return True -- 2.20.1