How to count comment lines and blank lines of a java source code using Python? -


i new learner.this program write. there seems lot of problems. want count total lines, blank lines, comments lines , code lines. can't run program. , know way count comment lines wrong.really need help.

def filelinecount(filename):     (shotname,extension) = os.path.splitext(filename);     if extension == '.java' : # file type          file = open(filename,'r');         alllines = file.readlines();         file.close();          linecount    =0;         commentcount = 0;         blankcount   = 0;         codecount    = 0;         eachline in alllines:                 if  eachline.find('//'):  #linecomment                      commentcount += 1;                 else :                     if eachline == "":                         blankcount += 1;                     else :                         codecount += 1;             linecount = linecount + 1;         self.all += linecount;         self.allcomment += commentcount;         self.allblank += blankcount;         self.allsource += codecount;         print filename;         print '           total      :',linecount ;         print '           comment    :',commentcount;         print '           blank      :',blankcount;         print '           source     :',codecount; 


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -