Исправлено чтение данных из calculate.env

master3.4 3.4.0_beta2
Mike Hiretsky 9 years ago
parent b82a5ff87f
commit 44eb2cafdb

@ -19,7 +19,7 @@ ConfigParser -- responsible for parsing a list of
__init__(defaults=None, dict_type=_default_dict, allow_no_value=False,
delimiters=('=', ':'), comment_prefixes=('#', ';'),
inline_comment_prefixes=None, strict=True,
inline_comment_prefixes=None, strict=False,
empty_lines_in_values=True):
Create the parser. When `defaults' is given, it is initialized into the
dictionary or intrinsic defaults. The keys must be strings, the values
@ -612,7 +612,7 @@ class RawConfigParser(MutableMapping):
if 'empty_lines_in_values' in _3to2kwargs: empty_lines_in_values = _3to2kwargs['empty_lines_in_values']; del _3to2kwargs['empty_lines_in_values']
else: empty_lines_in_values = True
if 'strict' in _3to2kwargs: strict = _3to2kwargs['strict']; del _3to2kwargs['strict']
else: strict = True
else: strict = False
if 'inline_comment_prefixes' in _3to2kwargs: inline_comment_prefixes = _3to2kwargs['inline_comment_prefixes']; del _3to2kwargs['inline_comment_prefixes']
else: inline_comment_prefixes = None
if 'comment_prefixes' in _3to2kwargs: comment_prefixes = _3to2kwargs['comment_prefixes']; del _3to2kwargs['comment_prefixes']

@ -31,7 +31,7 @@ import operator
import traceback
from contextlib import contextmanager
from types import StringTypes
from calculate.lib.configparser import ConfigParser
from calculate.lib.configparser import ConfigParser, ParsingError
def addStdConfig(fileLst,prefix='/'):
stdPath = path.join(prefix,
@ -857,11 +857,18 @@ class SimpleDataVars(object):
config = ConfigParser(strict=False)
if path.isdir(iniFile):
rs = RepositorySubstituting(self, system_root=system_root)
config.read(addStdConfig(
searchProfile(iniFile, 'calculate.env', repository_sub=rs),
try:
config.read(addStdConfig(
searchProfile(iniFile, 'calculate.env',
repository_sub=rs),
prefix=self.systemRoot), encoding="utf-8")
except ParsingError:
raise DataVarsError(_("Error in calculate.env in profile"))
else:
config.read(iniFile, encoding="utf-8")
try:
config.read(iniFile, encoding="utf-8")
except ParsingError:
raise DataVarsError(_("Error in %s") % iniFile)
importVars = {}
for varname, varobj in self.allVars.items():
if varobj.section not in importVars:
@ -1189,10 +1196,12 @@ class DataVars(SimpleDataVars):
for iniFile in calculateIniFiles:
if path.exists(iniFile):
config = ConfigParser(strict=False)
config.read(iniFile, encoding="utf-8")
try:
config.read(iniFile, encoding="utf-8")
value = config[section][varname]
retVal = value
except ParsingError:
raise DataVarsError(_("Error in %s") % iniFile)
except KeyError:
pass
return retVal.encode('UTF-8')
@ -1244,12 +1253,20 @@ class DataVars(SimpleDataVars):
config = ConfigParser(strict=False)
if iniName == 'profile':
repos = RepositorySubstituting(self)
config.read(addStdConfig(
try:
config.read(addStdConfig(
searchProfile(iniFile,'calculate.env',
repository_sub=repos)),
encoding="utf-8")
except ParsingError:
raise DataVarsError(
_("Error in profile calculate.env"))
else:
config.read(iniFile, encoding="utf-8")
try:
config.read(iniFile, encoding="utf-8")
except ParsingError:
raise DataVarsError(
_("Error in %s")%iniFile)
iniSections = config.sections()
if not iniSections:
continue

Loading…
Cancel
Save