3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from tools.buildconfig import BuildConfigParser
18 from tools.statics import BUILD_CONFIG_PATH
19 from tools.utils import validate_environ
22 class RepositoryConfig(object):
23 def __init__(self, ini_file=BUILD_CONFIG_PATH):
24 self.config = BuildConfigParser(ini_file=ini_file)
26 def read_section(self, section):
28 for repo_name, repo_value in self.config.items(section):
29 parts = repo_value.split('#')
30 repodata = dict(name=repo_name, baseurl=parts[0])
32 key, value = p.split('=', 1)
34 repositories.append(repodata)
37 def read_sections(self, sections):
40 repositories += self.read_section(s)
44 def get_localrepo(cls, remote=False):
47 validate_environ(['BUILD_URL'])
48 baseurl = os.path.join(os.environ['BUILD_URL'], 'artifact/results', dirname)
50 validate_environ(['WORKSPACE'])
51 baseurl = 'file://' + \
52 os.path.join(os.environ['WORKSPACE'], 'results', dirname)
53 return dict(name='localrepo', baseurl=baseurl)