Beispiel #1
0
 def __FindPlantUML(compoundname, name, samenamecnt):
    MyLogger.sakura(compoundname," ", name," ", samenamecnt)
    for index,value in self.all_functions.items():
       if value['compoundname'] == compoundname and value['name'] == name and str(value['samenamecnt']) == samenamecnt:
          # MyLogger.sakura(value)
          bodyfile = value['bodyfile']
          return self.outputbase+bodyfile+'/'+name+"("+samenamecnt+').pu'
    return ''
Beispiel #2
0
 def DraftUML(self):
    MyLogger.SetFraction(len(self.all_functions.items()))
    for index,values in self.all_functions.items():
       MyLogger.SetNumerator(index)
       compoundname = values['compoundname']
       definition = values['definition']
       argsstring = values['argsstring']
       name = values['name'][values['name'].rfind(":")+1:]
       samenamecnt = str(values['samenamecnt'])
       bodyfile = values['bodyfile']
       bodystart = int(values['bodystart'])-1
       bodyend = int(values['bodyend'])
       inputfile = self.inputbase+bodyfile
       outputfile = self.outputbase+bodyfile+'/'+name+"("+samenamecnt+').pu'
       MyLogger.sakura(outputfile)
       if not os.path.exists(os.path.dirname(outputfile)):
          os.makedirs(os.path.dirname(outputfile))
       if bodyend != -1:
          functionbody = myopen(inputfile, 'r').readlines()[bodystart:bodyend]
       else:
          functionbody = myopen(inputfile, 'r').readlines()[bodystart]
       functionbody = self.__CustomizeFunctionBody(functionbody, compoundname)
       with myopen(outputfile, 'w', encoding='utf-8') as f:
          f.write("' #######################################\n")
          f.write("' definition="+definition+"\n")
          f.write("' bodyfile="+bodyfile+"\n")
          f.write("' bodystart="+str(bodystart)+"\n")
          f.write("' bodyend="+str(bodyend)+"\n")
          f.write("' #######################################\n")
          f.write("@startuml\n")
          f.write("skinparam SequenceDividerFontSize 30\n")
          f.write("skinparam SequenceGroupFontSize 30\n")
          f.write("== " + compoundname + ":" + name + argsstring + " ==\n")
          f.write("activate " + compoundname + "\n")
          f.write("' #######################################\n")
          f.write(''.join(functionbody))
          f.write("' #######################################\n")
          f.write("deactivate " + compoundname + "\n")
          f.write("@enduml\n")
          f.write("' #######################################\n")
Beispiel #3
0
 def __ExtractPlantUML(inputfile, outputfile):
    isExtract = False
    with myopen(outputfile, 'w', encoding='utf-8') as output:
       # inputfileをループ
       input_lines = myopen(inputfile, 'r').readlines()
       for input_line in input_lines:
          # フォーマットに当てはまるコメントがあればumlを展開できるか確認
          if (result := re.fullmatch("(\s*)' MyPlantUML\[([\w.]+)->([\w.]*):([\w]+)\(([\d]*)\)\]\n", input_line, re.S)) != None:
             indent = result.group(1)
             modfrom = result.group(2)
             modto = result.group(3)
             function = result.group(4)
             number = result.group(5)
             if modto == '':
                output.write(input_line)
                continue
             if function in self.ignore_functions:
                output.write(input_line)
                continue
             umlpath = __FindPlantUML(modto, function, number)
             if umlpath == '' or not os.path.exists(umlpath):
                MyLogger.warning('plantuml not found for : ',input_line.replace("\n",""))
                output.write(input_line)
                continue
             # umlを展開
             isExtract = True
             extract_lines = myopen(umlpath, 'r').readlines()
             for extract_line in extract_lines:
                if extract_line == "@startuml\n" or extract_line == "@enduml\n":
                   continue
                extract_line = indent+extract_line
                extract_line = extract_line.replace("entrypoint", modfrom)
                MyLogger.sakura(extract_line.replace("\n",""))
                output.write(extract_line)
          else:
             MyLogger.sakura(input_line.replace("\n",""))
             output.write(input_line)
Beispiel #4
0
 def __ParseDefines(self, xmlpath):
    xml = ''.join(myopen(xmlpath, 'r').readlines())
    soup = BeautifulSoup(xml, 'lxml')
    componddef = soup.find('compounddef')
    if not componddef:
       MyLogger.warning('not found compoundname in ', xmlpath)
       return
    compoundname = componddef.find('compoundname').text
    defines = componddef.find_all('memberdef', {'kind':'define'})
    for define in defines:
       name = define.find('name').text
       if (params := define.find_all('param')):
          MyLogger.sakura("name",name)
          for param in params:
             MyLogger.sakura("param",param.text)
       if (initializer := define.find('initializer')):
          initializer = initializer.text
          MyLogger.sakura("initializer",initializer)
Beispiel #5
0
 def SetIgnoreFunction(self, functions):
    self.ignore_functions += functions
    MyLogger.sakura(self.ignore_functions)