patonlab / GoodVibes

Calculate quasi-harmonic free energies from Gaussian output files with temperature and other corrections
http://www.patonlab.colostate.edu
MIT License
132 stars 52 forks source link

File name parser does not work in a fancy way #7

Closed NKUCodingCat closed 6 years ago

NKUCodingCat commented 6 years ago

I am using V2.0.1 and Ln 410 - Ln 419 are as follows:

files = []
   if len(sys.argv) > 1:
      for elem in sys.argv[1:]:
         try:
            if elem.split(".")[1] == "out" or elem.split(".")[1] == "log":
               for file in glob(elem):
                   if options.spc == False or options.spc == 'link': files.append(file)
                   else:
                       if file.find('_'+options.spc+".") == -1: files.append(file)
         except IndexError: pass

Obviously, if I have a filename start with '.' or '..', such code cannot detect my filename correctly Eg: ../Examples/123.out

I wanna write a patch however I don't know the business logic of these parameters (Although I am a student that major in Computational Chem. ). But I think it could be easily to fix.

Meanwhile, use os.path.splitext to get extension is much more pythonic and here's a example

NKUCodingCat commented 6 years ago

solved in #9