コード例 #1
0
def init():
	global __enabled__
	global __installed__
	global __translation__

	if not __installed__:
		try:
			locale.setlocale(locale.LC_ALL, "")
		except locale.Error:
			__translation__ = gettext.NullTranslations()
		else:
			lang = locale.getlocale()

			#Fix for non-POSIX-compliant systems (Windows et al.).
			if os.getenv('LANG') is None:
				lang = locale.getdefaultlocale()
				os.environ['LANG'] = lang[0]

			filename = basedir.get_basedir() + "/translations/messages_%s.mo" % lang[0][0:2]

			try:
				__translation__ = gettext.GNUTranslations(open(filename, "rb"))
			except IOError:
				__translation__ = gettext.NullTranslations()

		__enabled__ = True
		__installed__ = True
		__translation__.install(True)
コード例 #2
0
ファイル: localization.py プロジェクト: xxyy/gitinspector
def init():
	global __enabled__
	global __installed__
	global __translation__

	if not __installed__:
		try:
			locale.setlocale(locale.LC_ALL, "")
		except locale.Error:
			__translation__ = gettext.NullTranslations()
		else:
			lang = locale.getlocale()

			#Fix for non-POSIX-compliant systems (Windows et al.).
			if os.getenv('LANG') is None:
				lang = locale.getdefaultlocale()

				if lang[0]:
					os.environ['LANG'] = lang[0]

			if lang[0] is not None:
				filename = basedir.get_basedir() + "/translations/messages_%s.mo" % lang[0][0:2]

				try:
					__translation__ = gettext.GNUTranslations(open(filename, "rb"))
				except IOError:
					__translation__ = gettext.NullTranslations()
			else:
				print("WARNING: Localization disabled because the system language could not be determined.", file=sys.stderr)
				__translation__ = gettext.NullTranslations()

		__enabled__ = True
		__installed__ = True
		__translation__.install(True)
コード例 #3
0
ファイル: localization.py プロジェクト: zj2089/cowry
def init():
	global __installed__
	global __translation__

	if not __installed__:
		try:
			locale.setlocale(locale.LC_ALL, "")
		except locale.Error:
			__translation__ = gettext.NullTranslations()
		else:
			lang = locale.getlocale()

			#Fix for non-POSIX-compliant systems (Windows et al.).
			if os.getenv('LANG') is None:
				lang = locale.getdefaultlocale()
				os.environ['LANG'] = lang[0]

			filename = basedir.get_basedir() + "/translations/messages_%s.mo" % lang[0][0:2]

			try:
				__translation__ = gettext.GNUTranslations(open(filename, "rb"))
			except IOError:
				__translation__ = gettext.NullTranslations()

		__installed__ = True
		__translation__.install(True)
コード例 #4
0
ファイル: format.py プロジェクト: xtrasmal/gitinspector
def output_header():
    if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
        base = basedir.get_basedir()
        html_header = __output_html_template__(base + "/html/html.header")
        tablesorter_js = __get_zip_file_content__(
            "jquery.tablesorter.min.js",
            "/html/jquery.tablesorter.min.js.zip").encode(
                "latin-1", "replace")
        tablesorter_js = tablesorter_js.decode("utf-8", "ignore")
        flot_js = __get_zip_file_content__("jquery.flot.js")
        pie_js = __get_zip_file_content__("jquery.flot.pie.js")
        resize_js = __get_zip_file_content__("jquery.flot.resize.js")

        logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
        logo = logo_file.read()
        logo_file.close()
        logo = base64.b64encode(logo)

        if __selected_format__ == "htmlembedded":
            jquery_js = ">" + __get_zip_file_content__("jquery.js")
        else:
            jquery_js = " src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\">"

        print(
            html_header.format(
                title=_("Repository statistics for {0}").format(
                    os.path.basename(basedir.get_basedir_git())),
                jquery=jquery_js,
                jquery_tablesorter=tablesorter_js,
                jquery_flot=flot_js,
                jquery_flot_pie=pie_js,
                jquery_flot_resize=resize_js,
                logo=logo.decode("utf-8", "replace"),
                logo_text=_(
                    "The output has been generated by {0} {1}. The statistical analysis tool"
                    " for git repositories.").
                format(
                    "<a href=\"https://gitinspector.googlecode.com\">gitinspector</a>",
                    version.__version__),
                repo_text=
                _("Statistical information for the repository '{0}' was gathered on {1}."
                  ).format(os.path.basename(basedir.get_basedir_git()),
                           localization.get_date()),
                show_minor_authors=_("Show minor authors"),
                hide_minor_authors=_("Hide minor authors"),
                show_minor_rows=_("Show rows with minor work"),
                hide_minor_rows=_("Hide rows with minor work")))
    elif __selected_format__ == "xml":
        print("<gitinspector>")
        print("\t<version>" + version.__version__ + "</version>")
        print("\t<repository>" + os.path.basename(basedir.get_basedir_git()) +
              "</repository>")
        print("\t<report-date>" + time.strftime("%Y/%m/%d") + "</report-date>")
    else:
        print(
            textwrap.fill(_(
                "Statistical information for the repository '{0}' was gathered on {1}."
            ).format(os.path.basename(basedir.get_basedir_git()),
                     localization.get_date()),
                          width=terminal.get_size()[0]))
