Allow parent section for dox.yaml
Allow section to have parent like tox.ini, i.e: foo: images: - image1 foo:bar: commands: - blah would have foo:bar getting the image image1 since dependent of foo Change-Id: I613db9ed9ac16c978ef8a42a604992ce2205bc08
This commit is contained in:
parent
336d174cee
commit
9f33ae5252
14
dox.yml
14
dox.yml
@ -10,20 +10,10 @@ testing:
|
|||||||
- export PYTHONHASHSEED=$RANDOM
|
- export PYTHONHASHSEED=$RANDOM
|
||||||
- python setup.py testr --slowest
|
- python setup.py testr --slowest
|
||||||
|
|
||||||
pep8:
|
testing:pep8:
|
||||||
images:
|
|
||||||
- infra/trusty
|
|
||||||
add:
|
|
||||||
- requirements.txt
|
|
||||||
- test-requirements.txt
|
|
||||||
prep:
|
|
||||||
- pip install -U -r requirements.txt -r test-requirements.txt
|
|
||||||
commands:
|
commands:
|
||||||
- flake8
|
- flake8
|
||||||
|
|
||||||
nulltest:
|
testing:cover:
|
||||||
images:
|
|
||||||
- busybox:latest
|
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
- /bin/echo "hello"
|
- /bin/echo "hello"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import dox.config.base as base
|
import dox.config.base as base
|
||||||
@ -44,25 +45,41 @@ class DoxYaml(base.ConfigBase):
|
|||||||
default_section = 'testing'
|
default_section = 'testing'
|
||||||
default_keys_of_section = ['images', 'commands', 'add', 'prep']
|
default_keys_of_section = ['images', 'commands', 'add', 'prep']
|
||||||
|
|
||||||
def get_section(self, yaml, section):
|
def _parse_parent_child_section(self, section, _yaml):
|
||||||
|
ret = {}
|
||||||
|
if ':' not in section:
|
||||||
|
return _yaml
|
||||||
|
|
||||||
|
parent, child = section.split(':')
|
||||||
|
|
||||||
|
if parent in self._yaml.keys():
|
||||||
|
ret = self._yaml.get(parent)
|
||||||
|
ret.update(_yaml)
|
||||||
|
else:
|
||||||
|
raise DoxYamlSectionNotFound("Parent %s was not found" % parent)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def get_section(self, _yaml, section):
|
||||||
if section == '_default':
|
if section == '_default':
|
||||||
section = self.default_section
|
section = self.default_section
|
||||||
|
|
||||||
# NOTE(chmou): This is for compatibility mode with dox.yml with no
|
# NOTE(chmou): This is for compatibility mode with dox.yml with no
|
||||||
# sections, probably need to be removed in the future
|
# sections, probably need to be removed in the future
|
||||||
if (section is None and
|
if (section is None and
|
||||||
(all(i in yaml.keys() for i in self.default_keys_of_section)
|
(all(i in _yaml.keys() for i in self.default_keys_of_section)
|
||||||
or all(i in self.default_keys_of_section
|
or all(i in self.default_keys_of_section
|
||||||
for i in yaml.keys()))):
|
for i in _yaml.keys()))):
|
||||||
return yaml
|
return _yaml
|
||||||
elif not section:
|
elif not section:
|
||||||
if self.default_section in yaml.keys():
|
if self.default_section in _yaml.keys():
|
||||||
return yaml.get(self.default_section)
|
return self._parse_parent_child_section(
|
||||||
|
self.default_section, _yaml.get(self.default_section))
|
||||||
raise DoxYamlSectionNotFound("You need to specify a section.")
|
raise DoxYamlSectionNotFound("You need to specify a section.")
|
||||||
elif section not in yaml.keys():
|
elif section not in _yaml.keys():
|
||||||
raise DoxYamlSectionNotFound(section)
|
raise DoxYamlSectionNotFound(section)
|
||||||
elif section:
|
|
||||||
return yaml.get(section)
|
return self._parse_parent_child_section(section,
|
||||||
|
_yaml.get(section))
|
||||||
|
|
||||||
def _open_dox_yaml(self):
|
def _open_dox_yaml(self):
|
||||||
if self._yaml is None:
|
if self._yaml is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user