c6eb59eb42
Add the following files: python3-flightgear/README-l10n.txt python3-flightgear/fg-convert-translation-files python3-flightgear/fg-new-translations python3-flightgear/fg-update-translation-files python3-flightgear/flightgear/__init__.py python3-flightgear/flightgear/meta/__init__.py python3-flightgear/flightgear/meta/exceptions.py python3-flightgear/flightgear/meta/i18n.py python3-flightgear/flightgear/meta/logging.py python3-flightgear/flightgear/meta/misc.py They should work on Python 3.4 and later (tested with 3.5.3). The folder structure is chosen so that other FG support modules can insert themselves here, and possibly be used together. I put all of these inside 'flightgear.meta', because I don't expect them to be needed at FG runtime (neither now nor in the future), probably not even by the CMake build system. To declare that a string has plural forms, simply set the attribute 'with-plural' to 'true' on the corresponding element of the default translation (and as in Qt, use %n as a placeholder for the number that determines which singular or plural form to use).
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# exceptions.py --- Simple, general-purpose subclass of Exception
|
|
#
|
|
# Copyright (C) 2015, 2017 Florent Rougon
|
|
#
|
|
# This program 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 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
"""Simple, general-purpose Exception subclass."""
|
|
|
|
|
|
class FGPyException(Exception):
|
|
def __init__(self, message=None, *, mayCapitalizeMsg=True):
|
|
"""Initialize an FGPyException instance.
|
|
|
|
Except in cases where 'message' starts with a proper noun or
|
|
something like that, its first character should be given in
|
|
lower case. Automated treatments of this exception may print the
|
|
message with its first character changed to upper case, unless
|
|
'mayCapitalizeMsg' is False. In other words, if the case of the
|
|
first character of 'message' must not be changed under any
|
|
circumstances, set 'mayCapitalizeMsg' to False.
|
|
|
|
"""
|
|
self.message = message
|
|
self.mayCapitalizeMsg = mayCapitalizeMsg
|
|
|
|
def __str__(self):
|
|
return self.completeMessage()
|
|
|
|
def __repr__(self):
|
|
return "{}.{}({!r})".format(__name__, type(self).__name__, self.message)
|
|
|
|
# Typically overridden by subclasses with a custom constructor
|
|
def detail(self):
|
|
return self.message
|
|
|
|
def completeMessage(self):
|
|
if self.message:
|
|
return "{shortDesc}: {detail}".format(
|
|
shortDesc=self.ExceptionShortDescription,
|
|
detail=self.detail())
|
|
else:
|
|
return self.ExceptionShortDescription
|
|
|
|
ExceptionShortDescription = "FlightGear Python generic exception"
|