Remove YamlParser references from JJB modules.

Change-Id: Ia9ca686c4040fd27890dbce99fda3db3e99a1102
This commit is contained in:
Wayne Warren 2016-01-02 16:11:21 -08:00
parent 4350690b61
commit f9b3c4e6a7
3 changed files with 13 additions and 10 deletions

View File

@ -57,14 +57,16 @@ class Base(object):
def __init__(self, registry):
self.registry = registry
def handle_data(self, parser):
def handle_data(self, job_data):
"""This method is called before any XML is generated. By
overriding this method, the module may manipulate the YAML
data structure on the parser however it likes before any XML
is generated. If it has changed the data structure at all, it
must return ``True``, otherwise, it must return ``False``.
overriding this method, a module may arbitrarily modify a data
structure which will probably be the JJB YamlParser's intermediate data
representation. If it has changed the data structure at all, it must
return ``True``, otherwise, it must return ``False``.
:arg YAMLParser parser: the global YAML Parser
:arg dict job_data: the intermediate representation of job data
loaded from JJB Yaml files without variables interpolation or other
yaml expansions.
:rtype: boolean
"""

View File

@ -135,10 +135,11 @@ ZUUL_POST_PARAMETERS = [
class Zuul(jenkins_jobs.modules.base.Base):
sequence = 0
def handle_data(self, parser):
def handle_data(self, job_data):
changed = False
jobs = itertools.chain(parser.data.get('job', {}).values(),
parser.data.get('job-template', {}).values())
jobs = itertools.chain(
job_data.get('job', {}).values(),
job_data.get('job-template', {}).values())
for job in jobs:
triggers = job.get('triggers')
if not triggers:

View File

@ -226,7 +226,7 @@ class YamlParser(object):
changed = False
for module in self.registry.modules:
if hasattr(module, 'handle_data'):
if module.handle_data(self):
if module.handle_data(self.data):
changed = True
for job in self.data.get('job', {}).values():