Import (ConfigParser|configparser) as configparser
This commit is contained in:
parent
718bb41ff5
commit
7b67581d11
14
blogthon.cgi
14
blogthon.cgi
@ -21,9 +21,9 @@ import re
|
|||||||
|
|
||||||
# Backward compatibilty to python2
|
# Backward compatibilty to python2
|
||||||
try:
|
try:
|
||||||
import configparser
|
import configparser as configparser
|
||||||
except:
|
except ImportError:
|
||||||
import ConfigParser
|
import ConfigParser as configparser
|
||||||
|
|
||||||
from cgi import FieldStorage
|
from cgi import FieldStorage
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
@ -77,10 +77,7 @@ def document_header(string):
|
|||||||
print("<rss version=\"2.0\">")
|
print("<rss version=\"2.0\">")
|
||||||
|
|
||||||
# Parse configuration (with backward compatibilty)
|
# Parse configuration (with backward compatibilty)
|
||||||
try:
|
configuration = configparser.SafeConfigParser()
|
||||||
configuration = configparser.SafeConfigParser()
|
|
||||||
except:
|
|
||||||
configuration = ConfigParser.SafeConfigParser()
|
|
||||||
|
|
||||||
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
||||||
if os.path.exists(config):
|
if os.path.exists(config):
|
||||||
@ -117,9 +114,6 @@ try:
|
|||||||
feed_preview = configuration.get("feed", "feed_preview")
|
feed_preview = configuration.get("feed", "feed_preview")
|
||||||
except configparser.Error as error:
|
except configparser.Error as error:
|
||||||
errorpage(str(error))
|
errorpage(str(error))
|
||||||
# And for backward compatibility
|
|
||||||
except ConfigParser.Error as error:
|
|
||||||
errorpage(str(error))
|
|
||||||
|
|
||||||
if not re.match("^http:\/\/.*$", blog_url):
|
if not re.match("^http:\/\/.*$", blog_url):
|
||||||
blog_url = "http://" + blog_url
|
blog_url = "http://" + blog_url
|
||||||
|
Loading…
Reference in New Issue
Block a user