MCPcopy Create free account
hub / github.com/Kitware/CMake / __preprocess_arguments

Function __preprocess_arguments

Source/cmConvertMSBuildXMLToJSON.py:363–405  ·  view source on GitHub ↗

Preprocesses occurrences of Argument within the root. Argument XML values reference other values within the document by name. The referenced value does not contain a switch. This function will add the switch associated with the argument.

(root)

Source from the content-addressed store, hash-verified

361
362
363def __preprocess_arguments(root):
364 """Preprocesses occurrences of Argument within the root.
365
366 Argument XML values reference other values within the document by name. The
367 referenced value does not contain a switch. This function will add the
368 switch associated with the argument.
369 """
370 # Set the flags to require a value
371 flags = ','.join(vsflags(VSFlags.UserValueRequired))
372
373 # Search through the arguments
374 arguments = root.getElementsByTagName('Argument')
375
376 for argument in arguments:
377 reference = __get_attribute(argument, 'Property')
378 found = None
379
380 # Look for the argument within the root's children
381 for child in root.childNodes:
382 # Ignore Text nodes
383 if isinstance(child, Element):
384 name = __get_attribute(child, 'Name')
385
386 if name == reference:
387 found = child
388 break
389
390 if found is not None:
391 logging.info('Found property named %s', reference)
392 # Get the associated switch
393 switch = __get_attribute(argument.parentNode, 'Switch')
394
395 # See if there is already a switch associated with the element.
396 if __get_attribute(found, 'Switch'):
397 logging.debug('Copying node %s', reference)
398 clone = found.cloneNode(True)
399 root.insertBefore(clone, found)
400 found = clone
401
402 found.setAttribute('Switch', switch)
403 found.setAttribute('Flags', flags)
404 else:
405 logging.warning('Could not find property named %s', reference)
406
407
408def __get_attribute(node, name, default_value=''):

Callers 1

read_msbuild_xmlFunction · 0.85

Calls 3

vsflagsFunction · 0.85
__get_attributeFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…