minor bugfixes

This commit is contained in:
Michael Clemens 2018-03-26 12:23:04 +02:00
parent 54a0d7b858
commit 2f4064bcfc
2 changed files with 10 additions and 8 deletions

View File

@ -11,5 +11,5 @@ sort_rules = True
toc = True toc = True
# Configure inclusion of images # Configure inclusion of images
images = False images = True
imagepath = images imagepath = images

View File

@ -44,7 +44,7 @@ imagepath = config.get('config', 'imagepath')
# Generates a line containing linebreaks, indented lists, styles etc. # Generates a line containing linebreaks, indented lists, styles etc.
def line(level,key,value): def line(level,key,value):
lvl = "" lvl = ""
output = "" output = ""
valout = "" valout = ""
@ -52,7 +52,7 @@ def line(level,key,value):
elif level == 2: lvl = " * " elif level == 2: lvl = " * "
elif level == 3: lvl = " * " elif level == 3: lvl = " * "
else: lvl = "" else: lvl = ""
if value: if value:
value = unquote(value) value = unquote(value)
@ -88,8 +88,10 @@ def sortxml(xmlfile):
# Generate Markdown Syntax for Images # Generate Markdown Syntax for Images
def addimage(rulename): def addimage(rulename):
out = "" out = ""
if not os.path.exists(imagepath):
os.makedirs(imagepath)
imagefile = imagepath + "/" + rulename + ".png" imagefile = imagepath + "/" + rulename + ".png"
imagefile = imagefile.replace(" ", "_") imagefile = imagefile.replace(" ", "_")
out = "![](" + imagefile + ")\n\n\n" out = "![](" + imagefile + ")\n\n\n"
@ -116,12 +118,12 @@ def getRelationDict(cdata):
tname = t.get('name') tname = t.get('name')
tparent = t.findtext('trigger') tparent = t.findtext('trigger')
if tname: if tname:
if not tparent: if not tparent:
tparent = "root" tparent = "root"
rel[tname]=tparent rel[tname]=tparent
return rel return rel
# populate Graph Object with trigger nodes and edges # populate Graph Object with trigger nodes and edges
def addTriggersToGraph(reldict,cdata,G): def addTriggersToGraph(reldict,cdata,G):
@ -134,7 +136,7 @@ def addTriggersToGraph(reldict,cdata,G):
if key.startswith("trigger") or key.startswith("Root Trigger"): if key.startswith("trigger") or key.startswith("Root Trigger"):
for trigkey in sorted(reldict): for trigkey in sorted(reldict):
if reldict[trigkey] == key: if reldict[trigkey] == key:
trigcount += 1 trigcount += 1
# get count value from triggers element # get count value from triggers element
for tc in cdata.getiterator('trigger'): for tc in cdata.getiterator('trigger'):
if tc.get('name') == key: if tc.get('name') == key:
@ -148,7 +150,7 @@ def addTriggersToGraph(reldict,cdata,G):
oper = "AND" oper = "AND"
else: else:
oper = "OR" oper = "OR"
# add trigger nodes to graph # add trigger nodes to graph
G.add_node(key, label=oper, shape='plaintext') G.add_node(key, label=oper, shape='plaintext')
if key != "root" and reldict[key] != "root": if key != "root" and reldict[key] != "root":