def retrieveJSPsFromJSPFile(self, publichtmldir, pgmidandjsplist): created_program_id = 'retrieveJSPsFromJSPFile<<Job07_JSPsRelatingToPGMIDs' print('Start 3' + created_program_id) returnSet = set() for value in pgmidandjsplist: splitList = value.split('\t') pgmid = splitList[0] jspfile = splitList[1] +'\\'+ splitList[2] jspfile = jspfile.replace('\t','.').replace('public_html.','').rstrip('.jsp') fullfilepath = teocommon_operation.convertPackageFilenameToFullpath(publichtmldir, jspfile,'.jsp') if os.path.isfile(fullfilepath): with open(fullfilepath,'r',-1,encoding='utf-8') as rf: lines = rf.readlines() for i, line in enumerate(lines): # tb_m00_screen_vs_jsps : pgmid | jsp_filepackage | jsp_filename | created_program_id if re.search('<%@.*\.jsp',line): #case 3 m = re.search('<%@.*"(.*)"', line) if m: returnSet.add(pgmid+'\t[[[JSP imported]]]<from '+jspfile+'>\t'+m.group(1)+'\t'+created_program_id) if re.search('window\.open',line): #case 4 line = line.replace('\t','') line = splitList[2]+':#:'+str(i+1)+':@:'+line teokeepf = '*' returnSet.add(pgmid+'\t[[[JSP window.open(..)]]]<from '+jspfile+'>\t'+line+'\t'+created_program_id + '\t'+teokeepf) else: pass return returnSet
def main(self, configdir, publichtmldir, uipgms, outputfilename=''): patternset = set() for value in uipgms: patternset.add(value.rstrip('.jsp')) #Step 1 aSet = self.findFileNamesContainString(publichtmldir, tuple(patternset), 0, '.jsp') #Then Step 2 mainList = self.transformToSubLists(aSet, replaceextension='_service.xml') bSet = self.retrieveJSPsFromServiceFile(configdir, mainList) #Then Step 3 resultSet = [] resultSet.extend(aSet) resultSet.extend(bSet) cSet = self.retrieveJSPsFromJSPFile(publichtmldir, resultSet) resultSet.extend(cSet) returnList = [] if outputfilename: wf = open(outputfilename, 'w', -1, encoding='utf-8') for value in sorted(set(resultSet)): splitList = value.split('\t') ## packfilename = value.partition('\t')[2].replace('\t','.').replace('public_html.','') packfilename = splitList[1].replace('public_html.','') + \ '.' + \ splitList[2] fullfilepath = teocommon_operation.convertPackageFilenameToFullpath( publichtmldir, packfilename) returnList.append(value) if os.path.isfile( fullfilepath): #filter active files for the final result if outputfilename: wf.write(value + '\n') pass else: print('<<<JSP file does not exist!!!>>>' + value) if outputfilename: wf.close() return returnList
def main(self, configdir, publichtmldir, uipgms, outputfilename=''): patternset = set() for value in uipgms: patternset.add(value.rstrip('.jsp')) #Step 1 aSet = self.findFileNamesContainString(publichtmldir,tuple(patternset),0,'.jsp') #Then Step 2 mainList = self.transformToSubLists(aSet, replaceextension='_service.xml') bSet = self.retrieveJSPsFromServiceFile(configdir, mainList) #Then Step 3 resultSet = [] resultSet.extend(aSet) resultSet.extend(bSet) cSet = self.retrieveJSPsFromJSPFile(publichtmldir, resultSet) resultSet.extend(cSet) returnList = [] if outputfilename: wf = open(outputfilename,'w', -1, encoding='utf-8') for value in sorted(set(resultSet)): splitList = value.split('\t') ## packfilename = value.partition('\t')[2].replace('\t','.').replace('public_html.','') packfilename = splitList[1].replace('public_html.','') + \ '.' + \ splitList[2] fullfilepath = teocommon_operation.convertPackageFilenameToFullpath(publichtmldir, packfilename) returnList.append(value) if os.path.isfile(fullfilepath): #filter active files for the final result if outputfilename: wf.write(value+'\n') pass else: print('<<<JSP file does not exist!!!>>>'+value) if outputfilename: wf.close() return returnList
def retrieveJSPsFromJSPFile(self, publichtmldir, pgmidandjsplist): created_program_id = 'retrieveJSPsFromJSPFile<<Job07_JSPsRelatingToPGMIDs' print('Start 3' + created_program_id) returnSet = set() for value in pgmidandjsplist: splitList = value.split('\t') pgmid = splitList[0] jspfile = splitList[1] + '\\' + splitList[2] jspfile = jspfile.replace('\t', '.').replace('public_html.', '').rstrip('.jsp') fullfilepath = teocommon_operation.convertPackageFilenameToFullpath( publichtmldir, jspfile, '.jsp') if os.path.isfile(fullfilepath): with open(fullfilepath, 'r', -1, encoding='utf-8') as rf: lines = rf.readlines() for i, line in enumerate(lines): # tb_m00_screen_vs_jsps : pgmid | jsp_filepackage | jsp_filename | created_program_id if re.search('<%@.*\.jsp', line): #case 3 m = re.search('<%@.*"(.*)"', line) if m: returnSet.add(pgmid + '\t[[[JSP imported]]]<from ' + jspfile + '>\t' + m.group(1) + '\t' + created_program_id) if re.search('window\.open', line): #case 4 line = line.replace('\t', '') line = splitList[2] + ':#:' + str(i + 1) + ':@:' + line teokeepf = '*' returnSet.add(pgmid + '\t[[[JSP window.open(..)]]]<from ' + jspfile + '>\t' + line + '\t' + created_program_id + '\t' + teokeepf) else: pass return returnSet