Unify drawer node classes under a common parent.
This commit is contained in:
parent
d1d5de89b7
commit
fc9ce664ae
@ -1,32 +1,23 @@
|
||||
class PropertyDrawerNode:
|
||||
class DrawerNode:
|
||||
def __init__(self):
|
||||
self.children = []
|
||||
|
||||
def append(self, child):
|
||||
self.children.append(child)
|
||||
|
||||
|
||||
class PropertyDrawerNode(DrawerNode):
|
||||
|
||||
def __repr__(self):
|
||||
return "<Properties: {}>".format(len(self.children))
|
||||
|
||||
|
||||
class LogbookDrawerNode:
|
||||
def __init__(self):
|
||||
self.children = []
|
||||
|
||||
def append(self, child):
|
||||
self.children.append(child)
|
||||
|
||||
class LogbookDrawerNode(DrawerNode):
|
||||
def __repr__(self):
|
||||
return "<LogBook: {}>".format(len(self.children))
|
||||
|
||||
|
||||
class ResultsDrawerNode:
|
||||
def __init__(self):
|
||||
self.children = []
|
||||
|
||||
def append(self, child):
|
||||
self.children.append(child)
|
||||
|
||||
class ResultsDrawerNode(DrawerNode):
|
||||
def __repr__(self):
|
||||
return "<Results: {}>".format(len(self.children))
|
||||
|
||||
@ -82,12 +73,16 @@ class ListItem:
|
||||
|
||||
|
||||
class BlockNode:
|
||||
def __init__(self):
|
||||
self.children = []
|
||||
|
||||
def append(self, child):
|
||||
raise NotImplementedError()
|
||||
self.children.append(child)
|
||||
|
||||
|
||||
class CodeBlock(BlockNode):
|
||||
def __init__(self, header, subtype):
|
||||
super().__init__()
|
||||
self.header = header
|
||||
self.lines = None
|
||||
self.subtype = subtype
|
||||
|
@ -378,7 +378,7 @@ class Headline:
|
||||
elif isinstance(line, Text):
|
||||
if isinstance(current_node, dom.BlockNode):
|
||||
current_node.append(dom.Text(line))
|
||||
elif isinstance(current_node, dom.LogbookDrawerNode):
|
||||
elif isinstance(current_node, dom.DrawerNode):
|
||||
current_node.append(dom.Text(line))
|
||||
else:
|
||||
if isinstance(current_node, dom.TableNode):
|
||||
|
Loading…
Reference in New Issue
Block a user