diff --git a/.pylintrc b/.pylintrc
index 61c8c24..af32a7f 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -3,7 +3,7 @@ include-ids=yes
comment=yes
[MESSAGES CONTROL]
-disable=C0111,W0232,W0603,W0702
+disable=C0111,R0801,W0232,W0603,W0702
[DESIGN]
diff --git a/blame.py b/blame.py
index 6d82a35..fa4f8d7 100644
--- a/blame.py
+++ b/blame.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
from changes import FileDiff
import comment
import filtering
@@ -100,7 +101,7 @@ class Blame:
def output_progress(pos, length):
if sys.stdout.isatty():
terminal.clear_row()
- print "\bChecking how many rows belong to each author (Progress): " + str(100 * pos / length) + "%",
+ print("\bChecking how many rows belong to each author (Progress): {0:.0f}%".format(100 * pos / length), end="")
sys.stdout.flush()
@staticmethod
@@ -138,16 +139,16 @@ def get(hard):
return __blame__
def output(hard):
- print ""
+ print("")
get(hard)
if hard and sys.stdout.isatty():
terminal.clear_row()
- print "{0}Below is the number of rows from each author that have survived and".format("\b" if sys.stdout.isatty() else "")
- print "are still intact in the current revision:\n"
+ print("Below are the number of rows from each author that have survived and")
+ print("are still intact in the current revision:\n")
terminal.printb("Author".ljust(21) + "Rows".rjust(10) + "% in comments".rjust(16))
for i in sorted(__blame__.get_summed_blames().items()):
- print i[0].ljust(20)[0:20],
- print str(i[1].rows).rjust(10),
- print "{0:.2f}".format(100.0 * i[1].comments / i[1].rows).rjust(15)
+ print(i[0].ljust(20)[0:20], end=" ")
+ print(str(i[1].rows).rjust(10), end=" ")
+ print("{0:.2f}".format(100.0 * i[1].comments / i[1].rows).rjust(15))
diff --git a/changes.py b/changes.py
index da6341b..8b39d3b 100644
--- a/changes.py
+++ b/changes.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import extensions
import filtering
import os
@@ -154,18 +155,18 @@ def output(hard):
total_changes += authorinfo_list.get(i).deletions
if authorinfo_list:
- print "The following historical commit information, by author, was found in the"
- print "repository:\n"
+ print("The following historical commit information, by author, was found in")
+ print("the repository:\n")
terminal.printb("Author".ljust(21) + "Commits " + "Insertions " + "Deletions " + "% of changes")
for i in sorted(authorinfo_list):
authorinfo = authorinfo_list.get(i)
percentage = 0 if total_changes == 0 else (authorinfo.insertions + authorinfo.deletions) / total_changes * 100
- print i.ljust(20)[0:20],
- print str(authorinfo.commits).rjust(7),
- print str(authorinfo.insertions).rjust(12),
- print str(authorinfo.deletions).rjust(11),
- print "{0:.2f}".format(percentage).rjust(14)
+ print(i.ljust(20)[0:20], end=" ")
+ print(str(authorinfo.commits).rjust(7), end=" ")
+ print(str(authorinfo.insertions).rjust(12), end=" ")
+ print(str(authorinfo.deletions).rjust(11), end=" ")
+ print("{0:.2f}".format(percentage).rjust(14))
else:
- print "No commited files with the specified extensions were found."
+ print("No commited files with the specified extensions were found.")
diff --git a/extensions.py b/extensions.py
index d3e131a..ff18903 100644
--- a/extensions.py
+++ b/extensions.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import terminal
__default_extensions__ = ["java", "c", "cpp", "h", "hpp", "py", "glsl", "rb", "js", "sql"]
@@ -36,11 +37,12 @@ def add_located(string):
def output():
if __located_extensions__:
- print "\nThe extensions below were found in the repository history"
- print "(extensions used during statistical analysis are marked):"
+ print("\nThe extensions below were found in the repository history")
+ print("(extensions used during statistical analysis are marked):")
for i in __located_extensions__:
if i in __extensions__:
- print "[" + terminal.__bold__ + i + terminal.__normal__ + "]",
+ print("[" + terminal.__bold__ + i + terminal.__normal__ + "]", end=" ")
else:
- print i,
+ print (i, end=" ")
+ print("")
diff --git a/filtering.py b/filtering.py
index 39db528..9e3e8ec 100644
--- a/filtering.py
+++ b/filtering.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import terminal
__filters__ = []
@@ -43,9 +44,9 @@ def set_filtered(file_name):
def output():
if __filtered_files__:
- print "\nThe following files were excluded from the statistics due to the"
- print "specified exclusion patterns:"
+ print("\nThe following files were excluded from the statistics due to the")
+ print("specified exclusion patterns:")
for i in __filtered_files__:
(width, _) = terminal.get_size()
- print "...%s" % i[-width+3:] if len(i) > width else i
+ print("...%s" % i[-width+3:] if len(i) > width else i)
diff --git a/gitinspector.py b/gitinspector.py
index 5ff5139..f1e4614 100755
--- a/gitinspector.py
+++ b/gitinspector.py
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import blame
import changes
import extensions
@@ -77,9 +78,9 @@ if __name__ == "__main__":
__opts__, __args__ = getopt.gnu_getopt(sys.argv[1:], "cf:hHlmrTwx:", ["checkout-missing", "exclude=",
"file-types=", "hard", "help", "list-file-types", "metrics",
"responsibilities", "tda367", "timeline", "version"])
- except getopt.error, msg:
- print sys.argv[0], "\b:", msg
- print "Try `", sys.argv[0], "--help' for more information."
+ except getopt.error as msg:
+ print(sys.argv[0], "\b:", msg)
+ print("Try `", sys.argv[0], "--help' for more information.")
sys.exit(2)
for o, a in __opts__:
if o in("-c", "--checkout-missing"):
diff --git a/help.py b/help.py
index 2887886..25ff51c 100644
--- a/help.py
+++ b/help.py
@@ -55,8 +55,9 @@ more information.
gitinspector requires that the git executable is available in your PATH.
Report gitinspector bugs to gitinspector@ejwa.se."""
+from __future__ import print_function
from extensions import __default_extensions__
import sys
def output():
- print __doc__.format(sys.argv[0], ",".join(__default_extensions__))
+ print(__doc__.format(sys.argv[0], ",".join(__default_extensions__)))
diff --git a/metrics.py b/metrics.py
index 71b6ba1..397d725 100644
--- a/metrics.py
+++ b/metrics.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
from changes import FileDiff
import comment
import filtering
@@ -61,8 +62,8 @@ def output():
metrics = Metrics()
if not metrics.eloc:
- print "\nNo metrics violations were found in the repository."
+ print("\nNo metrics violations were found in the repository.")
else:
- print "\nThe following files are suspiciously big (in order of severity):"
+ print("\nThe following files are suspiciously big (in order of severity):")
for i in sorted(set([(j, i) for (i, j) in metrics.eloc.items()]), reverse = True):
- print i[1] + " (" + str(i[0]) + " eloc)"
+ print(i[1] + " (" + str(i[0]) + " eloc)")
diff --git a/missing.py b/missing.py
index c23d307..1115790 100644
--- a/missing.py
+++ b/missing.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import os
import terminal
@@ -38,10 +39,10 @@ def set_checkout_missing(checkout):
def output():
if __missing_files__:
- print "\nThe following files were missing in the repository and were therefore not"
- print "completely included in the statistical analysis. To include them, you can"
- print "either checkout manually using git or use the -c option in gitinspector:"
+ print("\nThe following files were missing in the repository and were therefore not")
+ print("completely included in the statistical analysis. To include them, you can")
+ print("either checkout manually using git or use the -c option in gitinspector:")
for missing in __missing_files__:
(width, _) = terminal.get_size()
- print "...%s" % missing[-width+3:] if len(missing) > width else missing
+ print("...%s" % missing[-width+3:] if len(missing) > width else missing)
diff --git a/responsibilities.py b/responsibilities.py
index 642b9c5..385a5b7 100644
--- a/responsibilities.py
+++ b/responsibilities.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import blame
import terminal
@@ -37,20 +38,20 @@ class Responsibilities:
return sorted(author_blames.items())
def output(hard):
- print "\nThe following repsonsibilties, by author, were found in the current"
- print "revision of the repository (comments are exluded from the line count,"
- print "if possible):"
+ print("\nThe following repsonsibilties, by author, were found in the current")
+ print("revision of the repository (comments are exluded from the line count,")
+ print("if possible):")
for i in sorted(set(i[0] for i in blame.get(hard).blames)):
- print "\n" + i, "is mostly responsible for:"
+ print("\n" + i, "is mostly responsible for:")
responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(hard, i)), reverse=True)
for j, entry in enumerate(responsibilities):
(width, _) = terminal.get_size()
width -= 7
- print str(entry[0]).rjust(6),
- print "...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1]
+ print(str(entry[0]).rjust(6), end=" ")
+ print("...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1])
if j >= 9:
break
diff --git a/terminal.py b/terminal.py
index 22a7958..6fd8c24 100644
--- a/terminal.py
+++ b/terminal.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import os
import platform
import sys
@@ -72,7 +73,7 @@ def __get_size_linux__():
return int(size[1]), int(size[0])
def clear_row():
- print "\b" * 200,
+ print("\b" * 200, end="")
def skip_escapes(skip):
if skip:
@@ -82,7 +83,7 @@ def skip_escapes(skip):
__normal__ = ""
def printb(string):
- print __bold__ + string + __normal__
+ print(__bold__ + string + __normal__)
def get_size():
if sys.stdout.isatty():
diff --git a/timeline.py b/timeline.py
index 94f412f..403617b 100644
--- a/timeline.py
+++ b/timeline.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see .
+from __future__ import print_function
import datetime
import terminal
@@ -90,31 +91,32 @@ class TimelineData:
return self.entries.get((author, period), None) != None
def __output_row__(timeline_data, periods, names):
- print "\n" + terminal.__bold__ + "Author".ljust(20),
+ print("\n" + terminal.__bold__ + "Author".ljust(20), end=" ")
for period in periods:
- print period.rjust(10),
+ print(period.rjust(10), end=" ")
- print terminal.__normal__
+ print(terminal.__normal__)
for name in names:
- print name.ljust(20)[0:20],
+ print(name.ljust(20)[0:20], end=" ")
for period in periods:
multiplier = timeline_data.get_multiplier(period, 9)
signs = timeline_data.get_author_signs_in_period(name, period, multiplier)
signs_str = (signs[1] * "-" + signs[0] * "+")
- print ("." if timeline_data.is_author_in_period(period, name) and len(signs_str) == 0 else signs_str).rjust(10),
- print ""
+ print (("." if timeline_data.is_author_in_period(period, name) and
+ len(signs_str) == 0 else signs_str).rjust(10), end=" ")
+ print("")
def output(changes, useweeks):
if changes.get_commits():
- print "\nThe following history timeline has been gathered from the repository:"
+ print("\nThe following history timeline has been gathered from the repository:")
timeline_data = TimelineData(changes, useweeks)
periods = timeline_data.get_periods()
names = timeline_data.get_authors()
(width, _) = terminal.get_size()
- max_periods_per_row = (width - 21) / 11
+ max_periods_per_row = int((width - 21) / 11)
for i in range(0, len(periods), max_periods_per_row):
__output_row__(timeline_data, periods[i:i+max_periods_per_row], names)
diff --git a/version.py b/version.py
index 00d4039..8f47ec2 100644
--- a/version.py
+++ b/version.py
@@ -25,7 +25,9 @@ There is NO WARRANTY, to the extent permitted by law.
Written by Adam Waldenberg."""
+from __future__ import print_function
+
__version__ = "0.0.1"
def output():
- print __doc__.format(__version__)
+ print(__doc__.format(__version__))