Skip to content

Commit b60b0f2

Browse files
committed
Defer formatting for various debug messages
1 parent e7789a6 commit b60b0f2

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def debug_print(fmt, *args):
123123
if debug_trace:
124124

125125
def trace_print(*args):
126-
sys.stdout.write("[%s] " % (inspect.currentframe().f_back.f_lineno))
126+
sys.stdout.write("[%s]" % (inspect.currentframe().f_back.f_lineno))
127127
for a in args:
128-
sys.stdout.write("%s " % a)
128+
sys.stdout.write(" %s" % a)
129129
sys.stdout.write("\n")
130130

131131

@@ -729,7 +729,7 @@ def __init__(self, nameStack, curTemplate, doxygen, location, defaultAccess):
729729

730730
if curTemplate:
731731
self["template"] = curTemplate
732-
trace_print("Setting template to '%s'" % self["template"])
732+
trace_print("Setting template to", self["template"])
733733

734734
methodAccessSpecificList = {}
735735
propertyAccessSpecificList = {}
@@ -1865,7 +1865,6 @@ def finalize_vars(self):
18651865
else:
18661866
trace_print("WARN-this should almost never happen!")
18671867
trace_print(var)
1868-
trace_print("-" * 80)
18691868
var["unresolved"] = True
18701869

18711870
elif tag in self._template_typenames:
@@ -1950,23 +1949,23 @@ def finalize_vars(self):
19501949
# var['raw_type'] = var['raw_type'][2:]
19511950

19521951
# Take care of #defines and #pragmas etc
1953-
trace_print("Processing precomp_macro_buf: %s" % self._precomp_macro_buf)
1952+
trace_print("Processing precomp_macro_buf:", self._precomp_macro_buf)
19541953
for m, location in self._precomp_macro_buf:
19551954
macro = m.replace("<CppHeaderParser_newline_temp_replacement>\\n", "\n")
19561955
ml = macro.lower()
19571956
try:
19581957
if ml.startswith("#define"):
1959-
trace_print("Adding #define %s" % macro)
1958+
trace_print("Adding #define", macro)
19601959
define = CppDefine(macro, location)
19611960
self.defines.append(define["value"])
19621961
self.defines_detail.append(define)
19631962
elif ml.startswith("#pragma"):
1964-
trace_print("Adding #pragma %s" % macro)
1963+
trace_print("Adding #pragma", macro)
19651964
pragma = CppPragma(macro, location)
19661965
self.pragmas_detail.append(pragma)
19671966
self.pragmas.append(pragma["value"])
19681967
elif ml.startswith("#include"):
1969-
trace_print("Adding #include %s" % macro)
1968+
trace_print("Adding #include", macro)
19701969
include = CppInclude(macro, location)
19711970
self.includes.append(include["value"])
19721971
self.includes_detail.append(include)
@@ -2455,8 +2454,9 @@ def _evaluate_property_stack(self, clearStack=True, addToVar=None):
24552454
# Is it really a list of variables?
24562455
if leftMostComma != 0:
24572456
trace_print(
2458-
"Multiple variables for namestack in %s. Separating processing"
2459-
% self.nameStack
2457+
"Multiple variables for namestack in",
2458+
self.nameStack,
2459+
". Separating processing",
24602460
)
24612461
orig_nameStack = self.nameStack[:]
24622462

@@ -2580,7 +2580,6 @@ def _evaluate_class_stack(self):
25802580
if key in self.classes:
25812581
trace_print("ERROR name collision:", key)
25822582
self.classes[key].show()
2583-
trace_print("-" * 80)
25842583
newClass.show()
25852584
assert key not in self.classes # namespace collision
25862585
self.classes[key] = newClass
@@ -3290,7 +3289,7 @@ def _evaluate_stack(self, token=None):
32903289
)
32913290
):
32923291
debug_print("trace")
3293-
trace_print("typedef %s", self.stack)
3292+
trace_print("typedef", self.stack)
32943293
self._evaluate_typedef()
32953294
return
32963295

@@ -3407,7 +3406,7 @@ def _evaluate_stack(self, token=None):
34073406
elif self.braceDepth > len(self.nameSpaces) + 1:
34083407
debug_print("trace")
34093408
else:
3410-
debug_print("Discarded statement %s" % (self.nameStack,))
3409+
debug_print("Discarded statement %s", self.nameStack)
34113410

34123411
try:
34133412
self.nameStackHistory[self.braceDepth] = (nameStackCopy, self.curClass)
@@ -3643,35 +3642,35 @@ def _strip_parent_keys(self):
36433642
obj_queue = [self]
36443643
while len(obj_queue):
36453644
obj = obj_queue.pop()
3646-
trace_print("pop %s type %s" % (obj, type(obj)))
3645+
trace_print("pop", obj, "type", type(obj))
36473646
try:
36483647
if "parent" in obj.keys():
36493648
del obj["parent"]
3650-
trace_print("Stripped parent from %s" % obj.keys())
3649+
trace_print("Stripped parent from", obj.keys())
36513650
except:
36523651
pass
36533652
try:
36543653
if "method" in obj.keys():
36553654
del obj["method"]
3656-
trace_print("Stripped method from %s" % obj.keys())
3655+
trace_print("Stripped method from", obj.keys())
36573656
except:
36583657
pass
36593658
# Figure out what sub types are one of ours
36603659
try:
36613660
if not hasattr(obj, "keys"):
36623661
obj = obj.__dict__
36633662
for k in obj.keys():
3664-
trace_print("-Try key %s" % (k))
3665-
trace_print("-type %s" % (type(obj[k])))
3663+
trace_print("-Try key", k)
3664+
trace_print("-type", type(obj[k]))
36663665
if k in ["nameStackHistory", "parent", "_public_typedefs"]:
36673666
continue
36683667
if type(obj[k]) == list:
36693668
for i in obj[k]:
3670-
trace_print("push l %s" % i)
3669+
trace_print("push l", i)
36713670
obj_queue.append(i)
36723671
elif type(obj[k]) == dict:
36733672
if len(obj):
3674-
trace_print("push d %s" % obj[k])
3673+
trace_print("push d", obj[k])
36753674
obj_queue.append(obj[k])
36763675
elif type(obj[k]) == type(type(0)):
36773676
if type(obj[k]) == int:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy