Skip to content

Commit 64034fa

Browse files
committed
clean-up
1 parent f3649d1 commit 64034fa

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/ogdf_python/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
cppyy.load_library("libOGDF.so")
3030

31-
import ogdf_python.pythonize
3231
import ogdf_python.doxygen
32+
import ogdf_python.pythonize
3333
from cppyy.gbl import ogdf
3434

3535
__all__ = ["ogdf", "cppinclude", "cppdef", "nullptr"]

src/ogdf_python/doxygen.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from collections import defaultdict
44

55

6+
# doxygen XML parsing #################################################################################################
7+
8+
69
def parse_index_xml():
710
root = etree.parse(os.path.join(DOXYGEN_XML_DIR, 'index.xml'))
811
compounds = defaultdict(dict)
@@ -35,6 +38,26 @@ def parse_index_xml():
3538
return compounds
3639

3740

41+
def find_all_includes():
42+
for ctype in ("class", "struct", "namespace"):
43+
for compound in DOXYGEN_DATA[ctype].values():
44+
compound_xml = etree.parse(os.path.join(DOXYGEN_XML_DIR, compound["refid"] + '.xml'))
45+
for location in compound_xml.findall(".//*[@id]/location"):
46+
parent = location.getparent()
47+
if parent.get("id") == compound["refid"]:
48+
member = compound
49+
else:
50+
name = parent.find("name")
51+
if name.text not in compound["members"]:
52+
print("got location for unknown object", compound["refid"], parent.get("id"), name.text)
53+
continue
54+
else:
55+
member = compound["members"][name.text][parent.get("id")]
56+
member["file"] = location.get("declfile", location.get("file"))
57+
58+
59+
# doc strings / help messages##########################################################################################
60+
3861
def pythonize_docstrings(klass, name):
3962
data = DOXYGEN_DATA["class"][klass.__cpp_name__] # TODO do the same for namespace members
4063
url = DOXYGEN_URL % (data["refid"], "")
@@ -61,23 +84,7 @@ def pythonize_docstrings(klass, name):
6184
pass
6285

6386

64-
def find_all_includes():
65-
for ctype in ("class", "struct", "namespace"):
66-
for compound in DOXYGEN_DATA[ctype].values():
67-
compound_xml = etree.parse(os.path.join(DOXYGEN_XML_DIR, compound["refid"] + '.xml'))
68-
for location in compound_xml.findall(".//*[@id]/location"):
69-
parent = location.getparent()
70-
if parent.get("id") == compound["refid"]:
71-
member = compound
72-
else:
73-
name = parent.find("name")
74-
if name.text not in compound["members"]:
75-
print("got location for unknown object", compound["refid"], parent.get("id"), name.text)
76-
continue
77-
else:
78-
member = compound["members"][name.text][parent.get("id")]
79-
member["file"] = location.get("declfile", location.get("file"))
80-
87+
# helpful "attribute not found" errors ################################################################################
8188

8289
def find_include(*names):
8390
if len(names) == 1:
@@ -141,6 +148,8 @@ def helpful_getattribute(ns, name):
141148
type(ns).__getattribute__ = helpful_getattribute
142149

143150

151+
# __main__ and imported use ###########################################################################################
152+
144153
if "OGDF_DOC_DIR" in os.environ:
145154
from lxml import etree
146155

src/ogdf_python/pythonize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def replace_GraphAttributes(klass, name):
126126

127127

128128
generate_GA_setters()
129+
# TODO use pythonization for this so that classes are loaded lazily
129130
replace_GraphAttributes(cppyy.gbl.ogdf.GraphAttributes, "GraphAttributes")
130131
replace_GraphAttributes(cppyy.gbl.ogdf.ClusterGraphAttributes, "ClusterGraphAttributes")
131-
132132
cppyy.gbl.ogdf.Graph._repr_html_ = GraphAttributes_to_html # TODO layout
133133
cppyy.gbl.ogdf.ClusterGraph._repr_html_ = GraphAttributes_to_html
134134

0 commit comments

Comments
 (0)