36
36
'ConfigError' ,
37
37
'ConfigOptionNotSupportedError' ,
38
38
'InvalidConfig' ,
39
- 'ProjectConfig' ,
40
39
)
41
40
42
41
ALL = 'all'
@@ -110,12 +109,10 @@ class InvalidConfig(ConfigError):
110
109
111
110
message_template = 'Invalid "{key}": {error}'
112
111
113
- def __init__ (self , key , code , error_message , source_file = None ,
114
- source_position = None ):
112
+ def __init__ (self , key , code , error_message , source_file = None ):
115
113
self .key = key
116
114
self .code = code
117
115
self .source_file = source_file
118
- self .source_position = source_position
119
116
message = self .message_template .format (
120
117
key = key ,
121
118
code = code ,
@@ -144,11 +141,10 @@ class BuildConfigBase(object):
144
141
145
142
version = None
146
143
147
- def __init__ (self , env_config , raw_config , source_file , source_position ):
144
+ def __init__ (self , env_config , raw_config , source_file ):
148
145
self .env_config = env_config
149
146
self .raw_config = raw_config
150
147
self .source_file = source_file
151
- self .source_position = source_position
152
148
if os .path .isdir (self .source_file ):
153
149
self .base_path = self .source_file
154
150
else :
@@ -160,10 +156,7 @@ def __init__(self, env_config, raw_config, source_file, source_position):
160
156
def error (self , key , message , code ):
161
157
"""Raise an error related to ``key``."""
162
158
if not os .path .isdir (self .source_file ):
163
- source = '{file} [{pos}]' .format (
164
- file = os .path .relpath (self .source_file , self .base_path ),
165
- pos = self .source_position ,
166
- )
159
+ source = os .path .relpath (self .source_file , self .base_path )
167
160
error_message = '{source}: {message}' .format (
168
161
source = source ,
169
162
message = message ,
@@ -175,7 +168,6 @@ def error(self, key, message, code):
175
168
code = code ,
176
169
error_message = error_message ,
177
170
source_file = self .source_file ,
178
- source_position = self .source_position ,
179
171
)
180
172
181
173
@contextmanager
@@ -189,7 +181,6 @@ def catch_validation_error(self, key):
189
181
code = error .code ,
190
182
error_message = str (error ),
191
183
source_file = self .source_file ,
192
- source_position = self .source_position ,
193
184
)
194
185
195
186
def pop (self , name , container , default , raise_ex ):
@@ -1043,16 +1034,6 @@ def submodules(self):
1043
1034
return Submodules (** self ._config ['submodules' ])
1044
1035
1045
1036
1046
- class ProjectConfig (list ):
1047
-
1048
- """Wrapper for multiple build configs."""
1049
-
1050
- def validate (self ):
1051
- """Validates each configuration build."""
1052
- for build in self :
1053
- build .validate ()
1054
-
1055
-
1056
1037
def load (path , env_config ):
1057
1038
"""
1058
1039
Load a project configuration and the top-most build config for a given path.
@@ -1068,10 +1049,9 @@ def load(path, env_config):
1068
1049
'No configuration file found' ,
1069
1050
code = CONFIG_REQUIRED
1070
1051
)
1071
- build_configs = []
1072
1052
with open (filename , 'r' ) as configuration_file :
1073
1053
try :
1074
- configs = parse (configuration_file .read ())
1054
+ config = parse (configuration_file .read ())
1075
1055
except ParseError as error :
1076
1056
raise ConfigError (
1077
1057
'Parse error in {filename}: {message}' .format (
@@ -1080,23 +1060,19 @@ def load(path, env_config):
1080
1060
),
1081
1061
code = CONFIG_SYNTAX_INVALID ,
1082
1062
)
1083
- for i , config in enumerate (configs ):
1084
- allow_v2 = env_config .get ('allow_v2' )
1085
- if allow_v2 :
1086
- version = config .get ('version' , 1 )
1087
- else :
1088
- version = 1
1089
- build_config = get_configuration_class (version )(
1090
- env_config ,
1091
- config ,
1092
- source_file = filename ,
1093
- source_position = i ,
1094
- )
1095
- build_configs .append (build_config )
1063
+ allow_v2 = env_config .get ('allow_v2' )
1064
+ if allow_v2 :
1065
+ version = config .get ('version' , 1 )
1066
+ else :
1067
+ version = 1
1068
+ build_config = get_configuration_class (version )(
1069
+ env_config ,
1070
+ config ,
1071
+ source_file = filename ,
1072
+ )
1096
1073
1097
- project_config = ProjectConfig (build_configs )
1098
- project_config .validate ()
1099
- return project_config
1074
+ build_config .validate ()
1075
+ return build_config
1100
1076
1101
1077
1102
1078
def get_configuration_class (version ):
0 commit comments