Use a more consistent style for booleans values.
For an optional boolean option, a common idiom was to write: data.get('option-name', 'false') Using a keyword False instead of the string 'false' (resp. True instead of 'true') is deemed clearer, since it conveys that the option is a flag. Such calls are modified to using False/True. The change has been creating using `git grep '.\(false\|true\).)'` to find what needed to change. Change-Id: I54087b5487c7186fcc4ee70ea9b28c1a1002a547
This commit is contained in:
parent
a4a01038cd
commit
627b87f13d
@ -152,10 +152,10 @@ def copyartifact(parser, xml_parent, data):
|
||||
XML.SubElement(selector, 'buildNumber').text = data['build-number']
|
||||
if select == 'last-successful':
|
||||
XML.SubElement(selector, 'stable').text = str(
|
||||
data.get('stable', 'false')).lower()
|
||||
data.get('stable', False)).lower()
|
||||
if select == 'upstream-build':
|
||||
XML.SubElement(selector, 'fallbackToLastSuccessful').text = str(
|
||||
data.get('fallback-to-last-successful', 'false')).lower()
|
||||
data.get('fallback-to-last-successful', False)).lower()
|
||||
if select == 'permalink':
|
||||
XML.SubElement(selector, 'id').text = permalinkdict[permalink]
|
||||
if select == 'build-param':
|
||||
@ -914,19 +914,19 @@ def grails(parser, xml_parent, data):
|
||||
XML.SubElement(grails, 'properties').text = data.get(
|
||||
'properties', '')
|
||||
XML.SubElement(grails, 'forceUpgrade').text = str(
|
||||
data.get('force-upgrade', 'false')).lower()
|
||||
data.get('force-upgrade', False)).lower()
|
||||
XML.SubElement(grails, 'nonInteractive').text = str(
|
||||
data.get('non-interactive', 'false')).lower()
|
||||
data.get('non-interactive', False)).lower()
|
||||
XML.SubElement(grails, 'useWrapper').text = str(
|
||||
data.get('use-wrapper', 'false')).lower()
|
||||
data.get('use-wrapper', False)).lower()
|
||||
XML.SubElement(grails, 'plainOutput').text = str(
|
||||
data.get('plain-output', 'false')).lower()
|
||||
data.get('plain-output', False)).lower()
|
||||
XML.SubElement(grails, 'stackTrace').text = str(
|
||||
data.get('stack-trace', 'false')).lower()
|
||||
data.get('stack-trace', False)).lower()
|
||||
XML.SubElement(grails, 'verbose').text = str(
|
||||
data.get('verbose', 'false')).lower()
|
||||
data.get('verbose', False)).lower()
|
||||
XML.SubElement(grails, 'refreshDependencies').text = str(
|
||||
data.get('refresh-dependencies', 'false')).lower()
|
||||
data.get('refresh-dependencies', False)).lower()
|
||||
|
||||
|
||||
class Builders(jenkins_jobs.modules.base.Base):
|
||||
|
@ -97,7 +97,7 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
'HipChatNotifier_-HipChatJobProperty')
|
||||
XML.SubElement(pdefhip, 'room').text = hipchat['room']
|
||||
XML.SubElement(pdefhip, 'startNotification').text = str(
|
||||
hipchat.get('start-notify', 'false')).lower()
|
||||
hipchat.get('start-notify', False)).lower()
|
||||
|
||||
publishers = xml_parent.find('publishers')
|
||||
if publishers is None:
|
||||
|
@ -106,7 +106,7 @@ def bool_param(parser, xml_parent, data):
|
||||
default: false
|
||||
description: "A parameter named FOO, defaults to 'false'."
|
||||
"""
|
||||
data['default'] = str(data.get('default', 'false')).lower()
|
||||
data['default'] = str(data.get('default', False)).lower()
|
||||
base_param(parser, xml_parent, data, True,
|
||||
'hudson.model.BooleanParameterDefinition')
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Matrix(jenkins_jobs.modules.base.Base):
|
||||
XML.SubElement(root, 'combinationFilter').text = \
|
||||
str(ex_d.get('combination-filter', '')).rstrip()
|
||||
XML.SubElement(ex_r, 'runSequentially').text = \
|
||||
str(ex_d.get('sequential', 'false')).lower()
|
||||
str(ex_d.get('sequential', False)).lower()
|
||||
if 'touchstone' in ex_d:
|
||||
XML.SubElement(ex_r, 'touchStoneCombinationFilter').text = \
|
||||
str(ex_d['touchstone'].get('expr', ''))
|
||||
|
@ -79,7 +79,7 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
XML.SubElement(xml_parent, 'mavenName').text = maven_name
|
||||
|
||||
XML.SubElement(xml_parent, 'ignoreUpstremChanges').text = str(
|
||||
data['maven'].get('ignore-upstream-changes', 'true')).lower()
|
||||
data['maven'].get('ignore-upstream-changes', True)).lower()
|
||||
|
||||
XML.SubElement(xml_parent, 'rootPOM').text = \
|
||||
data['maven'].get('root-pom', 'pom.xml')
|
||||
|
@ -167,13 +167,13 @@ def inject(parser, xml_parent, data):
|
||||
info, 'groovyScriptContent', data.get('groovy-content'))
|
||||
|
||||
XML.SubElement(info, 'loadFilesFromMaster').text = str(
|
||||
data.get('load-from-master', 'false')).lower()
|
||||
data.get('load-from-master', False)).lower()
|
||||
XML.SubElement(inject, 'on').text = str(
|
||||
data.get('enabled', 'true')).lower()
|
||||
data.get('enabled', True)).lower()
|
||||
XML.SubElement(inject, 'keepJenkinsSystemVariables').text = str(
|
||||
data.get('keep-system-variables', 'true')).lower()
|
||||
data.get('keep-system-variables', True)).lower()
|
||||
XML.SubElement(inject, 'keepBuildVariables').text = str(
|
||||
data.get('keep-build-variables', 'true')).lower()
|
||||
data.get('keep-build-variables', True)).lower()
|
||||
|
||||
|
||||
def authenticated_build(parser, xml_parent, data):
|
||||
@ -306,7 +306,7 @@ def extended_choice(parser, xml_parent, data):
|
||||
XML.SubElement(extended, 'name').text = data['name']
|
||||
XML.SubElement(extended, 'description').text = data.get('description', '')
|
||||
XML.SubElement(extended, 'quoteValue').text = str(data.get('quote-value',
|
||||
'false')).lower()
|
||||
False)).lower()
|
||||
XML.SubElement(extended, 'visibleItemCount').text = data.get(
|
||||
'visible-items', '5')
|
||||
choice = data.get('type', 'single-select')
|
||||
|
@ -348,19 +348,19 @@ def cobertura(parser, xml_parent, data):
|
||||
XML.SubElement(cobertura, 'coberturaReportFile').text = data.get(
|
||||
'report-file', '**/coverage.xml')
|
||||
XML.SubElement(cobertura, 'onlyStable').text = str(
|
||||
data.get('only-stable', 'false')).lower()
|
||||
data.get('only-stable', False)).lower()
|
||||
XML.SubElement(cobertura, 'failUnhealthy').text = str(
|
||||
data.get('fail-unhealthy', 'false')).lower()
|
||||
data.get('fail-unhealthy', False)).lower()
|
||||
XML.SubElement(cobertura, 'failUnstable').text = str(
|
||||
data.get('fail-unstable', 'false')).lower()
|
||||
data.get('fail-unstable', False)).lower()
|
||||
XML.SubElement(cobertura, 'autoUpdateHealth').text = str(
|
||||
data.get('health-auto-update', 'false')).lower()
|
||||
data.get('health-auto-update', False)).lower()
|
||||
XML.SubElement(cobertura, 'autoUpdateStability').text = str(
|
||||
data.get('stability-auto-update', 'false')).lower()
|
||||
data.get('stability-auto-update', False)).lower()
|
||||
XML.SubElement(cobertura, 'zoomCoverageChart').text = str(
|
||||
data.get('zoom-coverage-chart', 'false')).lower()
|
||||
data.get('zoom-coverage-chart', False)).lower()
|
||||
XML.SubElement(cobertura, 'failNoReports').text = str(
|
||||
data.get('fail-no-reports', 'false')).lower()
|
||||
data.get('fail-no-reports', False)).lower()
|
||||
healthy = XML.SubElement(cobertura, 'healthyTarget')
|
||||
targets = XML.SubElement(healthy, 'targets', {
|
||||
'class': 'enum-map',
|
||||
@ -567,13 +567,13 @@ def xunit(parser, xml_parent, data):
|
||||
supported_type[framework_name].get('pattern', '')
|
||||
XML.SubElement(xmlframework, 'failIfNotNew').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'requireupdate', 'true')).lower()
|
||||
'requireupdate', True)).lower()
|
||||
XML.SubElement(xmlframework, 'deleteOutputFiles').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'deleteoutput', 'true')).lower()
|
||||
'deleteoutput', True)).lower()
|
||||
XML.SubElement(xmlframework, 'stopProcessingIfError').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'stoponerror', 'true')).lower()
|
||||
'stoponerror', True)).lower()
|
||||
|
||||
xmlthresholds = XML.SubElement(xunit, 'thresholds')
|
||||
if 'thresholds' in data:
|
||||
@ -1189,7 +1189,7 @@ def cppcheck(parser, xml_parent, data):
|
||||
cppext = XML.SubElement(cppextbase, 'cppcheckConfig')
|
||||
XML.SubElement(cppext, 'pattern').text = data['pattern']
|
||||
XML.SubElement(cppext, 'ignoreBlankFiles').text = \
|
||||
str(data.get('ignoreblankfiles', 'false')).lower()
|
||||
str(data.get('ignoreblankfiles', False)).lower()
|
||||
|
||||
csev = XML.SubElement(cppext, 'configSeverityEvaluation')
|
||||
thrsh = data.get('thresholds', {})
|
||||
@ -1205,15 +1205,15 @@ def cppcheck(parser, xml_parent, data):
|
||||
|
||||
sev = thrsh.get('severity', {})
|
||||
XML.SubElement(csev, 'severityError').text = \
|
||||
str(sev.get('error', 'true')).lower()
|
||||
str(sev.get('error', True)).lower()
|
||||
XML.SubElement(csev, 'severityWarning').text = \
|
||||
str(sev.get('warning', 'true')).lower()
|
||||
str(sev.get('warning', True)).lower()
|
||||
XML.SubElement(csev, 'severityStyle').text = \
|
||||
str(sev.get('style', 'true')).lower()
|
||||
str(sev.get('style', True)).lower()
|
||||
XML.SubElement(csev, 'severityPerformance').text = \
|
||||
str(sev.get('performance', 'true')).lower()
|
||||
str(sev.get('performance', True)).lower()
|
||||
XML.SubElement(csev, 'severityInformation').text = \
|
||||
str(sev.get('information', 'true')).lower()
|
||||
str(sev.get('information', True)).lower()
|
||||
|
||||
graph = data.get('graph', {})
|
||||
cgraph = XML.SubElement(cppext, 'configGraph')
|
||||
@ -1222,17 +1222,17 @@ def cppcheck(parser, xml_parent, data):
|
||||
XML.SubElement(cgraph, 'ySize').text = str(y)
|
||||
gdisplay = graph.get('display', {})
|
||||
XML.SubElement(cgraph, 'displayAllErrors').text = \
|
||||
str(gdisplay.get('sum', 'true')).lower()
|
||||
str(gdisplay.get('sum', True)).lower()
|
||||
XML.SubElement(cgraph, 'displayErrorSeverity').text = \
|
||||
str(gdisplay.get('error', 'false')).lower()
|
||||
str(gdisplay.get('error', False)).lower()
|
||||
XML.SubElement(cgraph, 'displayWarningSeverity').text = \
|
||||
str(gdisplay.get('warning', 'false')).lower()
|
||||
str(gdisplay.get('warning', False)).lower()
|
||||
XML.SubElement(cgraph, 'displayStyleSeverity').text = \
|
||||
str(gdisplay.get('style', 'false')).lower()
|
||||
str(gdisplay.get('style', False)).lower()
|
||||
XML.SubElement(cgraph, 'displayPerformanceSeverity').text = \
|
||||
str(gdisplay.get('performance', 'false')).lower()
|
||||
str(gdisplay.get('performance', False)).lower()
|
||||
XML.SubElement(cgraph, 'displayInformationSeverity').text = \
|
||||
str(gdisplay.get('information', 'false')).lower()
|
||||
str(gdisplay.get('information', False)).lower()
|
||||
|
||||
|
||||
def logparser(parser, xml_parent, data):
|
||||
@ -1255,9 +1255,9 @@ def logparser(parser, xml_parent, data):
|
||||
clog = XML.SubElement(xml_parent,
|
||||
'hudson.plugins.logparser.LogParserPublisher')
|
||||
XML.SubElement(clog, 'unstableOnWarning').text = \
|
||||
str(data.get('unstable-on-warning', 'false')).lower()
|
||||
str(data.get('unstable-on-warning', False)).lower()
|
||||
XML.SubElement(clog, 'failBuildOnError').text = \
|
||||
str(data.get('fail-on-error', 'false')).lower()
|
||||
str(data.get('fail-on-error', False)).lower()
|
||||
# v1.08: this must be the full path, the name of the rules is not enough
|
||||
XML.SubElement(clog, 'parsingRulesPath').text = data.get('parse-rules', '')
|
||||
|
||||
@ -1643,15 +1643,15 @@ def jabber(parser, xml_parent, data):
|
||||
"all, failure, failure-fixed, or change")
|
||||
XML.SubElement(j, 'strategy').text = strategydict[strategy]
|
||||
XML.SubElement(j, 'notifyOnBuildStart').text = str(
|
||||
data.get('notify-on-build-start', 'false')).lower()
|
||||
data.get('notify-on-build-start', False)).lower()
|
||||
XML.SubElement(j, 'notifySuspects').text = str(
|
||||
data.get('notify-scm-committers', 'false')).lower()
|
||||
data.get('notify-scm-committers', False)).lower()
|
||||
XML.SubElement(j, 'notifyCulprits').text = str(
|
||||
data.get('notify-scm-culprits', 'false')).lower()
|
||||
data.get('notify-scm-culprits', False)).lower()
|
||||
XML.SubElement(j, 'notifyFixers').text = str(
|
||||
data.get('notify-scm-fixers', 'false')).lower()
|
||||
data.get('notify-scm-fixers', False)).lower()
|
||||
XML.SubElement(j, 'notifyUpstreamCommitters').text = str(
|
||||
data.get('notify-upstream-committers', 'false')).lower()
|
||||
data.get('notify-upstream-committers', False)).lower()
|
||||
message = data.get('message', 'summary-scm')
|
||||
messagedict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
||||
'summary': 'SummaryOnlyBuildToChatNotifier',
|
||||
@ -1716,9 +1716,9 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
XML.SubElement(ptrn, 'type').text = "EXCLUDE"
|
||||
|
||||
XML.SubElement(p, 'deleteDirs').text = \
|
||||
str(data.get("dirmatch", "false")).lower()
|
||||
str(data.get("dirmatch", False)).lower()
|
||||
XML.SubElement(p, 'cleanupMatrixParent').text = \
|
||||
str(data.get("clean-parent", "false")).lower()
|
||||
str(data.get("clean-parent", False)).lower()
|
||||
|
||||
mask = {'success': 'cleanWhenSuccess', 'unstable': 'cleanWhenUnstable',
|
||||
'failure': 'cleanWhenFailure', 'not-built': 'cleanWhenNotBuilt',
|
||||
@ -1733,7 +1733,7 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
if len(cdict) > 0:
|
||||
raise ValueError('clean-if must be one of: %r' % list(mask.keys()))
|
||||
|
||||
if str(data.get("fail-build", "false")).lower() == 'false':
|
||||
if str(data.get("fail-build", False)).lower() == 'false':
|
||||
XML.SubElement(p, 'notFailBuild').text = 'true'
|
||||
else:
|
||||
XML.SubElement(p, 'notFailBuild').text = 'false'
|
||||
@ -1765,9 +1765,9 @@ def maven_deploy(parser, xml_parent, data):
|
||||
XML.SubElement(p, 'id').text = data['id']
|
||||
XML.SubElement(p, 'url').text = data['url']
|
||||
XML.SubElement(p, 'uniqueVersion').text = str(
|
||||
data.get('unique-version', 'true')).lower()
|
||||
data.get('unique-version', True)).lower()
|
||||
XML.SubElement(p, 'evenIfUnstable').text = str(
|
||||
data.get('deploy-unstable', 'false')).lower()
|
||||
data.get('deploy-unstable', False)).lower()
|
||||
|
||||
|
||||
def text_finder(parser, xml_parent, data):
|
||||
@ -1804,11 +1804,11 @@ def text_finder(parser, xml_parent, data):
|
||||
if ('fileset' in data):
|
||||
XML.SubElement(finder, 'fileSet').text = data['fileset']
|
||||
XML.SubElement(finder, 'regexp').text = data['regexp']
|
||||
check_output = str(data.get('also-check-console-output', 'false')).lower()
|
||||
check_output = str(data.get('also-check-console-output', False)).lower()
|
||||
XML.SubElement(finder, 'alsoCheckConsoleOutput').text = check_output
|
||||
succeed_if_found = str(data.get('succeed-if-found', 'false')).lower()
|
||||
succeed_if_found = str(data.get('succeed-if-found', False)).lower()
|
||||
XML.SubElement(finder, 'succeedIfFound').text = succeed_if_found
|
||||
unstable_if_found = str(data.get('unstable-if-found', 'false')).lower()
|
||||
unstable_if_found = str(data.get('unstable-if-found', False)).lower()
|
||||
XML.SubElement(finder, 'unstableIfFound').text = unstable_if_found
|
||||
|
||||
|
||||
@ -1841,7 +1841,7 @@ def html_publisher(parser, xml_parent, data):
|
||||
XML.SubElement(ptarget, 'reportName').text = data['name']
|
||||
XML.SubElement(ptarget, 'reportDir').text = data['dir']
|
||||
XML.SubElement(ptarget, 'reportFiles').text = data['files']
|
||||
keep_all = str(data.get('keep-all', 'false')).lower()
|
||||
keep_all = str(data.get('keep-all', False)).lower()
|
||||
XML.SubElement(ptarget, 'keepAll').text = keep_all
|
||||
XML.SubElement(ptarget, 'wrapperName').text = "htmlpublisher-wrapper.html"
|
||||
|
||||
|
@ -389,7 +389,7 @@ def tfs(self, xml_parent, data):
|
||||
XML.SubElement(tfs, 'userName').text = str(
|
||||
data.get('login', ''))
|
||||
XML.SubElement(tfs, 'useUpdate').text = str(
|
||||
data.get('use-update', 'true'))
|
||||
data.get('use-update', True))
|
||||
store = data.get('web-access', None)
|
||||
if 'web-access' in data and isinstance(store, list):
|
||||
web = XML.SubElement(tfs, 'repositoryBrowser', {'class': 'hudson.'
|
||||
|
@ -161,7 +161,7 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
XML.SubElement(ptrn, 'type').text = "EXCLUDE"
|
||||
|
||||
deldirs = XML.SubElement(p, 'deleteDirs')
|
||||
deldirs.text = str(data.get("dirmatch", "false")).lower()
|
||||
deldirs.text = str(data.get("dirmatch", False)).lower()
|
||||
|
||||
|
||||
def rvm_env(parser, xml_parent, data):
|
||||
@ -306,9 +306,9 @@ def copy_to_slave(parser, xml_parent, data):
|
||||
XML.SubElement(cs, 'includes').text = ','.join(data.get('includes', ['']))
|
||||
XML.SubElement(cs, 'excludes').text = ','.join(data.get('excludes', ['']))
|
||||
XML.SubElement(cs, 'flatten').text = \
|
||||
str(data.get('flatten', 'false')).lower()
|
||||
str(data.get('flatten', False)).lower()
|
||||
XML.SubElement(cs, 'includeAntExcludes').text = \
|
||||
str(data.get('include-ant-excludes', 'false')).lower()
|
||||
str(data.get('include-ant-excludes', False)).lower()
|
||||
|
||||
rel = str(data.get('relative-to', 'userContent'))
|
||||
opt = ('userContent', 'home', 'workspace')
|
||||
@ -478,11 +478,11 @@ def release(parser, xml_parent, data):
|
||||
# For 'keep-forever', the sense of the XML flag is the opposite of
|
||||
# the YAML flag.
|
||||
no_keep_forever = 'false'
|
||||
if str(data.get('keep-forever', 'true')).lower() == 'false':
|
||||
if str(data.get('keep-forever', True)).lower() == 'false':
|
||||
no_keep_forever = 'true'
|
||||
XML.SubElement(relwrap, 'doNotKeepLog').text = no_keep_forever
|
||||
XML.SubElement(relwrap, 'overrideBuildParameters').text = str(
|
||||
data.get('override-build-parameters', 'false')).lower()
|
||||
data.get('override-build-parameters', False)).lower()
|
||||
XML.SubElement(relwrap, 'releaseVersionTemplate').text = data.get(
|
||||
'version-template', '')
|
||||
for param in data.get('parameters', []):
|
||||
|
Loading…
Reference in New Issue
Block a user