Ejemplo n.º 1
0
    def core_fileprocess(self, fullfilepath, filetype):
        if os.access(fullfilepath, os.R_OK):
            with open(fullfilepath, 'r', -1, encoding='utf-8') as fp:
                try:
                    lines = fp.readlines()
                    outputstring = ''
                    for i, line in enumerate(lines):
                        for function in constants.functionsContainVO:
                            p = re.compile(r'\b{0}'.format(function))
                            m = p.search(line)
                            if m:
                                if filetype == 'java':
                                    outputstring += commonJobs.printPackageAndFilename(
                                        fullfilepath, r'com\\posco'
                                    ) + '\t:::' + str(i + 1) + line.replace(
                                        '\t',
                                        ' ')  #normalize by remove tab in lines
                                elif filetype == 'jsp':
                                    outputstring += commonJobs.printPackageAndFilename(
                                        fullfilepath,
                                        r'public_html\\') + '\t:::' + str(
                                            i + 1) + line.replace('\t', ' ')


##                                sys.stdout.write(fullfilepath+':::'+str(i+1)+'\t'+line)
                                break  #need for improve performance
                    self.wf.write(outputstring)
                except:
                    print(str(sys.exc_info()[0]) + fullfilepath)
    def findFileNamesContainString(self, source_dir, findpattern_or_patterntuple, regex=0, extList=('')):
        """
        Job07__00_output.txt:   ProgramID | package | filename
        patterntuple: MUST be a tuple. (can create a set or list at first, then cast to tuple)
                         because endswith(..) only accept tuple
        """
        created_program_id = 'findFileNamesContainString<<Job07_JSPsRelatingToPGMIDs'
        print('Start 1' + created_program_id)
        returnSet = []
        for root, dirs, files in os.walk(source_dir):
            for file in files:
                lowerfile = file.lower()
                if lowerfile.endswith(extList):
                    if isinstance(findpattern_or_patterntuple, str):    # one pgm
                        findpattern = findpattern_or_patterntuple
                        if regex == 0:
                            if lowerfile.find(findpattern) != -1:
                                returnSet.append(findpattern.lower()+'\t'+commonJobs.printPackageAndFilename(root+"\\"+file,r'public_html')+'\t'+created_program_id)
                        else:
                            if re.search(findpattern, lowerfile):
                                pass
                    else:    # many pgms
                        patterntuple = findpattern_or_patterntuple
##                        if lowerfile.startswith(patterntuple):
##                            returnSet.append(file[:10].lower()+'\t'+commonJobs.printPackageAndFilename(root+"\\"+file,r'public_html'))                        
                        for findpattern in patterntuple:
                            if regex == 0:
                                if lowerfile.find(findpattern) != -1:
                                    returnSet.append(findpattern.lower()+'\t'+commonJobs.printPackageAndFilename(root+"\\"+file,r'public_html')+'\t'+created_program_id)
        return returnSet
Ejemplo n.º 3
0
 def findFileNamesContainString(self,
                                source_dir,
                                findpattern_or_patterntuple,
                                regex=0,
                                extList=('')):
     """
     Job07__00_output.txt:   ProgramID | package | filename
     patterntuple: MUST be a tuple. (can create a set or list at first, then cast to tuple)
                      because endswith(..) only accept tuple
     """
     created_program_id = 'findFileNamesContainString<<Job07_JSPsRelatingToPGMIDs'
     print('Start 1' + created_program_id)
     returnSet = []
     for root, dirs, files in os.walk(source_dir):
         for file in files:
             lowerfile = file.lower()
             if lowerfile.endswith(extList):
                 if isinstance(findpattern_or_patterntuple, str):  # one pgm
                     findpattern = findpattern_or_patterntuple
                     if regex == 0:
                         if lowerfile.find(findpattern) != -1:
                             returnSet.append(
                                 findpattern.lower() + '\t' +
                                 commonJobs.printPackageAndFilename(
                                     root + "\\" + file, r'public_html') +
                                 '\t' + created_program_id)
                     else:
                         if re.search(findpattern, lowerfile):
                             pass
                 else:  # many pgms
                     patterntuple = findpattern_or_patterntuple
                     ##                        if lowerfile.startswith(patterntuple):
                     ##                            returnSet.append(file[:10].lower()+'\t'+commonJobs.printPackageAndFilename(root+"\\"+file,r'public_html'))
                     for findpattern in patterntuple:
                         if regex == 0:
                             if lowerfile.find(findpattern) != -1:
                                 returnSet.append(
                                     findpattern.lower() + '\t' +
                                     commonJobs.printPackageAndFilename(
                                         root + "\\" +
                                         file, r'public_html') + '\t' +
                                     created_program_id)
     return returnSet
    def core_fileprocess(self, fullfilepath, filetype):
        if os.access(fullfilepath, os.R_OK):
            with open(fullfilepath,'r',-1,encoding='utf-8') as fp:
                try:
                    lines = fp.readlines()
                    outputstring = ''
                    for i,line in enumerate(lines):
                        for function in constants.functionsContainVO:
                            p = re.compile(r'\b{0}'.format(function))
                            m = p.search(line)
                            if m:
                                if filetype == 'java':
                                    outputstring += commonJobs.printPackageAndFilename(fullfilepath,r'com\\posco')+'\t:::'+str(i+1)+line.replace('\t',' ')  #normalize by remove tab in lines
                                elif filetype == 'jsp':
                                    outputstring += commonJobs.printPackageAndFilename(fullfilepath,r'public_html\\')+'\t:::'+str(i+1)+line.replace('\t',' ')
##                                sys.stdout.write(fullfilepath+':::'+str(i+1)+'\t'+line)
                                break   #need for improve performance
                    self.wf.write(outputstring)
                except:
                    print(str(sys.exc_info()[0]) + fullfilepath)
 def retrieveJavaFilesFromCMJavaFileList(self, srcpath, cmpackagepath, cmjavafilelist):
     global screenJavaList
     for root, dirs, files in os.walk(cmpackagepath):
         for file in files:
             if file in cmjavafilelist:
                 screenJavaList.append(commonJobs.printPackageAndFilename(root+"\\"+file, r'com\\posco',r'\.java').replace('\t','.'))
                 self.recur(srcpath, root+"\\"+file)
                 filteredList = self.filterActiveJavaFileList(srcpath, screenJavaList)
                 outputstring = ''
                 for value in filteredList:
                     outputstring += 'NUICM' +'\t' +file+'\t'+value+'\n'
                 self.wf.write(outputstring)
                 screenJavaList[:] = []
 def retrieveJavaFilesFromCMJavaFileList(self, srcpath, cmpackagepath,
                                         cmjavafilelist):
     global screenJavaList
     for root, dirs, files in os.walk(cmpackagepath):
         for file in files:
             if file in cmjavafilelist:
                 screenJavaList.append(
                     commonJobs.printPackageAndFilename(
                         root + "\\" + file, r'com\\posco',
                         r'\.java').replace('\t', '.'))
                 self.recur(srcpath, root + "\\" + file)
                 filteredList = self.filterActiveJavaFileList(
                     srcpath, screenJavaList)
                 outputstring = ''
                 for value in filteredList:
                     outputstring += 'NUICM' + '\t' + file + '\t' + value + '\n'
                 self.wf.write(outputstring)
                 screenJavaList[:] = []