mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
turn off strict config parsing in py3
This commit is contained in:
parent
650bb6fa26
commit
086c700151
13
WakaTime.py
13
WakaTime.py
@ -34,9 +34,10 @@ except ImportError:
|
|||||||
import queue # py3
|
import queue # py3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ConfigParser as configparser
|
from ConfigParser import SafeConfigParser as ConfigParser
|
||||||
|
from ConfigParser import Error as ConfigParserError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import configparser
|
from configparser import ConfigParser, Error as ConfigParserError
|
||||||
try:
|
try:
|
||||||
from urllib2 import urlopen, urlretrieve, ProxyHandler, build_opener, install_opener, HTTPError
|
from urllib2 import urlopen, urlretrieve, ProxyHandler, build_opener, install_opener, HTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -154,13 +155,17 @@ def parseConfigFile(configFile):
|
|||||||
at ~/.wakatime.cfg.
|
at ~/.wakatime.cfg.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
configs = configparser.SafeConfigParser()
|
kwargs = {} if is_py2 else {'strict': False}
|
||||||
|
configs = ConfigParser(**kwargs)
|
||||||
try:
|
try:
|
||||||
with open(configFile, 'r', encoding='utf-8') as fh:
|
with open(configFile, 'r', encoding='utf-8') as fh:
|
||||||
try:
|
try:
|
||||||
|
if is_py2:
|
||||||
configs.readfp(fh)
|
configs.readfp(fh)
|
||||||
|
else:
|
||||||
|
configs.read_file(fh)
|
||||||
return configs
|
return configs
|
||||||
except configparser.Error:
|
except ConfigParserError:
|
||||||
log(ERROR, traceback.format_exc())
|
log(ERROR, traceback.format_exc())
|
||||||
return None
|
return None
|
||||||
except IOError:
|
except IOError:
|
||||||
|
Loading…
Reference in New Issue
Block a user