From f9bc02e1c0d8aa4dc68221259ba50265c8a6c185 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Wed, 23 Mar 2011 14:57:43 +0100 Subject: Use print() for python3 compatibility --- blogthon.cgi | 380 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 190 insertions(+), 190 deletions(-) (limited to 'blogthon.cgi') diff --git a/blogthon.cgi b/blogthon.cgi index a8e05df..1151890 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -39,35 +39,35 @@ def generate_uuid(string): def errorpage(string): document_header("html") - print "" - print tab + "Error!" - print tab + "" - print "" - print "" - print tab + "
" - print tab*2 + "

Error!

" - print tab*2 + "

" + string + "

" - print tab + "
" - print "" - print "" + print("") + print(tab + "Error!") + print(tab + "") + print("") + print("") + print(tab + "
") + print(tab*2 + "

Error!

") + print(tab*2 + "

" + string + "

") + print(tab + "
") + print("") + print("") sys.exit() def document_header(string): if string == "html": - print "Content-type: text/html\n" - print "" + print("Content-type: text/html\n") + print("") try: - print "" + print("") except NameError: - print "" + print("") if string == "atom": - print "Content-type: application/atom+xml\n" - print "" - print "" + print("Content-type: application/atom+xml\n") + print("") + print("") if string == "rss": - print "Content-type: application/rss+xml\n" - print "" - print "" + print("Content-type: application/rss+xml\n") + print("") + print("") # Parse configuration configuration = ConfigParser.SafeConfigParser() @@ -272,56 +272,56 @@ if feed_display == "atom": sec = "%(#)02d" % {"#": int(date[5])} document_header("atom") - print "" % blog_url - print tab + "" - print tab*2 + "%s" % blog_title - print tab + "" - print tab + "%s" % blog_title - print tab + "urn:uuid:%s" % blog_title_md5sum - print tab + "%s-%s-%sT%s:%s:%sZ" % (str(date[0]), month, day, hour, min, sec) - print "" + print("" % blog_url) + print(tab + "") + print(tab*2 + "%s" % blog_title) + print(tab + "") + print(tab + "%s" % blog_title) + print(tab + "urn:uuid:%s" % blog_title_md5sum) + print(tab + "%s-%s-%sT%s:%s:%sZ" % (str(date[0]), month, day, hour, min, sec)) + print("") j = len(entries) if j > 10: j = 10 for i in xrange(0, j): title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "") date = entries[i][0] title_md5sum = generate_uuid(title) - print tab*2 + "" - print tab*3 + "%s" % title - print tab*3 + "" % (blog_url, title) - print tab*3 + "urn:uuid:%s" % title_md5sum - print tab*3 + "%s-%s-%sT%s:%s:%sZ" % (str(date[0]), month, day, hour, min, sec) - print tab*3 + "" + print(tab*2 + "") + print(tab*3 + "%s" % title) + print(tab*3 + "" % (blog_url, title)) + print(tab*3 + "urn:uuid:%s" % title_md5sum) + print(tab*3 + "%s-%s-%sT%s:%s:%sZ" % (str(date[0]), month, day, hour, min, sec)) + print(tab*3 + "") content = open(str(entries[i][1]), "r") for h in xrange(0, int(feed_preview)): rss_line = content.readline().strip() if rss_line != "": - print tab*4 + rss_line + print(tab*4 + rss_line) content.close() - print tab*3 + "" - print tab*2 + "" - print "" + print(tab*3 + "") + print(tab*2 + "") + print("") # Generate rss 2.0 feed elif feed_display == "rss": document_header("rss") - print tab + "" - print tab*2 + "%s" % blog_title - print tab*2 + "%s" % blog_url - print tab*2 + "%s" % blog_subtitle + print(tab + "") + print(tab*2 + "%s" % blog_title) + print(tab*2 + "%s" % blog_url) + print(tab*2 + "%s" % blog_subtitle) date = time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime(time.mktime(entries[0][0]))) - print tab*2 + "%s" % date - print "" + print(tab*2 + "%s" % date) + print("") j = len(entries) if j > 10: j = 10 for i in xrange(0, j): title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "") date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0]))) - print tab*2 + "" - print tab*3 + "%s" % title - print tab*3 + "%s?p=%s" % (blog_url, title) - print tab*3 + "%s?p=%s" % (blog_url, title) - print tab*3 + "%s" % date + print(tab*2 + "") + print(tab*3 + "%s" % title) + print(tab*3 + "%s?p=%s" % (blog_url, title)) + print(tab*3 + "%s?p=%s" % (blog_url, title)) + print(tab*3 + "%s" % date) content = open(str(entries[i][1]), "r") rss_description= "" for h in xrange(0, int(feed_preview)): @@ -329,24 +329,24 @@ elif feed_display == "rss": if line: rss_description = "%s%s
" % (rss_description, line) content.close() - print tab*3 + "" % rss_description - print tab*2 + "
" - print tab + "
" - print "" + print(tab*3 + "" % rss_description) + print(tab*2 + "") + print(tab + "
") + print("") # Generate regular page else: document_header("html") - print tab + "" - print tab*2 + "%s" % blog_title - print tab*2 + "" - print tab*2 + "" - print tab*2 + "" % keywords - print tab*2 + "" % blog_title - print tab*2 + "" % (style, style) - print tab + "" - print tab + "" - print "" + print(tab + "") + print(tab*2 + "%s" % blog_title) + print(tab*2 + "") + print(tab*2 + "") + print(tab*2 + "" % keywords) + print(tab*2 + "" % blog_title) + print(tab*2 + "" % (style, style)) + print(tab + "") + print(tab + "") + print # Plugins sys.path.append(plugins_dir) @@ -354,37 +354,37 @@ else: __import__ (plugin.split("/")[1].replace(".py", "")) # Site header - print tab*2 + "
" - print tab*3 + "
" - print tab*4 + "%s" % blog_title - print tab*3 + "
" - print tab*3 + "
" - print tab*4 + "%s" % blog_subtitle - print tab*3 + "
" - print tab*2 + "
" - print "" + print(tab*2 + "
") + print(tab*3 + "
") + print(tab*4 + "%s" % blog_title) + print(tab*3 + "
") + print(tab*3 + "
") + print(tab*4 + "%s" % blog_subtitle) + print(tab*3 + "
") + print(tab*2 + "
") + print("") # RSS feed - print tab*2 + "
" - print tab*3 + "rss" - print tab*2 + "
" - print "" + print(tab*2 + "
") + print(tab*3 + "rss") + print(tab*2 + "
") + print("") # Atom feed - print tab*2 + "
" - print tab*3 + "atom" - print tab*2 + "
" - print "" + print(tab*2 + "
") + print(tab*3 + "atom") + print(tab*2 + "
") + print("") # Staticpages if staticpages == "True": staticpages = [] staticpages_list = glob(os.path.join(staticpages_dir, "*")) staticpages_list.sort() - print tab*2 + "
" - print tab*3 + "
%s
" % blog_locale[0] - print tab*3 + "
" - print tab*4 + "
    " + print(tab*2 + "
    ") + print(tab*3 + "
    %s
    " % blog_locale[0]) + print(tab*3 + "
    ") + print(tab*4 + "
      ") for staticpage in staticpages_list: file = open(staticpage, "r") header = file.readline() @@ -395,78 +395,78 @@ else: link = "?s=%s" % link file.close() title = re.sub("\w+?\/\d+?-", "", staticpage) - print tab*5 + "
    • %s
    • " % (link, title) - print tab*4 + "
    " - print tab*3 + "
    " - print tab*3 + "
    " - print tab*2 + "
    " - print "" + print(tab*5 + "
  • %s
  • " % (link, title)) + print(tab*4 + "
") + print(tab*3 + "
") + print(tab*3 + "
") + print(tab*2 + "
") + print("") # Monthlist if monthlist == "True": olddate = "" - print tab*2 + "
" - print tab*3 + "
%s
" % blog_locale[1] - print tab*3 + "
" - print tab*4 + "
    " + print(tab*2 + "
    ") + print(tab*3 + "
    %s
    " % blog_locale[1]) + print(tab*3 + "
    ") + print(tab*4 + "
      ") for entry in entries: date = time.strftime("%m%Y", entry[0]) date_display = time.strftime("%h %Y", entry[0]) if not olddate == date: - print tab*5 + "
    • %s
    • " % (date, date_display) + print(tab*5 + "
    • %s
    • " % (date, date_display)) olddate = date - print tab*4 + "
    " - print tab*3 + "
    " - print tab*3 + "
    " - print tab*2 + "
    " - print "" + print(tab*4 + "
") + print(tab*3 + "
") + print(tab*3 + "
") + print(tab*2 + "
") + print("") # Linklist if linklist == "True": - print tab*2 + "
" - print tab*3 + "" % blog_locale[2] - print tab*3 + "") + print(tab*3 + "") + print(tab*2 + "
") + print("") - print tab*2 + "
" - print "" + print(tab*2 + "
") + print("") # Staticpage if static_display != "": content = open(os.path.join(staticpages_dir, static_display), "r") - print tab*3 + "
" - print tab*4 + "
%s
" % re.sub("^\.", "", re.sub("\d+?-", "", static_display)) - print tab*4 + "
" - print tab*5 + "

" + print(tab*3 + "

") + print(tab*4 + "
%s
" % re.sub("^\.", "", re.sub("\d+?-", "", static_display))) + print(tab*4 + "
") + print(tab*5 + "

") for line in content: if no_break.match(line): - print tab*5 + line.strip() + print(tab*5 + line.strip()) else: - print tab*5 + line.strip() + "
" - print tab*5 + "

" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*3 + "
" - print "" + print(tab*5 + line.strip() + "
") + print(tab*5 + "

") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*3 + "
") + print("") content.close() # Entry @@ -488,24 +488,24 @@ else: if post_display == title.replace(" ", "-") or not post_display: if allentries_display == "1" or entry_counter < entries_per_page: content = open(entry, "r") - print tab*3 + "
" + print(tab*3 + "
") if permalinks: - print tab*4 + "" % (title.replace(" ", "-"), title) + print(tab*4 + "" % (title.replace(" ", "-"), title)) else: - print tab*4 + "
%s
" % title - print tab*4 + "
%s
" % date - print tab*4 + "
" + print(tab*4 + "
%s
" % title) + print(tab*4 + "
%s
" % date) + print(tab*4 + "
") for line in content: if no_break.match(line): - print tab*5 + line.strip() + print(tab*5 + line.strip()) else: - print tab*5 + line.strip() + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" - print tab*4 + "
" + print(tab*5 + line.strip() + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") + print(tab*4 + "
") # Comments... # ... are shown when post_display and comments_file isn't false @@ -513,10 +513,10 @@ else: if post_display: if comments_file: comments_content = open(comments_file[0], "r") - print tab*3 + "
" - print tab*2 + "
" - print "" - print tab*2 + "
" + print(tab*3 + "
") + print(tab*2 + "
") + print("") + print(tab*2 + "
") notfirstline = 0 # Ugly fix for closing comment containers label_count = 0 @@ -524,83 +524,83 @@ else: for line in comments_content: if line_start_hyphen.match(line): if notfirstline == 1: - print tab*4 + "
" - print tab*3 + "
" + print(tab*4 + "") + print(tab*3 + "") notfirstline = 0 - print tab*3 + "
" + print(tab*3 + "
") # Label for each comment label_count += 1 - print tab*4 + "" % str(label_count) + print(tab*4 + "" % str(label_count)) - print tab*4 + "
%s
" % line.split(".", 1)[1].strip() + print(tab*4 + "
%s
" % line.split(".", 1)[1].strip()) elif line_start_plus.match(line): - print tab*4 + "
%s
" % line.split(".", 1)[1].strip() - print tab*4 + "
" + print(tab*4 + "
%s
" % line.split(".", 1)[1].strip()) + print(tab*4 + "
") else: notfirstline = 1 line = line.split(".", 1)[1] - print tab*5 + line.strip() + "
" - print "" - print tab*4 + "
" - print tab*3 + "
" + print(tab*5 + line.strip() + "
") + print("") + print(tab*4 + "
") + print(tab*3 + "
") comments_content.close() else: - print tab*3 + "" - print tab*2 + "" - print tab*2 + "
" + print(tab*3 + "
") + print(tab*2 + "") + print(tab*2 + "
") # Form for adding comments if comments == "True": random_int_a = randint(1,9) random_int_b = randint(1,9) cquizv = random_int_a + random_int_b - print tab*3 + "
" - print tab*4 + "
" - print tab*5 + "" % title - print tab*5 + "" % str(cquizv) - print tab*5 + "" % blog_locale[6] - print tab*5 + "
" % blog_locale[7] - print tab*5 + "
" % (str(random_int_a), str(random_int_b)) - print tab*5 + "
" % blog_locale[8] - print tab*4 + "
" - print tab*3 + "
" + print(tab*3 + "
") + print(tab*4 + "
") + print(tab*5 + "" % title) + print(tab*5 + "" % str(cquizv)) + print(tab*5 + "" % blog_locale[6]) + print(tab*5 + "
" % blog_locale[7]) + print(tab*5 + "
" % (str(random_int_a), str(random_int_b))) + print(tab*5 + "
" % blog_locale[8]) + print(tab*4 + "
") + print(tab*3 + "
") else: - print tab*3 + "
" - print "" + print(tab*3 + "
") + print("") if comments == "True": comments_file = glob(os.path.join(entries_dir, title + ".comments")) if not comments_file and not post_display: - print tab*4 + "
" - print tab*5 + "%s" % (title.replace(" ", "-"), blog_locale[3]) - print tab*4 + "
" - print tab*3 + "
" - print "" + print(tab*4 + "
") + print(tab*5 + "%s" % (title.replace(" ", "-"), blog_locale[3])) + print(tab*4 + "
") + print(tab*3 + "") + print("") elif comments_file and not post_display: comments_content = open(comments_file[0], "r") comments_counter = 0 for line in comments_content: if line.split(".", 1)[0] == "-": comments_counter += 1 - print tab*4 + "
" - print tab*5 + "%s (%s)" % (title.replace(" ", "-"), blog_locale[4], str(comments_counter)) - print tab*4 + "
" - print tab*3 + "" - print "" + print(tab*4 + "
") + print(tab*5 + "%s (%s)" % (title.replace(" ", "-"), blog_locale[4], str(comments_counter))) + print(tab*4 + "
") + print(tab*3 + "") + print("") comments_content.close() else: - print tab*3 + "" - print "" + print(tab*3 + "") + print("") content.close() entry_counter += 1 if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist - print tab*3 + "" % blog_locale[5] + print(tab*3 + "" % blog_locale[5]) - print tab*2 + "" - print "" - print tab + "" - print "" + print(tab*2 + "") + print("") + print(tab + "") + print("") # vim: set sw=4 tw=0 ts=4 expandtab: -- cgit v1.2.3