コード例 #5
0
def init():
	global __enabled__
	global __installed__
	global __translation__

	if not __installed__:
		try:
			locale.setlocale(locale.LC_ALL, "")
		except locale.Error:
			__translation__ = gettext.NullTranslations()
		else:
			lang = locale.getlocale()

			#Fix for non-POSIX-compliant systems (Windows et al.).
			if os.getenv('LANG') is None:
				lang = locale.getdefaultlocale()

				if lang[0]:
					os.environ['LANG'] = lang[0]

			if lang[0] is not None:
				filename = basedir.get_basedir() + "/translations/messages_%s.mo" % lang[0][0:2]

				try:
					__translation__ = gettext.GNUTranslations(open(filename, "rb"))
				except IOError:
					__translation__ = gettext.NullTranslations()
			else:
				print("WARNING: Localization disabled because the system language could not be determined.", file=sys.stderr)
				__translation__ = gettext.NullTranslations()

		__enabled__ = True
		__installed__ = True
		__translation__.install(True)
コード例 #6
0
ファイル: format.py プロジェクト: marham/gitinspector
def output_footer():
	if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
		base = basedir.get_basedir()
		html_footer = __output_html_template__(base + "/html/html.footer")
		print(html_footer)
	elif __selected_format__ == "xml":
		print("</gitinspector>")
コード例 #7
0
ファイル: format.py プロジェクト: xtrasmal/gitinspector
def output_footer():
    if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
        base = basedir.get_basedir()
        html_footer = __output_html_template__(base + "/html/html.footer")
        print(html_footer)
    elif __selected_format__ == "xml":
        print("</gitinspector>")
コード例 #8
0
ファイル: format.py プロジェクト: MattHardcastle/gitinspector
def output_header():
    if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
        base = basedir.get_basedir()
        html_header = __output_html_template__(base + "/html/html.header")
        tablesorter_js = __get_zip_file_content__("jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip")
        flot_js = __get_zip_file_content__("jquery.flot.js")
        pie_js = __get_zip_file_content__("jquery.flot.pie.js")
        resize_js = __get_zip_file_content__("jquery.flot.resize.js")

        logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
        logo = logo_file.read()
        logo_file.close()
        logo = base64.b64encode(logo)

        if __selected_format__ == "htmlembedded":
            jquery_js = ">" + __get_zip_file_content__("jquery.js")
        else:
            jquery_js = ' src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">'

        print(
            html_header.format(
                title=_("Repository statistics for {0}").format(os.path.basename(basedir.get_basedir_git())),
                jquery=jquery_js,
                jquery_tablesorter=tablesorter_js,
                jquery_flot=flot_js,
                jquery_flot_pie=pie_js,
                jquery_flot_resize=resize_js,
                logo=logo.decode("utf-8", "replace"),
                logo_text=_(
                    "The output has been generated by {0} {1}. The statistical analysis tool" " for git repositories."
                ).format('<a href="http://gitinspector.googlecode.com">gitinspector</a>', version.__version__),
                repo_text=_("Statistical information for the repository '{0}' was gathered on {1}.").format(
                    os.path.basename(basedir.get_basedir_git()), localization.get_date()
                ),
                show_minor_authors=_("Show minor authors"),
                hide_minor_authors=_("Hide minor authors"),
                show_minor_rows=_("Show rows with minor work"),
                hide_minor_rows=_("Hide rows with minor work"),
            )
        )
    elif __selected_format__ == "xml":
        print("<gitinspector>")
        print("\t<version>" + version.__version__ + "</version>")
        print("\t<repository>" + os.path.basename(basedir.get_basedir_git()) + "</repository>")
        print("\t<report-date>" + time.strftime("%Y/%m/%d") + "</report-date>")
    else:
        print(
            textwrap.fill(
                _("Statistical information for the repository '{0}' was gathered on {1}.").format(
                    os.path.basename(basedir.get_basedir_git()), localization.get_date()
                ),
                width=terminal.get_size()[0],
            )
        )
def output_header():
	if __selected_format__ == "html":
		base = basedir.get_basedir()
		html_header = __output_html_template__(base + "/html/html.header")
		jquery_js = __get_zip_file_content__("jquery.js")
		tablesorter_js = __get_zip_file_content__("jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip")
		flot_js = __get_zip_file_content__("jquery.flot.js")
		pie_js = __get_zip_file_content__("jquery.flot.pie.js")

		logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
		logo = logo_file.read()
		logo_file.close()
		logo = base64.b64encode(logo)

		print(html_header.format(version.__version__, jquery_js, tablesorter_js, flot_js, pie_js, logo.decode("utf-8", "replace")))
	elif __selected_format__ == "xml":
		print("<gitinspector>")
		print("\t<version>" + version.__version__ + "</version>")
