@@ -31,49 +31,34 @@ def is_str(string):
31
31
return isinstance (string , basestring )
32
32
33
33
34
- def find_xml_generator (name = None ):
34
+ def find_xml_generator (name = "castxml" ):
35
35
"""
36
- Try to find a c++ parser. Returns path and name.
36
+ Try to find a c++ parser (xml generator)
37
37
38
- :param name: name of the c++ parser: castxml or gccxml
39
- :type name: str
38
+ Args:
39
+ name (str): name of the c++ parser (e.g. castxml)
40
+
41
+ Returns:
42
+ path (str), name (str): path to the xml generator and it's name
40
43
41
- If no name is given the function first looks for castxml,
42
- then for gccxml. If no c++ parser is found the function
43
- raises an exception .
44
+
45
+ If no c++ parser is found the function raises an exception.
46
+ pygccxml does currently only support castxml as c++ parser .
44
47
45
48
"""
46
49
if platform .system () == "Windows" :
47
50
command = "where"
48
51
else :
49
52
command = "which"
50
53
51
- if name is None :
52
- name = "castxml"
53
- p = subprocess .Popen ([command , name ], stdout = subprocess .PIPE ,
54
- stderr = subprocess .PIPE )
55
- path = p .stdout .read ().decode ("utf-8" )
56
- p .wait ()
57
- p .stdout .close ()
58
- p .stderr .close ()
59
- if path == "" :
60
- name = "gccxml"
61
- p = subprocess .Popen ([command , name ], stdout = subprocess .PIPE ,
62
- stderr = subprocess .PIPE )
63
- path = p .stdout .read ().decode ("utf-8" )
64
- p .wait ()
65
- p .stdout .close ()
66
- p .stderr .close ()
67
- else :
68
- p = subprocess .Popen ([command , name ], stdout = subprocess .PIPE ,
69
- stderr = subprocess .PIPE )
70
- path = p .stdout .read ().decode ("utf-8" )
71
- p .wait ()
72
- p .stdout .close ()
73
- p .stderr .close ()
54
+ p = subprocess .Popen ([command , name ], stdout = subprocess .PIPE ,
55
+ stderr = subprocess .PIPE )
56
+ path = p .stdout .read ().decode ("utf-8" )
57
+ p .wait ()
58
+ p .stdout .close ()
59
+ p .stderr .close ()
74
60
if path == "" :
75
- raise (Exception (
76
- "No c++ parser found. Please install castxml or gccxml." ))
61
+ raise (Exception ("No c++ parser found. Please install castxml." ))
77
62
else :
78
63
return path .rstrip (), name
79
64
0 commit comments