correct create list item value names

if the valuePrefix attribute does not exist on the list item, the value
is the value name, other wise, the valuename a number with the
valuePrefix prepended to it

fixes #46627

needs to be backported to 2016.11 as well
This commit is contained in:
lomeroe 2018-03-31 09:58:37 -05:00
parent 395b7f8fdc
commit 2bee383e9d

View file

@ -3439,7 +3439,7 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
element_valuenames = []
element_values = this_element_value
if this_element_value is not None:
element_valuenames = list(range(1, len(this_element_value) + 1))
element_valuenames = list([str(z) for z in range(1, len(this_element_value) + 1)])
if 'additive' in element.attrib:
if element.attrib['additive'].lower() == 'false':
# a delete values will be added before all the other
@ -3464,11 +3464,18 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
if this_element_value is not None:
element_valuenames = this_element_value.keys()
element_values = this_element_value.values()
if 'valuePrefix' in element.attrib and element.attrib['valuePrefix'] != '':
if this_element_value is not None:
element_valuenames = ['{0}{1}'.format(element.attrib['valuePrefix'],
k) for k in element_valuenames]
if 'valuePrefix' in element.attrib:
# if the valuePrefix attribute exists, the valuenames are <prefix><number>
# most prefixes attributes are empty in the admx files, so the valuenames
# end up being just numbers
if element.attrib['valuePrefix'] != '':
if this_element_value is not None:
element_valuenames = ['{0}{1}'.format(element.attrib['valuePrefix'],
k) for k in element_valuenames]
else:
# if there is no valuePrefix attribute, the valuename is the value
if element_values is not None:
element_valuenames = [str(z) for z in element_values]
if not check_deleted:
if this_element_value is not None:
log.debug('_processValueItem has an explicit element_value of {0}'.format(this_element_value))