1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
## Fonty Python Copyright (C) 2006, 2007, 2008, 2009 Donn.C.Ingle
## Contact: donn.ingle@gmail.com - I hope this email lasts.
##
## This file is part of Fonty Python.
## Fonty Python is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Fonty Python is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Fonty Python. If not, see <http://www.gnu.org/licenses/>.
import locale
import fpsys
"""
testing i18n with fontybugs
try:
raise fontybugs.BadVoodoo("bad voodoo")
except fontybugs.BadVoodoo, e:
print "error:", unicode(e)
try:
raise fontybugs.PogWriteError("/some/path/po.pog")
except fontybugs.PogWriteError, e:
print unicode(e)
"""
## The %s must be OUTSIDE the _() construct.
class Errors ( Exception ):
checkperms = _("\n(Also check your file permissions.)")
messages = {
001 : _("Bad voodoo error. I give up."),
100 : _("There is no such item."),
200 : _("Pog is empty."),
300 : _("Pog is already installed."),
500 : _("Pog cannot be written to.\nCheck your filesystem.%s") % checkperms,
600 : _("Pog is invalid, please hand-edit it."),
700 : _("Some fonts did not install.\nPerhaps the original fonts folder has moved or been renamed.\nYou should purge or hand-edit."),
800 : _("Pog is not installed."),
900 : _("Some fonts could not be uninstalled.\nPlease check your home .fonts (with a dot in front) folder for broken links.%s") % checkperms,
1000 : _("Cannot delete the Pog.%s") % checkperms,
1010 : _("Not a single font in this pog could be installed.\nThe original font folder has probably moved or been renamed."),
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\"."),
1030 : _("This folder has no fonts in it."),
1040 : _("Please create the ~/.fonts directory (in your home directory) so that you can install fonts.\n\nExample:\ncd ~\nmkdir .fonts\n\n")
}
def __unicode__( self ):
return u"%s : %s" % ( self.__class__.messages[self._id], self._item )
def _format_error(self):
## As of Python 2.6 e.message has been deprecated.
## Turn 'self' into a 'string like object' by calling __unicode__ above.
msg = unicode(self)
msg = fpsys.LSP.to_bytes( msg )
return msg
def print_error(self):
print self._format_error()
def print_error_and_quit(self):
self.print_error()
raise SystemExit
class BadVoodoo ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 001
class ErrNoSuchItem ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 100
class PogEmpty ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 200
class PogInstalled ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 300
class PogWriteError ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 500
class PogInvalid ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 600
class PogSomeFontsDidNotInstall ( Errors ): #Some fonts did get installed, but not all
def __init__ ( self, item = None):
self._item = item
self._id = 700
class PogNotInstalled ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 800
class PogLinksRemain ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 900
class PogCannotDelete ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 1000
class PogAllFontsFailedToInstall ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 1010
class PogAllFontsFailedToUninstall ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 1020
class FolderHasNoFonts ( Errors ):
def __init__ ( self, item = None):
self._item = item
self._id = 1030
#June 25, 2016
class NoFontsDir ( Errors ):
def __init__ (self, item = None ):
self._item = item
self._id=1040
|