Exemple #1
0
class Local(Singleton):
    def __init__(self):
        xml = SimpleXML(Path.executeDirectory())
        try:
            self.__lngSect = xml.openSection(SysConfig().lngFile)
        except Exception, err:
            raise err
        if self.__lngSect is None:
            raise BaseException("Error", "config file 'bin.xml' is not exist.")
Exemple #2
0
    def formatLocalText(self, _scope, _tag, **args):
        """
		格式化指定语言版本文本,不做编码转换,args 必须与 python 脚本编码一致
		"""
        sect = self.__lngSect[_scope]
        if sect is None or sect[_tag] is None or \
         sect[_tag].asString is None:
            raise BaseException(
                "Error", "language file is not contain the tag '<%s>/<%s>'." %
                (_scope, _tag))
        text = sect[_tag].asString
        try:
            text = text % args
        except TypeError:
            raise BaseException(
                "Error",
                "format message in tag '<%s>/<%s>' in language file fial: (args='%s')"
                % (_scope, _tag, args))
        return text
Exemple #3
0
    def getLocalText(self, scope, tag):
        """
		获取指定语言版本文本,不做编码转换,args 必须与 python 脚本编码一致
		"""
        sect = self.__lngSect[scope]
        if sect is None or sect[tag] is None or \
         sect[tag].asString is None:
            raise BaseException(
                "Error", "language file is not contain the tag '<%s>/<%s>'." %
                (scope, tag))
        return sect[tag].asString
Exemple #4
0
	def __init__(self, msg):
		title = Local().formatLocalText("explain", "errTitle")
		BaseException.__init__(self, title, msg)
Exemple #5
0
 def __init__(self, tagName, **args):
     title = Local().formatLocalText("encoding", "errTitle")
     msg = Local().formatLocalText("encoding", tagName, **args)
     BaseException.__init__(self, title, msg)
Exemple #6
0
	def __init__(self, msg):
		title = Local().formatLocalText("dataSource", 'errTitle')
		BaseException.__init__(self, title, msg)
Exemple #7
0
 def __call__(self, dsrc, row):
     raise BaseException(
         "Error",
         "class %r must implement %r method" % (self.clsName, "__call__"))
Exemple #8
0
 def explainText(cls, text, *args, **extras):
     raise BaseException("Error", "%s unimplements a class method: %s" % \
      (cls.__name__, 'explainText(cls, text, *args, **extras)'))
Exemple #9
0
def _raiseUnImplementExcept(clsName, methodName):
    raise BaseException("unimplement exception",
                        "method '%s' is not implemented.")