The repository name and report date is now included in the generated text.

This commit is contained in:
Adam Waldenberg 2014-02-20 04:06:47 +01:00
parent 12e08daf72
commit 4e4d0a2ddb
4 changed files with 53 additions and 18 deletions

View File

@ -27,22 +27,29 @@ def get_basedir():
else:
return os.path.dirname(os.path.realpath(__file__))
__git_basedir__ = None
def get_basedir_git():
isbare = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
stdout=subprocess.PIPE).stdout
isbare = isbare.readlines()
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
absolute_path = ""
global __git_basedir__
if isbare:
absolute_path = subprocess.Popen("git rev-parse --git-dir", shell=True, bufsize=1,
stdout=subprocess.PIPE).stdout
else:
absolute_path = subprocess.Popen("git rev-parse --show-toplevel", shell=True, bufsize=1,
if not __git_basedir__:
isbare = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
stdout=subprocess.PIPE).stdout
isbare = isbare.readlines()
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
absolute_path = ""
if isbare:
absolute_path = subprocess.Popen("git rev-parse --git-dir", shell=True, bufsize=1,
stdout=subprocess.PIPE).stdout
else:
absolute_path = subprocess.Popen("git rev-parse --show-toplevel", shell=True, bufsize=1,
stdout=subprocess.PIPE).stdout
absolute_path = absolute_path.readlines()
if len(absolute_path) == 0:
sys.exit(_("Unable to determine absolute path of git repository."))
absolute_path = absolute_path.readlines()
if len(absolute_path) == 0:
sys.exit(_("Unable to determine absolute path of git repository."))
return absolute_path[0].decode("utf-8", "replace").strip()
__git_basedir__ = absolute_path[0].decode("utf-8", "replace").strip()
return __git_basedir__

View File

@ -1,6 +1,6 @@
# coding: utf-8
#
# Copyright © 2012-2013 Ejwa Software. All rights reserved.
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
#
# This file is part of gitinspector.
#
@ -19,10 +19,14 @@
from __future__ import print_function
from __future__ import unicode_literals
import localization
import version
import base64
import basedir
import os
import terminal
import textwrap
import time
import zipfile
__available_formats__ = ["html", "htmlembedded", "text", "xml"]
@ -88,6 +92,8 @@ def output_header():
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>"),
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"),
@ -95,6 +101,11 @@ def output_header():
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_footer():
if __selected_format__ == "html":

View File

@ -310,5 +310,5 @@
<body>
<div><div class="box logo">
<img src="data:image/png;base64,{logo}" />
<p>{logo_text}<p>
<p>{repo_text} {logo_text}</p>
</div></div>

View File

@ -1,6 +1,6 @@
# coding: utf-8
#
# Copyright © 2013 Ejwa Software. All rights reserved.
# Copyright © 2013-2014 Ejwa Software. All rights reserved.
#
# This file is part of gitinspector.
#
@ -17,12 +17,15 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import unicode_literals
import basedir
import gettext
import locale
import os
import time
__enabled__ = False
__installed__ = False
__translation__ = None
@ -31,6 +34,7 @@ def N_(message):
return message
def init():
global __enabled__
global __installed__
global __translation__
@ -54,13 +58,26 @@ def init():
except IOError:
__translation__ = gettext.NullTranslations()
__enabled__ = True
__installed__ = True
__translation__.install(True)
def get_date():
if __enabled__ and isinstance(__translation__, gettext.GNUTranslations):
return time.strftime("%x")
else:
return time.strftime("%Y/%m/%d")
def enable():
if __installed__ and type(__translation__) is not gettext.GNUTranslations:
if isinstance(__translation__, gettext.GNUTranslations):
__translation__.install(True)
global __enabled__
__enabled__ = True
def disable():
global __enabled__
__enabled__ = False
if __installed__:
gettext.NullTranslations().install(True)