Beispiel #1
0
 def __ParseFunctions(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
    compoundname = compoundname[compoundname.rfind(":")+1:]
    functions = componddef.find_all('memberdef', {'kind':'function'})
    for function in functions:
       definition = function.find('definition').text
       argsstring = function.find('argsstring').text
       name = function.find('name').text
       location = function.find('location')
       if not location.has_attr('bodyfile'):
          MyLogger.warning('not found bodyfile of ', definition)
          continue
       bodyfile = location['bodyfile']
       bodystart = location['bodystart']
       bodyend = location['bodyend']
       if not name in self.samenamecnt:
          self.samenamecnt[name] = 1
       else:
          self.samenamecnt[name] += 1
       self.db_functions.DBAppendRow([compoundname, definition, argsstring, name, self.samenamecnt[name], bodyfile, bodystart, bodyend], self.temp_dict)
Beispiel #2
0
 def DBAppendColumn(self, columns, value=''):
     for column in columns:
         if not column in self.df.columns:
             self.df.insert(len(self.df.columns), column, value)
         else:
             MyLogger.warning('column ', column, ' is already exist')
     self.OnDataFrameUpdate()
     self.DBWrite()
Beispiel #3
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 #4
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)