update adml text search to use 'starts-with' as some policies text has trailing spaces (#39090)

This commit is contained in:
lomeroe 2017-02-01 16:43:01 -06:00 committed by Nicole Thomas
parent 9dccb9fbe3
commit 8a00ecfb79

View file

@ -104,7 +104,7 @@ try:
VALUE_LIST_XPATH = etree.XPath('.//*[local-name() = "valueList"]')
ENUM_ITEM_DISPLAY_NAME_XPATH = etree.XPath('.//*[local-name() = "item" and @*[local-name() = "displayName" = $display_name]]')
ADMX_SEARCH_XPATH = etree.XPath('//*[local-name() = "policy" and @*[local-name() = "name"] = $policy_name and (@*[local-name() = "class"] = "Both" or @*[local-name() = "class"] = $registry_class)]')
ADML_SEARCH_XPATH = etree.XPath('//*[text() = $policy_name and @*[local-name() = "id"]]')
ADML_SEARCH_XPATH = etree.XPath('//*[starts-with(text(), $policy_name) and @*[local-name() = "id"]]')
ADMX_DISPLAYNAME_SEARCH_XPATH = etree.XPath('//*[local-name() = "policy" and @*[local-name() = "displayName"] = $display_name and (@*[local-name() = "class"] = "Both" or @*[local-name() = "class"] = $registry_class) ]')
PRESENTATION_ANCESTOR_XPATH = etree.XPath('ancestor::*[local-name() = "presentation"]')
TEXT_ELEMENT_XPATH = etree.XPath('.//*[local-name() = "text"]')
@ -3857,6 +3857,9 @@ def _lookup_admin_template(policy_name,
suggested_policies = ''
if len(adml_search_results) > 1:
multiple_adml_entries = True
for adml_search_result in adml_search_results:
if not adml_search_result.attrib['text'].strip() == policy_name:
adml_search_results.remove(adml_search_result)
for adml_search_result in adml_search_results:
dmsg = 'found an adml entry matching the string! {0} -- {1}'
log.debug(dmsg.format(adml_search_result.tag,