Changeset 57

Show
Ignore:
Timestamp:
02/08/04 21:34:16 (5 years ago)
Author:
ug
Message:

Add copyCurrentGamesToFolder

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 05/devel/kombilo.py

    r56 r57  
    952952                            duplist.append(os.path.join(db['sgfpath'], g[0])) 
    953953        return duplist 
     954 
     955 
     956    def listOfCurrentSGFFiles(self): 
     957        l = [] 
     958        for db in self.DBlist: 
     959            if db['disabled']: continue 
     960            for i in db['current']: 
     961                l.append(os.path.join(db['sgfpath'], getFilename(db['data'][i][0]))) 
     962        return l   
     963 
    954964 
    955965 
     
    56205630    # -------------------------------------------------------------------- 
    56215631 
     5632 
     5633    def copyCurrentGamesToFolder(self): 
     5634        dir = askdirectory(initialdir=self.datapath) 
     5635        if not dir: return 
     5636        dir = str(dir) 
     5637 
     5638        if not os.path.exists(dir) and askokcancel('Error', 'Directory ' + dir + ' does not exist. Create it?'): 
     5639            try: 
     5640                os.makedirs(dir) 
     5641            except: 
     5642                return 
     5643         
     5644        l = self.gamelist.listOfCurrentSGFFiles() 
     5645        for f in l: 
     5646            inf = open(f) 
     5647            s = inf.read() 
     5648            inf.close() 
     5649 
     5650            outfile = os.path.join(dir, os.path.split(f)[-1]) 
     5651            if os.path.exists(outfile): continue 
     5652            out = open(outfile, 'w') 
     5653            out.write(s) 
     5654            out.close() 
     5655 
     5656 
     5657 
    56225658    def askMaxLengthPrevSearchStack(self): 
    56235659        s = askstring('Configure Back button', 'Enter maximal number of searches to remember:\n' + \ 
     
    60006036        self.filemenu.insert_command(7, label='Export current position', command=self.exportCurrentPos) 
    60016037        self.filemenu.insert_command(8, label='Export SGF', command=self.exportSGF) 
    6002          
     6038 
     6039        self.filemenu.insert_command(9, label='Copy current SGF files to folder', 
     6040                                     command=self.copyCurrentGamesToFolder) 
    60036041 
    60046042        self.customMenus = customMenus(self)