Changeset 491


Ignore:
Timestamp:
Feb 23, 2012 11:46:43 AM (10 years ago)
Author:
vondreele
Message:

recovered old GPXBackup as new one put extra ".bak'" in file name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstruct.py

    r490 r491  
    221221    return Histograms,Phases
    222222   
    223 def GPXBackup(GPXfile,makeBack=True):
     223#def GPXBackup(GPXfile,makeBack=True):      #not work correctly
     224#    import distutils.file_util as dfu
     225#    GPXpath,GPXname = ospath.split(GPXfile)
     226#    if GPXpath == '': GPXpath = '.'
     227#    Name = ospath.splitext(GPXname)[0]
     228#    files = os.listdir(GPXpath)
     229#    last = 0
     230#    for name in files:
     231#        name = name.split('.')
     232#        if len(name) >= 3 and name[0] == Name and 'bak' in name[-2]:
     233#            if makeBack:
     234#                last = max(last,int(name[-2].strip('bak'))+1)
     235#            else:
     236#                last = max(last,int(name[-2].strip('bak')))
     237#    GPXback = ospath.join(GPXpath,GPXname.rstrip('.'.join(name[-2:]))+'.bak'+str(last)+'.gpx')
     238#    dfu.copy_file(GPXfile,GPXback)
     239#    return GPXback
     240#       
     241def GPXBackup(GPXfile,makeBack=True):       #recovered old one
    224242    import distutils.file_util as dfu
    225243    GPXpath,GPXname = ospath.split(GPXfile)
     
    230248    for name in files:
    231249        name = name.split('.')
    232         if len(name) >= 3 and name[0] == Name and 'bak' in name[-2]:
     250        if len(name) == 3 and name[0] == Name and 'bak' in name[1]:
    233251            if makeBack:
    234                 last = max(last,int(name[-2].strip('bak'))+1)
     252                last = max(last,int(name[1].strip('bak'))+1)
    235253            else:
    236                 last = max(last,int(name[-2].strip('bak')))
    237     GPXback = ospath.join(GPXpath,GPXname.rstrip('.'.join(name[-2:]))+'.bak'+str(last)+'.gpx')
     254                last = max(last,int(name[1].strip('bak')))
     255    GPXback = ospath.join(GPXpath,ospath.splitext(GPXname)[0]+'.bak'+str(last)+'.gpx')
    238256    dfu.copy_file(GPXfile,GPXback)
    239257    return GPXback
    240        
     258
    241259def SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,CovData,makeBack=True):
    242260    ''' Updates gpxfile from all histograms that are found in any phase
Note: See TracChangeset for help on using the changeset viewer.