Made some changes to ensure compatibility in Python 2 with gettext.

The gettext.install() functions supplies a way to force it to return
unicode which helps with compatibility between Python 2 & 3. To make it
work properly when merging those returned string with strings in the
different modules of gitinspector we also had to do some changes to make
sure all string literals are in unicode.
This commit is contained in:
Adam Waldenberg 2013-06-25 16:37:18 +02:00
parent 9c0633f8ad
commit f20c3c1895
13 changed files with 20 additions and 5 deletions

View File

@ -17,6 +17,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
__comment_begining__ = {"java": "/*", "c": "/*", "cpp": "/*", "h": "/*", "hpp": "/*", "html": "<!--", "php": "/*", __comment_begining__ = {"java": "/*", "c": "/*", "cpp": "/*", "h": "/*", "hpp": "/*", "html": "<!--", "php": "/*",
"py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "sql": "/*", "xml": "<!--"} "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "sql": "/*", "xml": "<!--"}

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from outputable import Outputable from outputable import Outputable
import terminal import terminal
import textwrap import textwrap

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from outputable import Outputable from outputable import Outputable
import terminal import terminal
import textwrap import textwrap
@ -44,7 +45,7 @@ def set_filtered(file_name):
return True return True
return False return False
__filtering_info_text__ = _("The following files were excluded from the statistics due to the" __filtering_info_text__ = _("The following files were excluded from the statistics due to the "
"specified exclusion patterns") "specified exclusion patterns")
class Filtering(Outputable): class Filtering(Outputable):

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
import version import version
import base64 import base64
import basedir import basedir

View File

@ -19,6 +19,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
import localization import localization
localization.init() localization.init()

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from extensions import __default_extensions__ from extensions import __default_extensions__
from format import __available_formats__ from format import __available_formats__
import sys import sys

View File

@ -18,6 +18,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
__since__ = "" __since__ = ""
__until__ = "" __until__ = ""

View File

@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import gettext import gettext
import locale import locale
import os import os
@ -38,4 +39,4 @@ def init():
except IOError: except IOError:
translation = gettext.NullTranslations() translation = gettext.NullTranslations()
translation.install() translation.install(True)

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from outputable import Outputable from outputable import Outputable
import interval import interval
import os import os

View File

@ -18,17 +18,18 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
import format import format
class Outputable(object): class Outputable(object):
def output_html(self): def output_html(self):
print(_("HTML output not yet supported in \"") + self.__class__.__name__ + "\".") print(_("HTML output not yet supported in") + " \"" + self.__class__.__name__ + "\".")
def output_text(self): def output_text(self):
print(_("Text output not yet supported in \"") + self.__class__.__name__ + "\".") print(_("Text output not yet supported in") + " \"" + self.__class__.__name__ + "\".")
def output_xml(self): def output_xml(self):
print(_("XML output not yet supported in \"") + self.__class__.__name__ + "\".") print(_("XML output not yet supported in") + " \"" + self.__class__.__name__ + "\".")
def output(outputable): def output(outputable):
if format.get_selected() == "html": if format.get_selected() == "html":

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from outputable import Outputable from outputable import Outputable
import blame import blame
import terminal import terminal

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
from outputable import Outputable from outputable import Outputable
import datetime import datetime
import terminal import terminal

View File

@ -18,6 +18,7 @@
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>. # along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals
import localization import localization
localization.init() localization.init()