jiridanek commented on a change in pull request #285:
URL: https://github.com/apache/qpid-proton/pull/285#discussion_r557570245
##########
File path: tools/python/mllib/dom.py
##########
@@ -32,285 +32,308 @@
else:
STRING_TYPES = (str,)
+
class Container:
- def __init__(self):
- self.children = []
+ def __init__(self):
+ self.children = []
+
+ def add(self, child):
+ child.parent = self
+ self.children.append(child)
- def add(self, child):
- child.parent = self
- self.children.append(child)
+ def extend(self, children):
+ for child in children:
+ child.parent = self
+ self.children.append(child)
- def extend(self, children):
- for child in children:
- child.parent = self
- self.children.append(child)
class Component:
- def __init__(self):
- self.parent = None
+ def __init__(self):
+ self.parent = None
- def index(self):
- if self.parent:
- return self.parent.children.index(self)
- else:
- return 0
+ def index(self):
+ if self.parent:
+ return self.parent.children.index(self)
+ else:
+ return 0
+
+ def _line(self, file, line, column):
+ self.file = file
+ self.line = line
+ self.column = column
- def _line(self, file, line, column):
- self.file = file
- self.line = line
- self.column = column
class DispatchError(Exception):
- def __init__(self, scope, f):
- msg = "no such attribute"
+ def __init__(self, scope, f):
+ msg = "no such attribute"
+
class Dispatcher:
- def is_type(self, type):
- cls = self
- while cls != None:
- if cls.type == type:
- return True
- cls = cls.base
- return False
-
- def dispatch(self, f, attrs = ""):
- cls = self
- while cls != None:
- if hasattr(f, cls.type):
- return getattr(f, cls.type)(self)
- else:
- cls = cls.base
-
- cls = self
- while cls != None:
- if attrs:
- sep = ", "
- if cls.base == None:
- sep += "or "
- else:
- sep = ""
- attrs += "%s'%s'" % (sep, cls.type)
- cls = cls.base
-
- raise AttributeError("'%s' object has no attribute %s" %
- (f.__class__.__name__, attrs))
+ def is_type(self, type):
+ cls = self
+ while cls != None:
+ if cls.type == type:
+ return True
+ cls = cls.base
+ return False
+
+ def dispatch(self, f, attrs=""):
Review comment:
eh, never mind, it _is_ consistent
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]