py3k: The ConfigParser module has been renamed to configparser

This commit is contained in:
Justus Winter 2011-12-14 11:58:20 +01:00 committed by Sebastian Spaeth
parent 676ce952d3
commit 4ed0362d41
2 changed files with 13 additions and 2 deletions

View file

@ -17,7 +17,12 @@ import stat
import email import email
from notmuch import Database, Query, NotmuchError, STATUS from notmuch import Database, Query, NotmuchError, STATUS
from ConfigParser import SafeConfigParser try:
# python3.x
from configparser import SafeConfigParser
except ImportError:
# python2.x
from ConfigParser import SafeConfigParser
from cStringIO import StringIO from cStringIO import StringIO
PREFIX = re.compile('(\w+):(.*$)') PREFIX = re.compile('(\w+):(.*$)')

View file

@ -543,7 +543,13 @@ class Database(object):
""" Reads a user's notmuch config and returns his db location """ Reads a user's notmuch config and returns his db location
Throws a NotmuchError if it cannot find it""" Throws a NotmuchError if it cannot find it"""
try:
# python3.x
from configparser import SafeConfigParser
except ImportError:
# python2.x
from ConfigParser import SafeConfigParser from ConfigParser import SafeConfigParser
config = SafeConfigParser() config = SafeConfigParser()
conf_f = os.getenv('NOTMUCH_CONFIG', conf_f = os.getenv('NOTMUCH_CONFIG',
os.path.expanduser('~/.notmuch-config')) os.path.expanduser('~/.notmuch-config'))