Changeset 51
- Timestamp:
- 02/08/04 18:26:34 (5 years ago)
- Files:
-
- 05/devel/kombilo.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
05/devel/kombilo.py
r50 r51 2569 2569 """ The main class of Kombilo. """ 2570 2570 2571 def process(self, dbpath, datap, messages , encoding=''):2571 def process(self, dbpath, datap, messages): 2572 2572 """ Process the database dbpath, i.e. translate the SGF files into the 2573 2573 .db files that the pattern search function uses. … … 2593 2593 else: 2594 2594 filelist = glob.glob(os.path.join(dbpath,'*')) 2595 2596 encoding = self.encodingVar.get() 2595 2597 2596 2598 filelist.sort() … … 5292 5294 if not namelist: return 5293 5295 5294 self.gamelist.DBlist.append({'name': datap, 'sgfpath':dbpath, 'encoding': '',5296 self.gamelist.DBlist.append({'name': datap, 'sgfpath':dbpath, 'encoding': self.encodingVar.get(), 5295 5297 'current':array('L'), 'results':[], 'numNewGames':0, 5296 5298 'data':[], 'disabled': 0}) … … 5372 5374 5373 5375 self.gamelist.DBlist[i:i] = [{'name':datap, 'sgfpath':dbpath, 'current':array('L'), 5374 ' results':[], 'numNewGames':0,5376 'encoding': self.encodingVar.get(), 'results':[], 'numNewGames':0, 5375 5377 'data':[], 'disabled': 0}] 5376 5378 … … 5465 5467 def browseDatabases(self): 5466 5468 initdir = self.options.whereToStoreDatabases.get() or os.curdir 5467 filename = str(askdirectory(initialdir = initdir)) 5469 filename = askdirectory(initialdir = initdir) 5470 if filename: filename = str(filename) 5468 5471 self.options.whereToStoreDatabases.set(filename) 5469 5472 … … 5530 5533 5531 5534 self.filenamesVar = StringVar() 5532 filenamesMenu = Pmw.OptionMenu(f3, labelpos='w', label_text='Files:', menubutton_textvariable = self.filenamesVar, 5535 filenamesMenu = Pmw.OptionMenu(f3, labelpos='w', label_text='Files:', 5536 menubutton_textvariable = self.filenamesVar, 5533 5537 items = ['*.sgf', '*.sgf, *.mgt', 'All files'], initialitem = 0) 5534 filenamesMenu.grid(row=1, column=0, columnspan=2, sticky=W) 5538 filenamesMenu.grid(row=1, column=0, sticky=W) 5539 5540 self.encodingVar = StringVar() 5541 if cjkcodecs_available: 5542 enclist = ['utf-8', 'gb2312', 'gbk', 'gb18030', 'hz', 5543 'big5', 'cp950', 'cp932', 'shift-jis', 'shift-jisx0213', 5544 'euc-jp', 'euc-jisx0213', 'iso-2022-jp', 'iso-2022-jp-1', 5545 'iso-2022-jp-2', 'iso-2022-jp-3', 'iso-2022-jp-ext', 5546 'cp949', 'euc-kr', 'johab', 'iso-2022-kr'] 5547 else: 5548 enclist = ['utf-8'] 5549 encodingMenu = Pmw.OptionMenu(f3, labelpos='w', label_text='Encoding:', 5550 menubutton_textvariable = self.encodingVar, 5551 items = enclist, initialitem = 0) 5552 encodingMenu.grid(row=1, column=1, sticky=W) 5535 5553 5536 5554 recursionButton = Checkbutton(f3, text = "Recursively add subdir's", highlightthickness=0, … … 5540 5558 whereDatabasesButton = Checkbutton(f3, text = 'Store databases separately from SGF files', highlightthickness=0, 5541 5559 command = self.toggleWhereDatabases, variable = self.options.storeDatabasesSeparately) 5542 whereDatabasesButton.grid(row=3, column=0, sticky=W)5560 whereDatabasesButton.grid(row=3, column=0, columnspan=2, sticky=W) 5543 5561 5544 5562 self.whereDatabasesEntry = Entry(f3, textvariable = self.options.whereToStoreDatabases) 5545 self.whereDatabasesEntry.grid(row=4, column=0, sticky=NSEW)5563 self.whereDatabasesEntry.grid(row=4, column=0, columnspan=2, sticky=NSEW) 5546 5564 if not self.options.storeDatabasesSeparately.get(): self.whereDatabasesEntry.config(state=DISABLED) 5547 5565 5548 5566 browseButton = Button(f3, text ='Browse', command = self.browseDatabases) 5549 browseButton.grid(row=4, column= 1)5567 browseButton.grid(row=4, column=2) 5550 5568 5551 5569 self.processMessages = Message(f4) … … 5747 5765 for db in self.gamelist.DBlist: 5748 5766 if db['disabled']: 5749 f.write('dD|%'+ db['sgfpath'] + '|%' + db['name'][0] + '|%' + db['name'][1] +'\n') 5767 f.write('dD|%'+ db['sgfpath'] + '|%' + db['name'][0] +\ 5768 '|%' + db['name'][1] + '|%' + db['encoding'] + '\n') 5750 5769 else: 5751 f.write('d|%' + db['sgfpath'] + '|%' + db['name'][0] + '|%' + db['name'][1] +'\n') 5770 f.write('d|%' + db['sgfpath'] + '|%' + db['name'][0] +\ 5771 '|%' + db['name'][1] + '|%' + db['encoding'] +'\n') 5752 5772 f.close() 5753 5773 except IOError: … … 6259 6279 self.sgfpath = line[1] 6260 6280 elif line and line[0] == 'd': 6281 if len(line)==4: 6282 enc = 'utf-8' 6283 else: 6284 enc = line[4] 6261 6285 self.gamelist.DBlist.append({'sgfpath':line[1], 'name':(line[2], line[3]), 'data':[], 6262 'encoding': '', 'results':[], 'current':array('L'),6286 'encoding': enc, 'results':[], 'current':array('L'), 6263 6287 'numNewGames':0, 'disabled': 0}) 6264 6288 6265 6289 elif line and line[0] == 'dD': 6290 if len(line)==3: 6291 enc = 'utf-8' 6292 else: 6293 enc = line[4] 6266 6294 self.gamelist.DBlist.append({'sgfpath':line[1], 'name':(line[2], line[3]), 'data':[], 6267 'encoding': '', 'results':[], 'current':array('L'),6295 'encoding': enc, 'results':[], 'current':array('L'), 6268 6296 'numNewGames':0, 'disabled': 1}) 6269 6297