コード例 #10
0
ファイル: format.py プロジェクト: NoodleTime125/CodeMetro
def output_header():
    if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
        base = basedir.get_basedir()
        html_header = __output_html_template__(base + "/html/html.header")
        tablesorter_js = __get_zip_file_content__(
            "jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip")
        flot_js = __get_zip_file_content__("jquery.flot.js")
        pie_js = __get_zip_file_content__("jquery.flot.pie.js")
        resize_js = __get_zip_file_content__("jquery.flot.resize.js")

        logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
        logo = logo_file.read()
        logo_file.close()
        logo = base64.b64encode(logo)

        if __selected_format__ == "htmlembedded":
            jquery_js = ">" + __get_zip_file_content__("jquery.js")
        else:
            jquery_js = " src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\">"

        print(
            html_header.format(
                version=version.__version__,
                jquery=jquery_js,
                jquery_tablesorter=tablesorter_js,
                jquery_flot=flot_js,
                jquery_flot_pie=pie_js,
                jquery_flot_resize=resize_js,
                logo=logo.decode("utf-8", "replace"),
                logo_text=_(
                    "The output has been generated by {0}; the statistical analysis tool"
                    " for git repositories.").
                format(
                    "<a href=\"http://gitinspector.googlecode.com\">gitinspector</a>"
                ),
                show_minor_authors=_("Show minor authors"),
                hide_minor_authors=_("Hide minor authors"),
                show_minor_rows=_("Show rows with minor work"),
                hide_minor_rows=_("Hide rows with minor work")))
    elif __selected_format__ == "xml":
        print("<gitinspector>")
        print("\t<version>" + version.__version__ + "</version>")
def output_header():
    if __selected_format__ == "html":
        base = basedir.get_basedir()
        html_header = __output_html_template__(base + "/html/html.header")
        jquery_js = __get_zip_file_content__("jquery.js")
        tablesorter_js = __get_zip_file_content__(
            "jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip")
        flot_js = __get_zip_file_content__("jquery.flot.js")
        pie_js = __get_zip_file_content__("jquery.flot.pie.js")

        logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
        logo = logo_file.read()
        logo_file.close()
        logo = base64.b64encode(logo)

        print(
            html_header.format(version.__version__, jquery_js,
                               tablesorter_js, flot_js, pie_js,
                               logo.decode("utf-8", "replace")))
    elif __selected_format__ == "xml":
        print("<gitinspector>")
        print("\t<version>" + version.__version__ + "</version>")
コード例 #12
0
def output_header():
	if __selected_format__ == "html" or __selected_format__ == "htmlembedded":
		base = basedir.get_basedir()
		html_header = __output_html_template__(base + "/html/html.header")
		tablesorter_js = __get_zip_file_content__("jquery.tablesorter.min.js", "/html/jquery.tablesorter.min.js.zip")
		flot_js = __get_zip_file_content__("jquery.flot.js")
		pie_js = __get_zip_file_content__("jquery.flot.pie.js")
		resize_js = __get_zip_file_content__("jquery.flot.resize.js")

		logo_file = open(base + "/html/gitinspector_piclet.png", "rb")
		logo = logo_file.read()
		logo_file.close()
		logo = base64.b64encode(logo)

		if __selected_format__ == "htmlembedded":
			jquery_js = ">" + __get_zip_file_content__("jquery.js")
		else:
			jquery_js = " src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\">"

		print(html_header.format(version = version.__version__,
		                         jquery = jquery_js,
		                         jquery_tablesorter = tablesorter_js,
		                         jquery_flot = flot_js,
		                         jquery_flot_pie = pie_js,
		                         jquery_flot_resize = resize_js,
		                         logo = logo.decode("utf-8", "replace"),
		                         logo_text = _("The output has been generated by {0}; the statistical analysis tool"
		                                       " for git repositories.").format(
					               "<a href=\"http://gitinspector.googlecode.com\">gitinspector</a>"),
		                         show_minor_authors = _("Show minor authors"),
		                         hide_minor_authors = _("Hide minor authors"),
		                         show_minor_rows = _("Show rows with minor work"),
		                         hide_minor_rows = _("Hide rows with minor work")))
	elif __selected_format__ == "xml":
		print("<gitinspector>")
		print("\t<version>" + version.__version__ + "</version>")
コード例 #13
0
ファイル: format.py プロジェクト: NoodleTime125/CodeMetro
def __get_zip_file_content__(name, file_name="/html/flot.zip"):
    zip_file = zipfile.ZipFile(basedir.get_basedir() + file_name, "r")
    content = zip_file.read(name)
    zip_file.close()
    return content.decode("utf-8", "replace")
コード例 #14
0
ファイル: format.py プロジェクト: marham/gitinspector
def __get_zip_file_content__(name, file_name="/html/flot.zip"):
	zip_file = zipfile.ZipFile(basedir.get_basedir() + file_name, "r")
	content = zip_file.read(name)
	zip_file.close()
	return content.decode("utf-8", "replace")