forked from kenkeiras/org-rw
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):
|
def __init__(self):
|
||||||
self.children = []
|
self.children = []
|
||||||
|
|
||||||
def append(self, child):
|
def append(self, child):
|
||||||
self.children.append(child)
|
self.children.append(child)
|
||||||
|
|
||||||
|
|
||||||
|
class PropertyDrawerNode(DrawerNode):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Properties: {}>".format(len(self.children))
|
return "<Properties: {}>".format(len(self.children))
|
||||||
|
|
||||||
|
|
||||||
class LogbookDrawerNode:
|
class LogbookDrawerNode(DrawerNode):
|
||||||
def __init__(self):
|
|
||||||
self.children = []
|
|
||||||
|
|
||||||
def append(self, child):
|
|
||||||
self.children.append(child)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<LogBook: {}>".format(len(self.children))
|
return "<LogBook: {}>".format(len(self.children))
|
||||||
|
|
||||||
|
|
||||||
class ResultsDrawerNode:
|
class ResultsDrawerNode(DrawerNode):
|
||||||
def __init__(self):
|
|
||||||
self.children = []
|
|
||||||
|
|
||||||
def append(self, child):
|
|
||||||
self.children.append(child)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Results: {}>".format(len(self.children))
|
return "<Results: {}>".format(len(self.children))
|
||||||
|
|
||||||
@ -82,12 +73,16 @@ class ListItem:
|
|||||||
|
|
||||||
|
|
||||||
class BlockNode:
|
class BlockNode:
|
||||||
|
def __init__(self):
|
||||||
|
self.children = []
|
||||||
|
|
||||||
def append(self, child):
|
def append(self, child):
|
||||||
raise NotImplementedError()
|
self.children.append(child)
|
||||||
|
|
||||||
|
|
||||||
class CodeBlock(BlockNode):
|
class CodeBlock(BlockNode):
|
||||||
def __init__(self, header, subtype):
|
def __init__(self, header, subtype):
|
||||||
|
super().__init__()
|
||||||
self.header = header
|
self.header = header
|
||||||
self.lines = None
|
self.lines = None
|
||||||
self.subtype = subtype
|
self.subtype = subtype
|
||||||
|
@ -378,7 +378,7 @@ class Headline:
|
|||||||
elif isinstance(line, Text):
|
elif isinstance(line, Text):
|
||||||
if isinstance(current_node, dom.BlockNode):
|
if isinstance(current_node, dom.BlockNode):
|
||||||
current_node.append(dom.Text(line))
|
current_node.append(dom.Text(line))
|
||||||
elif isinstance(current_node, dom.LogbookDrawerNode):
|
elif isinstance(current_node, dom.DrawerNode):
|
||||||
current_node.append(dom.Text(line))
|
current_node.append(dom.Text(line))
|
||||||
else:
|
else:
|
||||||
if isinstance(current_node, dom.TableNode):
|
if isinstance(current_node, dom.TableNode):
|
||||||
|
Loading…
Reference in New Issue
Block a user