Changeset 11
- Timestamp:
- 09/22/07 12:34:48 (1 year ago)
- Files:
-
- branches/baptiste/fontypython/cli.py (modified) (15 diffs)
- branches/baptiste/fontypython/config.py (modified) (6 diffs)
- branches/baptiste/fontypython/dialogues.py (modified) (5 diffs)
- branches/baptiste/fontypython/folder.py (modified) (2 diffs)
- branches/baptiste/fontypython/fontybugs.py (modified) (7 diffs)
- branches/baptiste/fontypython/fontypython.py (deleted)
- branches/baptiste/fontypython/fpsys.py (modified) (5 diffs)
- branches/baptiste/fontypython/fpversion.py (modified) (1 diff)
- branches/baptiste/fontypython/pathcontrol.py (modified) (4 diffs)
- branches/baptiste/fontypython/pog.py (modified) (12 diffs)
- branches/baptiste/fontypython/start.py (modified) (1 diff)
- branches/baptiste/fontypython/strings.py (modified) (6 diffs)
- branches/baptiste/fontypython/wxgui.py (modified) (34 diffs)
- branches/baptiste/locale (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/baptiste/fontypython/cli.py
r6 r11 19 19 20 20 import sys 21 import os 21 22 import strings 22 23 import pathcontrol … … 25 26 import fontybugs 26 27 28 ## i18n imports 29 import gettext 30 from gettext import gettext as _ 31 ## i18n configuration 32 gettext.bindtextdomain("cli", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 33 gettext.textdomain("cli") 34 27 35 from pog import * 28 36 … … 37 45 parser = OptionParser() 38 46 use = strings.use() 39 parser = OptionParser(usage=use, version="Fonty Python %s Copyright (C) 2006 Donn.C.Ingle" % fpversion. version)40 parser.add_option("-e", "--examples", action="store_const", dest="examples", const=True, help= "show some %$@#$ examples!")41 parser.add_option("-i", "--install", dest="install", metavar="pog", help= "install the fonts in this pog to your fonts folder")42 parser.add_option("-u", "--uninstall", dest="uninstall", metavar="pog", help= "uninstall the fonts in this pog")43 parser.add_option("-l", "--list", action="store_const", const=True, help= "list the names of all the pogs")44 parser.add_option("-s", "--size", action="store", metavar="num", dest="points", help= "set a new default point size. 64 is best")45 parser.add_option("-v", "--view", action="store", metavar="num", dest="numinpage", help= "set a new default for how many fonts to view at one go. 10 is good")46 parser.add_option("-t", "--text", action="store", metavar="\"text\"", dest="text", type="string", help= "set a new default sample text. \"This is an ex-parrot!\" is good. Be sure to use the quotes")47 parser.add_option("-p", "--purge", action="store", metavar="pog", dest="purge", help= "purge the pog of ttf files that are no longer really there")47 parser = OptionParser(usage=use, version="Fonty Python %s Copyright (C) 2006 Donn.C.Ingle" % fpversion.__version__) 48 parser.add_option("-e", "--examples", action="store_const", dest="examples", const=True, help=_("show some %$@#$ examples!")) 49 parser.add_option("-i", "--install", dest="install", metavar="pog", help=_("install the fonts in this pog to your fonts folder")) 50 parser.add_option("-u", "--uninstall", dest="uninstall", metavar="pog", help=_("uninstall the fonts in this pog")) 51 parser.add_option("-l", "--list", action="store_const", const=True, help=_("list the names of all the pogs")) 52 parser.add_option("-s", "--size", action="store", metavar="num", dest="points", help=_("set a new default point size. 64 is best")) 53 parser.add_option("-v", "--view", action="store", metavar="num", dest="numinpage", help=_("set a new default for how many fonts to view at one go. 10 is good")) 54 parser.add_option("-t", "--text", action="store", metavar="\"text\"", dest="text", type="string", help=_("set a new default sample text. \"This is an ex-parrot!\" is good. Be sure to use the quotes")) 55 parser.add_option("-p", "--purge", action="store", metavar="pog", dest="purge", help=_("purge the pog of ttf files that are no longer really there")) 48 56 #parser.add_option("-g", "--gui", action="store", metavar="(wxgui OR qtgui)", dest="gui", help="choose a graphical interface, one of wxgui or qtgui. Only one that is available and working on your system will be used. The default is wxgui") 49 parser.add_option("--min", action="store_const", const=True, help= "only show the minimal interface. This will be set as the default for next time.")50 parser.add_option("--max", action="store_const", const=True, help= "show the entire interface. This will be set as the default for next time.")57 parser.add_option("--min", action="store_const", const=True, help=_("only show the minimal interface. This will be set as the default for next time.")) 58 parser.add_option("--max", action="store_const", const=True, help=_("show the entire interface. This will be set as the default for next time.")) 51 59 52 60 (options, args) = parser.parse_args() … … 61 69 poglist = iPC.getPogNames() 62 70 if len(poglist) == 0: 63 print "There are no pogs available."71 print _("There are no pogs available.") 64 72 sys.exit() 65 print "Listing %d pog(s) "% len(poglist)66 print " (*) indicates installed pogs"73 print _("Listing %d pog(s) ") % len(poglist) 74 print _(" (*) indicates installed pogs") 67 75 for pog in poglist: 68 76 paf = iPC.appPath() + pog + ".pog" … … 72 80 f.close() 73 81 except: 74 print "Could not open %s."% paf82 print _("Could not open %s.") % paf 75 83 s = "" 76 84 if installed.upper() == "INSTALLED": … … 106 114 fpsys.config.text = options.text 107 115 fpsys.config.Save() 108 print "Your text has been set to \"%s\""% options.text109 print "Tip: Did you use quotes to surround your text?"110 print "Start FontyPython again to see the result."116 print _("Your text has been set to \"%s\"") % options.text 117 print _("Tip: Did you use quotes to surround your text?") 118 print _("Start FontyPython again to see the result.") 111 119 sys.exit() 112 120 … … 133 141 print str(e) 134 142 else: 135 sys.exit( "%s cannot be found. Try -l to see the names."% pogtopurge)143 sys.exit(_("%s cannot be found. Try -l to see the names.") % pogtopurge) 136 144 fpsys.config.Save() 137 145 sys.exit(strings.done) … … 157 165 ## PogAllFontsFailedToInstall 158 166 ## PogSomeFontsDidNotInstall 159 print "Installing %s"% pogtoinstall167 print _("Installing %s") % pogtoinstall 160 168 pog.install() # will use progressCallBack to print each font name. 161 169 except (fontybugs.PogEmpty, … … 165 173 print str(e) 166 174 else: # not a pogname 167 sys.exit( "%s cannot be found. Try -l to see the names."% pogtoinstall)175 sys.exit(_("%s cannot be found. Try -l to see the names.") % pogtoinstall) 168 176 fpsys.config.Save() 169 177 sys.exit(strings.done) … … 184 192 ## PogLinksRemain 185 193 ## PogNotInstalled 186 print "Removing %s"% pogtouninstall194 print _("Removing %s") % pogtouninstall 187 195 pog.uninstall() 188 196 except (fontybugs.PogEmpty, … … 191 199 print str(e) 192 200 else: 193 sys.exit( "Sorry, can't find %s. Try -l to see the names."% pogtouninstall)201 sys.exit(_("Sorry, can't find %s. Try -l to see the names.") % pogtouninstall) 194 202 fpsys.config.Save() 195 203 sys.exit(strings.done) … … 199 207 if len(args) > 2: 200 208 ## The user may have chosen a pogname with spaces and no quotes 201 print """Please check your arguments, there seem to be too many.209 print _("""Please check your arguments, there seem to be too many. 202 210 (Remember: it's one pound for a five-minute argument, but only 203 211 eight pounds for a course of ten.) 204 212 205 213 NB: If you wanted to use spaces in a pogname or folder then 206 please put quotes around them.""" 214 please put quotes around them.""") 207 215 sys.exit() 208 216 … … 228 236 if not fpsys.isFolder(A) and not fpsys.isPog(A) and not fakearg: 229 237 ## It's a non starter: 230 sys.exit( "%s does not exist. Try --list"% A)238 sys.exit(_("%s does not exist. Try --list") % A) 231 239 232 240 ## Disallow Folder in arg B 233 241 if B and fpsys.isFolder(B): 234 sys.exit( "You cannot use a folder as the target argument. Try --help")242 sys.exit(_("You cannot use a folder as the target argument. Try --help")) 235 243 236 244 ## Let's ensure that B exists, else we must make it. … … 274 282 except fontybugs.PogInvalid, e: 275 283 sys.exit(str(e)) 276 if installed: sys.exit( "The target pog (%s) is currently installed,\nyou can't use it as a target." % B)284 if installed: sys.exit(_("The target pog (%s) is currently installed,\nyou can't use it as a target." % B)) 277 285 278 286 if fpsys.isPog(A)and fpsys.isPog(B): 279 287 ## "PP" 280 288 if A == B: 281 sys.exit( "Your pogs are the same! Try -e")289 sys.exit(_("Your pogs are the same! Try -e")) 282 290 try: 283 291 empty = fpsys.validateViewPog(A) 284 292 except fontybugs.PogInvalid, e: 285 293 sys.exit(str(e)) 286 if empty: sys.exit( "This pog is empty")294 if empty: sys.exit(_("This pog is empty")) 287 295 288 296 try: … … 291 299 sys.exit(str(e)) 292 300 if installed: 293 sys.exit( "The target pog (%s) is currently installed,\nyou can't use it as a target."% B)301 sys.exit(_("The target pog (%s) is currently installed,\nyou can't use it as a target.") % B) 294 302 295 303 ## sys.exit("Your arguments amuse me :) Please try -h") branches/baptiste/fontypython/config.py
r6 r11 18 18 ## 19 19 20 import sys, os, pickle 20 import sys 21 import os 22 import pickle 21 23 import strings 22 24 import pathcontrol 23 25 26 ## i18n imports 27 import gettext 28 from gettext import gettext as _ 29 ## i18n configuration 30 gettext.bindtextdomain("config", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 31 gettext.textdomain("config") 24 32 25 33 #### … … 33 41 self.pos = (10, 10) 34 42 self.numinpage = 10 35 self.text = "Jump the lazy dog fox"43 self.text = _("Jump the lazy dog fox") 36 44 self.points = 64 37 45 self.lastview = "" # a pog name or a folder path. 38 46 self.usegui = None 47 self.max = True 48 self.lastdir = None 39 49 ## Private vars 40 50 self.__dontSaveNumInPage = False … … 47 57 pf.close() 48 58 except: 49 sys.exit( "%s file appears to be damaged.\nPlease delete it and start again"% self.ipc.appConf())59 sys.exit(_("%s file appears to be damaged.\nPlease delete it and start again") % self.ipc.appConf()) 50 60 else: 51 print "No config file found, creating it with defaults."61 print _("No config file found, creating it with defaults.") 52 62 self.__write() 53 63 ## Now get them into the instance vars: 54 64 try: 55 65 self.size = self.__data['size'] 66 self.usegui = self.__data['usegui'] 56 67 self.pos= self.__data['pos'] 57 68 self.numinpage = self.__data['numinpage'] 58 69 self.text = self.__data['text'] 59 70 self.points= self.__data['points'] 60 self.lastview = self.__data['lastview'] 71 self.lastview = self.__data['lastview'] 72 self.max = self.__data['max'] 73 self.lastdir = self.__data['lastdir'] 61 74 except KeyError: 62 75 ## The conf file has keys that don't work for this version, chances are it's old. … … 65 78 os.unlink(self.ipc.appConf()) 66 79 except: 67 sys.exit( "The fontypython config file is damaged.\nPlease remove it and start again")80 sys.exit(_("The fontypython config file is damaged.\nPlease remove it and start again")) 68 81 self.__write() 69 82 def dontSaveNumInPage(self, flag): … … 75 88 "text":self.text, 76 89 "points":self.points, 77 "lastview" : self.lastview 90 "lastview": self.lastview, 91 "usegui": self.usegui, 92 "max": self.max, 93 "lastdir": self.lastdir 78 94 } 79 95 def __write(self): … … 87 103 pf.close() 88 104 except IOError: 89 print "Could not write to the config file."105 print _("Could not write to the config file.") 90 106 def save(self): 91 107 self.__write() #Go write the file 92 93 108 94 109 ## Our config instance - it will have one instance across branches/baptiste/fontypython/dialogues.py
r6 r11 18 18 ## 19 19 20 import sys 21 import os 20 22 import fpsys 21 23 import strings … … 23 25 24 26 import wx.html as html 27 28 ## i18n imports 29 import gettext 30 from gettext import gettext as _ 31 ## i18n configuration 32 gettext.bindtextdomain("dialogues", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 33 gettext.textdomain("dialogues") 25 34 26 35 class DialogHelp(wx.Dialog): … … 83 92 84 93 def __set_properties(self): 85 self.SetTitle( "About FontyPython")94 self.SetTitle(_("About FontyPython")) 86 95 _icon = wx.EmptyIcon() 87 96 _icon.CopyFromBitmap(wx.Bitmap(fpsys.mythingsdir + 'fplogo.png', wx.BITMAP_TYPE_ANY)) … … 116 125 sizer_3.Fit(self.notebook_1_pane_2) 117 126 sizer_3.SetSizeHints(self.notebook_1_pane_2) 118 self.nb.AddPage(self.notebook_1_pane_1, "About")119 self.nb.AddPage(self.notebook_1_pane_2, "Licence")127 self.nb.AddPage(self.notebook_1_pane_1, _("About")) 128 self.nb.AddPage(self.notebook_1_pane_2, _("Licence")) 120 129 sizer_1.Add(self.nb, 1, wx.EXPAND, 0) 121 130 … … 132 141 #-1 , "Settings", size = wx.DefaultSize, , 133 142 # style = wx.DEFAULT_DIALOG_STYLE): 134 wx.Dialog.__init__(self, parent, -1, "Settings", pos = wx.DefaultPosition, size =(450,-1))143 wx.Dialog.__init__(self, parent, -1, _("Settings"), pos = wx.DefaultPosition, size =(450,-1)) 135 144 136 145 ## The layout begins: 137 146 font = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD) 138 self.labelHeading = wx.StaticText(self, -1, "Settings")147 self.labelHeading = wx.StaticText(self, -1, _("Settings")) 139 148 self.labelHeading.SetFont(font) 140 149 141 self.label_1 = wx.StaticText(self, -1, "Sample text:")150 self.label_1 = wx.StaticText(self, -1, _("Sample text:")) 142 151 self.inputSampleString = wx.TextCtrl(self, -1, fpsys.config.text) #, size = (200, -1)) 143 152 self.inputSampleString.SetFocus() 144 153 145 self.label_2 = wx.StaticText(self, -1, "Point size:")154 self.label_2 = wx.StaticText(self, -1, _("Point size:")) 146 155 self.inputPointSize = wx.SpinCtrl(self, -1, "") 147 156 self.inputPointSize.SetRange(1, 500) 148 157 self.inputPointSize.SetValue(fpsys.config.points) 149 158 150 self.label_3 = wx.StaticText(self, -1, "Page length:")159 self.label_3 = wx.StaticText(self, -1, _("Page length:")) 151 160 self.inputPageLen = wx.SpinCtrl(self, -1, "") 152 161 self.inputPageLen.SetRange(1, 5000) # It's your funeral! branches/baptiste/fontypython/folder.py
r8 r11 23 23 import fontybugs 24 24 import sys 25 import os 26 27 ## i18n imports 28 import gettext 29 from gettext import gettext as _ 30 ## i18n configuration 31 gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 32 gettext.textdomain("misc") 25 33 26 34 class Folder(BasicFontList): … … 42 50 fi = FontItem(os.path.join(self.path, f), False) 43 51 except UnicodeDecodeError, e: 44 sys.exit( "The file %s has caused a unicode error.\nPlease rename it, removing any strange characters, and try again."% f)52 sys.exit(_("The file %s has caused a unicode error.\nPlease rename it, removing any strange characters, and try again.") % f) 45 53 self.append(fi) 46 54 if len(self) == 0: branches/baptiste/fontypython/fontybugs.py
r4 r11 23 23 ## I want a single file which contains all the errors. 24 24 25 import sys 26 import os 27 28 ## i18n imports 29 import gettext 30 from gettext import gettext as _ 31 ## i18n configuration 32 gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 33 gettext.textdomain("misc") 34 25 35 class Errors ( Exception ): 26 checkperms = "Also check your file permissions"36 checkperms = _("Also check your file permissions") 27 37 messages = { 28 001 : "Bad voodoo error. I give up.",29 100 : "There is no such item",30 200 : "Pog is empty",31 300 : "Pog is already installed",32 #400 : "Pog cannot be read",33 500 : "Pog cannot be written to.\nCheck your filesystem.\n%s"% checkperms,34 600 : "Pog is invalid, please hand-edit it",35 700 : "Some fonts did not install.\nPerhaps the original fonts folder has moved or been renamed.\nYou should purge or hand-edit",36 800 : "Pog is not installed.",37 900 : "Some fonts could not be uninstalled.\nPlease check your home .fonts (with a dot in front) folder for broken links.\n%s"% checkperms,38 1000 : "Cannot delete the Pog. %s"% checkperms,39 1010 : "Not a single font in this pog could be installed.\nThe original font folder has probably moved or been renamed.",40 1020 : "Not a single font in this pog could be uninstalled.\nNone of the fonts were in your fonts folder, please check your home .fonts (with a dot in front) folder for broken links.\nThe pog has been marked as \"not installed\"",41 1030 : "This folder has not ttf fonts in it"38 001 : _("Bad voodoo error. I give up."), 39 100 : _("There is no such item"), 40 200 : _("Pog is empty"), 41 300 : _("Pog is already installed"), 42 #400 : _("Pog cannot be read", 43 500 : _("Pog cannot be written to.\nCheck your filesystem.\n%s") % checkperms, 44 600 : _("Pog is invalid, please hand-edit it"), 45 700 : _("Some fonts did not install.\nPerhaps the original fonts folder has moved or been renamed.\nYou should purge or hand-edit"), 46 800 : _("Pog is not installed."), 47 900 : _("Some fonts could not be uninstalled.\nPlease check your home .fonts (with a dot in front) folder for broken links.\n%s") % checkperms, 48 1000 : _("Cannot delete the Pog. %s") % checkperms, 49 1010 : _("Not a single font in this pog could be installed.\nThe original font folder has probably moved or been renamed."), 50 1020 : _("Not a single font in this pog could be uninstalled.\nNone of the fonts were in your fonts folder, please check your home .fonts (with a dot in front) folder for broken links.\nThe pog has been marked as \"not installed\""), 51 1030 : _("This folder has not ttf fonts in it") 42 52 } 43 53 def __str__ ( self ): … … 48 58 self._item = item 49 59 self._id = 001 50 60 51 61 class ErrNoSuchItem ( Errors ): 52 62 def __init__ ( self, item = None): … … 58 68 self._item = item 59 69 self._id = 200 60 70 61 71 class PogInstalled ( Errors ): 62 72 def __init__ ( self, item = None): 63 73 self._item = item 64 74 self._id = 300 65 75 66 76 class PogWriteError ( Errors ): 67 77 def __init__ ( self, item = None): 68 78 self._item = item 69 79 self._id = 500 70 80 71 81 class PogInvalid ( Errors ): 72 82 def __init__ ( self, item = None): … … 78 88 self._item = item 79 89 self._id = 700 80 90 81 91 #FontNotInstalled 82 92 class PogNotInstalled ( Errors ): … … 84 94 self._item = item 85 95 self._id = 800 86 96 87 97 class PogLinksRemain ( Errors ): 88 98 def __init__ ( self, item = None): 89 99 self._item = item 90 100 self._id = 900 91 101 92 102 #PogCannotDelete 93 103 class PogCannotDelete ( Errors ): … … 95 105 self._item = item 96 106 self._id = 1000 97 107 98 108 class PogAllFontsFailedToInstall ( Errors ): 99 109 def __init__ ( self, item = None): … … 104 114 def __init__ ( self, item = None): 105 115 self._item = item 106 self._id = 1020 107 116 self._id = 1020 117 108 118 class FolderHasNoFonts ( Errors ): 109 119 def __init__ ( self, item = None): 110 120 self._item = item 111 self._id = 1030 112 113 114 115 116 117 118 119 120 121 self._id = 1030 branches/baptiste/fontypython/fpsys.py
r6 r11 18 18 ## 19 19 20 import sys, os, pickle 20 import sys 21 import os 21 22 import pathcontrol 22 23 import strings … … 25 26 from folder import * 26 27 from emptyview import * 28 29 ## i18n imports 30 import gettext 31 from gettext import gettext as _ 32 ## i18n configuration 33 gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 34 gettext.textdomain("misc") 27 35 28 36 ## fpsys : fonty python system. … … 43 51 return os.path.dirname(os.path.abspath(root)) 44 52 except: 45 print "I'm sorry, but something is wrong."46 print "There is no __file__ variable. Please contact the author."53 print _("I'm sorry, but something is wrong.") 54 print _("There is no __file__ variable. Please contact the author.") 47 55 sys.exit() 48 56 … … 86 94 mythingsdir = determine_fontypython_path() + "/things/" #point it at things/ folder 87 95 88 ####89 ## Save and Load the conf file90 class Configure:91 """Makes/Loads the conf file.92 Supplies size, pos, numinpage, text string and point size to other objects."""93 def __init__(self) :94 ## Private vars95 self.__dontSaveNumInPage = False96 self.ipc = pathcontrol.PathControl()97 ## PUBLIC vars : Set some defaults:98 self.size = (400,600)99 self.pos = (10, 10)100 self.numinpage = 10101 self.text = "Jump the lazy dog fox"102 self.points = 64103 self.lastview = "EMPTY" # a pog name or a folder path.104 self.usegui = "wxgui"105 self.max = True106 self.lastdir = self.ipc.home()107 108 self.__setData()109 110 if os.path.exists(self.ipc.appConf()):111 try:112 pf = open(self.ipc.appConf(), "r") #Using global self.ipc object!113 self.__data = pickle.load(pf)114 pf.close()115 except:116 sys.exit("%s file appears to be damaged.\nPlease delete it and start again" % self.ipc.appConf())117 else:118 print "No config file found, creating it with defaults."119 self.__write()120 ## Now get them into the instance vars:121 try:122 self.size = self.__data['size']123 self.pos = self.__data['pos']124 self.numinpage = self.__data['numinpage']125 self.text = self.__data['text']126 self.points= self.__data['points']127 self.lastview = self.__data['lastview']128 self.usegui = self.__data['usegui']129 self.max = self.__data['max']130 self.lastdir = self.__data['lastdir']131 132 except KeyError:133 ## The conf file has keys that don't work for this version, chances are it's old.134 ## Let's delete and re-make it.135 try:136 os.unlink(self.ipc.appConf())137 except:138 sys.exit("The fontypython config file is damaged.\nPlease remove it and start again")139 self.__write()140 def dontSaveNumInPage(self, flag):141 self.__dontSaveNumInPage = flag142 def __setData(self):143 self.__data = {"size" : self.size,144 "pos" : self.pos,145 "numinpage" : self.numinpage,146 "text" : self.text,147 "points" : self.points,148 "lastview" : self.lastview,149 "usegui" : self.usegui,150 "max" : self.max,151 "lastdir" : self.lastdir152 }153 def __write(self) :154 #If we are NOT to save the numinpage, then fetch it from what was there before.155 if self.__dontSaveNumInPage:156 self.numinpage = self.__data["numinpage"]157 self.__setData()158 try:159 pf = open(self.ipc.appConf(), "w")160 pickle.dump(self.__data, pf)161 pf.close()162 except IOError:163 print "Could not write to the config file."164 def Save(self) :165 self.__write() #Go write the file166 167 168 96 ## Our config instance - it will have one instance across 169 97 ## all the modules that use it. 170 config = Configure() 98 import config as configure_parent 99 config = configure_parent.instance 171 100 172 101 def validateViewFolder(foldername): … … 248 177 for iA in state.viewobject: 249 178 if iA.paf in pafBlist: 250 iA.msg = "Already in %s"% state.targetobject.name179 iA.msg = _("Already in %s") % state.targetobject.name 251 180 iA.inactive = True 252 181 del pafBlist branches/baptiste/fontypython/fpversion.py
r4 r11 18 18 ## 19 19 20 version = "0.2.0" #Full GUI version20 __version__ = "0.2.0B" #Full GUI version branches/baptiste/fontypython/pathcontrol.py
r6 r11 20 20 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 21 ## 22 23 import sys 22 24 import os 25 26 ## i18n imports 27 import gettext 28 from gettext import gettext as _ 29 ## i18n configuration 30 gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 31 gettext.textdomain("misc") 23 32 24 33 class PathControl: … … 40 49 os.mkdir(self.__HOME + "/.fonts") 41 50 except: 42 print "Couldn't make the .fonts folder in %s"% self.__HOME43 print "Please check your write permissions and try again."51 print _("Couldn't make the .fonts folder in %s") % self.__HOME 52 print _("Please check your write permissions and try again.") 44 53 sys.exit () 45 54 self.__userfontpath = self.__HOME + "/.fonts" … … 48 57 self.__fpconffile = self.__HOME + "\\fontypython\\fp.conf" 49 58 else: 50 sys.exit( "Unsupported O/S")59 sys.exit(_("Unsupported O/S")) 51 60 52 61 #Make ~/.fontypython or ?:\Documents and Settings\blah\blah\fontypython … … 55 64 os.makedirs(self.__fphomepath) #using makedirS - just in case. 56 65 except: 57 print "Couldn't make the folder in %s"% self.__fphomepath58 print "Please check your write permissions and try again."66 print _("Couldn't make the folder in %s") % self.__fphomepath 67 print _("Please check your write permissions and try again.") 59 68 sys.exit () 60 69 branches/baptiste/fontypython/pog.py
r6 r11 20 20 ## 21 21 22 import sys 23 import os 22 24 from basicfontlist import * 23 25 from pathcontrol import * 24 26 import fontybugs 27 28 ## i18n imports 29 import gettext 30 from gettext import gettext as _ 31 ## i18n configuration 32 gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 33 gettext.textdomain("misc") 25 34 26 35 class Pog(BasicFontList): … … 58 67 line1 = f.readline()[:-1] 59 68 self.__installed = "dirty" # unsure as to the status 60 if line1.upper() == "INSTALLED": self.__installed = "yes"61 if line1.upper() == "NOT INSTALLED": self.__installed = "no"69 if line1.upper() == "INSTALLED": self.__installed = _("yes") 70 if line1.upper() == "NOT INSTALLED": self.__installed = _("no") 62 71 if self.__installed == "dirty": 63 72 ## We have a bad pog. … … 72 81 def isInstalled(self): 73 82 """Will ONLY raise a PogInvalid error. Any other will abort app.""" 74 if self.__installed == "yes": return True75 if self.__installed == "no": return False83 if self.__installed == _("yes"): return True 84 if self.__installed == _("no"): return False 76 85 ## Else it == "dirty" and: 77 86 ## We must open the file to discover the status: … … 79 88 f = self.__openfile() #sets __installed flag 80 89 f.close() 81 if self.__installed == "yes": return True82 if self.__installed == "no": return False90 if self.__installed == _("yes"): return True 91 if self.__installed == _("no"): return False 83 92 84 93 def __renameBadPog(self): … … 113 122 raise fontybugs.PogEmpty # RAISED :: PogEmpty 114 123 ## can't purge an installed pog 115 if self.__installed == "yes":124 if self.__installed == _("yes"): 116 125 raise fontybugs.PogInstalled # RAISED :: PogInstalled 117 126 else: … … 141 150 def install(self): 142 151 ## We start thinking all is rosey: 143 self.__installed = "yes"152 self.__installed = _("yes") 144 153 self.__badpog = False 145 154 ## Now we make sure ... 146 155 if len(self) == 0: 147 self.__installed = "no"156 self.__installed = _("no") 148 157 raise fontybugs.PogEmpty(self.name) # RAISED :: PogEmpty 149 158 ## Now we go through the guts of the pog, font by font: … … 155 164 if os.path.exists(fi.paf): 156 165 os.symlink(fi.paf, linkDestination) #Should do the trick. 157 self.__doProgressCallback( "installed : %s"% fi.paf)166 self.__doProgressCallback(_("installed : %s") % fi.paf) 158 167 else: 159 self.__doProgressCallback( "Could not find %s"% fi.paf)168 self.__doProgressCallback(_("Could not find %s") % fi.paf) 160 169 bugs += 1 161 170 if bugs == len(self): # There was 100% failure to install fonts. … … 188 197 if len(self) == 0: raise fontybugs.PogEmpty # RAISED :: PogEmpty 189 198 bugs = 0 190 if self.__installed == "yes":199 if self.__installed == _("yes"): 191 200 for fi in self: 192 201 link = os.path.join(self.__pc.userFontPath(), fi.name) #Point at the link in .fonts folder. … … 195 204 try: 196 205 os.unlink(link) 197 self.__doProgressCallback( "removed : %s"% fi.paf)206 self.__doProgressCallback(_("removed: %s") % fi.paf) 198 207 except: # e.g. Permission denied [err 13] 199 208 ## Only bugs that imply that the file is THERE but CANNOT BE REMOVED 200 209 ## are classified as bugs. We are making a sweeping assumption here. 201 self.__doProgressCallback( "Could not remove %s"% link)210 self.__doProgressCallback(_("Could not remove %s") % link) 202 211 bugs += 1 203 212 ## Okay, we are currently INSTALLED, so what is the result of the loop? … … 207 216 else: 208 217 ## Okay - there were no problems, so we are now done. 209 self.__installed = "no"218 self.__installed = _("no") 210 219 self.write() #save to disk 211 220 else: … … 218 227 try: 219 228 f = open(self.paf, "w") 220 i = "not installed\n"221 if self.__installed == "yes":222 i = "installed\n"229 i = _("not installed\n") 230 if self.__installed == _("yes"): 231 i = _("installed\n") 223 232 f.write(i) 224 233 #Now write the font pafs … … 237 246 raise fontybugs.PogCannotDelete(self.paf) 238 247 self.clear() 239 self.__installed = "no"248 self.__installed = _("no") branches/baptiste/fontypython/start.py
r6 r11 62 62 63 63 ## End, clean up 64 fpsys.config. Save()64 fpsys.config.save() branches/baptiste/fontypython/strings.py
r6 r11 19 19 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 20 ## 21 22 import sys 23 import os 21 24 import pathcontrol 22 25 import fpversion 23 26 24 copyright = "Fonty Python Copyright (C) 2006 Donn.C.Ingle" 25 contact = "email: donn.ingle@gmail.com" 26 done = "Done." 27 ## i18n imports 28 import gettext 29 from gettext import gettext as _ 30 ## i18n configuration 31 gettext.bindtextdomain("main", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 32 gettext.textdomain("main") 33 34 copyright = _("Fonty Python Copyright (C) 2007 Donn.C.Ingle") 35 contact = _("email: donn.ingle@gmail.com. website: http://fontypython.webfactional.com/") 36 done = _("Done.") 27 37 _pc = pathcontrol.PathControl() 28 38 29 warranty = """Fonty Python comes with ABSOLUTELY NO WARRANTY; for details39 warranty = _("""Fonty Python comes with ABSOLUTELY NO WARRANTY; for details 30 40 see the COPYING file. This is free software, and you are welcome to redistribute 31 41 it under certain conditions; see the COPYING file or the Licence tab in the 32 About menu for details.""" 42 About menu for details.""") 33 43 34 44 def AboutText(): 35 return "%s\nVersion %s.\nWritten on Gnu\Linux, using wxPython.\n\n%s" % (copyright, fpversion.version, warranty)45 return _("%(copyright)s\nVersion %(version)s.\nWritten on Gnu\Linux, using wxPython.\n\n%(warranty)s") % {'copyright': copyright, 'version': fpversion.__version__, 'warranty': warranty} 36 46 37 47 def use(): 38 use = """fp [OPTIONS] VIEW [TARGET]48 use = _("""fp [OPTIONS] VIEW [TARGET] 39 49 40 50 VIEW : A place where fonts are. A pog or a folder someplace. … … 66 76 67 77 Manage your ttf fonts on Gnu/Linux! 68 """ + copyright + """ 69 """ + warranty + """ 70 """ + contact 78 %(copyright)s 79 %(warranty)s 80 %(contact)s""") % {'copyright': copyright, 'warranty': warranty, 'contact': contact} 71 81 return use 72 82 73 83 def examples(): 74 s = """The basic format is:fp VIEW [TARGET]84 s = _("""The basic format is: fp VIEW [TARGET] 75 85 VIEW = A place where fonts are. A pog or a folder 76 86 someplace. … … 155 165 156 166 Your fontypython folder is: 157 """ + _pc.appPath() + """ 167 %(path)s 158 168 If you want to backup your pogs, that's where ya go. 159 160 """ + contact + """ 161 """ + copyright 169 %(contact)s 170 171 %(copyright)s""") % {'path': _pc.appPath(), 'contact': contact, 'copyright': copyright} 162 172 163 173 return s 164 174 165 175 def wxVersionError(): 166 return """I cannot find python-wxversion, this176 return _("""I cannot find python-wxversion, this 167 177 may mean you have some missing dependencies. 168 178 Fonty Python will try to start anyway ... … … 174 184 install python-wxgtk2.6 or better. 175 185 Go to http://wxpython.sourceforge.net/download.php 176 """ 177 186 """) 178 187 179 188 def wxError(): 180 return """Fonty Python depends on "wxPython".189 return _("""Fonty Python depends on "wxPython". 181 190 Please install "python-wxgtk2.6" (or better) here are the details: 182 191 … … 185 194 186 195 Go to http://wxpython.sourceforge.net/download.php 187 """ 196 """) 188 197 189 198 def PILError(): 190 return """Fonty Python depends on "PIL" - Python Imaging Library.&n
