Changeset 78
- Timestamp:
- 03/10/04 18:24:31 (4 years ago)
- Files:
-
- 05/devel/kombilo.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
05/devel/kombilo.py
r72 r78 868 868 f = open(filename) 869 869 sgf = f.read() 870 if self.DBlist[DBindex]['encoding']: 870 c = Cursor(sgf, 1) 871 encoding = c.encoding or self.DBlist[DBindex]['encoding'] 872 if encoding: 871 873 try: 872 sgf = sgf.decode( self.DBlist[DBindex]['encoding']).encode('utf-8')874 sgf = sgf.decode(encoding).encode('utf-8') 873 875 except: 874 876 pass 875 877 876 878 f.close() 877 node = Cursor(sgf, 1).getRootNode(gameNumber)879 node = c.getRootNode(gameNumber) 878 880 except: 879 881 return … … 2644 2646 2645 2647 encoding = self.encodingVar.get() 2648 2649 encoding1 = 0 2650 if self.encoding1Var.get() == 'Do not change SGF': encoding1 = 0 2651 elif self.encoding1Var.get() == 'Add CA tag': encoding1 = 1 2652 elif self.encoding1Var.get() == 'Transcode SGF to utf-8': encoding1 = 2 2653 2646 2654 2647 2655 filelist.sort() … … 2671 2679 try: 2672 2680 file = open(f) 2673 s = file.read()2681 sOrig = file.read() 2674 2682 file.close() 2675 2683 except IOError: … … 2677 2685 continue 2678 2686 2679 if encoding:2680 try:2681 s = s.decode(encoding).encode('utf-8')2682 except:2683 pass2684 2687 try: 2685 cursor = Cursor(s , self.options.sloppySGF.get())2688 cursor = Cursor(sOrig, self.options.sloppySGF.get()) 2686 2689 except: 2687 2690 messages.insert(END, 'Error in SGF file '+f+': Skipped.\n') 2688 2691 continue 2689 2692 2693 if encoding1 == 1 and not cursor.encoding: 2694 d = cursor.getRootNode(0) 2695 d['CA'] = [encoding] 2696 cursor.encoding = encoding 2697 cursor.updateRootNode(d,0) 2698 try: 2699 sgf_out = cursor.output() 2700 file = open(f, 'w') 2701 file.write(sgf_out) 2702 file.close() 2703 except: 2704 messages.insert(END, 'Unable to write CA-tagged file ' + f + '\n') 2705 currentEncoding = cursor.encoding or encoding 2706 if currentEncoding != 'utf-8': 2707 try: 2708 s = sOrig.decode(currentEncoding).encode('utf-8') 2709 cursor = Cursor(s, self.options.sloppySGF.get()) 2710 if encoding1 == 2 and not cursor.encoding: 2711 file = open(f, 'w') 2712 file.write(s) 2713 file.close() 2714 except IOError: 2715 messages.insert(END, 'Unable to write transcoded file ' + f + '\n') 2716 except: 2717 messages.insert(END, 'Unable to transcode file ' + f + '\n') 2718 2690 2719 if cursor.root.numChildren > 1: 2691 2720 collection = 1 … … 5630 5659 encodingMenu.grid(row=1, column=1, sticky=W) 5631 5660 5661 self.encoding1Var = StringVar() 5662 encoding1Menu = Pmw.OptionMenu(f3, labelpos='w', label_text='', 5663 menubutton_textvariable = self.encoding1Var, 5664 items = ['Do not change SGF', 'Add CA tag', 'Transcode SGF to utf-8'], 5665 initialitem = 0) 5666 encoding1Menu.grid(row=1, column=2, sticky=W) 5667 5632 5668 recursionButton = Checkbutton(f3, text = "Recursively add subdir's", highlightthickness=0, 5633 5669 variable = self.options.recProcess)
