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

Function read_msbuild_xml

Source/cmConvertMSBuildXMLToJSON.py:38–78  ·  view source on GitHub ↗

Reads the MS Build XML file at the path and returns its contents. Keyword arguments: values -- The map to append the contents to (default {})

(path, values=None)

Source from the content-addressed store, hash-verified

36
37
38def read_msbuild_xml(path, values=None):
39 """Reads the MS Build XML file at the path and returns its contents.
40
41 Keyword arguments:
42 values -- The map to append the contents to (default {})
43 """
44 if values is None:
45 values = {}
46
47 # Attempt to read the file contents
48 try:
49 document = parse(path)
50 except Exception as e:
51 logging.exception('Could not read MS Build XML file at %s', path)
52 return values
53
54 # Convert the XML to JSON format
55 logging.info('Processing MS Build XML file at %s', path)
56
57 # Get the rule node
58 rule = document.getElementsByTagName('Rule')[0]
59
60 rule_name = rule.attributes['Name'].value
61
62 logging.info('Found rules for %s', rule_name)
63
64 # Proprocess Argument values
65 __preprocess_arguments(rule)
66
67 # Get all the values
68 converted_values = []
69 __convert(rule, 'EnumProperty', converted_values, __convert_enum)
70 __convert(rule, 'BoolProperty', converted_values, __convert_bool)
71 __convert(rule, 'StringListProperty', converted_values,
72 __convert_string_list)
73 __convert(rule, 'StringProperty', converted_values, __convert_string)
74 __convert(rule, 'IntProperty', converted_values, __convert_string)
75
76 values[rule_name] = converted_values
77
78 return values
79
80
81def read_msbuild_json(path, values=None):

Callers 1

mainFunction · 0.85

Calls 2

__preprocess_argumentsFunction · 0.85
__convertFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…