Skip to content

Commit

Permalink
Replace 'row' with 'line' in whole code
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jun 1, 2016
1 parent af97d22 commit 21c85d9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
34 changes: 17 additions & 17 deletions gitinspector/blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
NUM_THREADS = multiprocessing.cpu_count()

class BlameEntry(object):
rows = 0
lines = 0
skew = 0 # Used when calculating average code age.
comments = 0

Expand Down Expand Up @@ -82,7 +82,7 @@ def __handle_blamechunk_content__(self, content):
self.blames[(author, self.filename)] = BlameEntry()

self.blames[(author, self.filename)].comments += comments
self.blames[(author, self.filename)].rows += 1
self.blames[(author, self.filename)].lines += 1

if (self.blamechunk_time - self.changes.first_commit_date).days > 0:
self.blames[(author, self.filename)].skew += ((self.changes.last_commit_date - self.blamechunk_time).days /
Expand All @@ -92,18 +92,18 @@ def __handle_blamechunk_content__(self, content):

def run(self):
git_blame_r = subprocess.Popen(self.blame_command, bufsize=1, stdout=subprocess.PIPE).stdout
rows = git_blame_r.readlines()
lines = git_blame_r.readlines()
git_blame_r.close()

self.__clear_blamechunk_info__()

#pylint: disable=W0201
for j in range(0, len(rows)):
row = rows[j].decode("utf-8", "replace").strip()
keyval = row.split(" ", 2)
for j in range(0, len(lines)):
line = lines[j].decode("utf-8", "replace").strip()
keyval = line.split(" ", 2)

if self.blamechunk_is_last:
self.__handle_blamechunk_content__(row)
self.__handle_blamechunk_content__(line)
self.__clear_blamechunk_info__()
elif keyval[0] == "boundary":
self.blamechunk_is_prior = True
Expand Down Expand Up @@ -132,18 +132,18 @@ def __init__(self, repo, hard, useweeks, changes):
if repo != None:
progress_text = "[%s] " % repo.name + progress_text

for i, row in enumerate(lines):
row = row.strip().decode("unicode_escape", "ignore")
row = row.encode("latin-1", "replace")
row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()
for i, line in enumerate(lines):
line = line.strip().decode("unicode_escape", "ignore")
line = line.encode("latin-1", "replace")
line = line.decode("utf-8", "replace").strip("\"").strip("'").strip()

if FileDiff.get_extension(row) in extensions.get_located() and FileDiff.is_valid_extension(row) and not \
filtering.set_filtered(FileDiff.get_filename(row)):
if FileDiff.get_extension(line) in extensions.get_located() and FileDiff.is_valid_extension(line) and not \
filtering.set_filtered(FileDiff.get_filename(line)):
blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \
(["-C", "-C", "-M"] if hard else []) +
[interval.get_since(), interval.get_ref(), "--", row])
thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row),
self.blames, row.strip())
[interval.get_since(), interval.get_ref(), "--", line])
thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(line),
self.blames, line.strip())
thread.daemon = True
thread.start()

Expand Down Expand Up @@ -192,7 +192,7 @@ def get_summed_blames(self):
if summed_blames.get(i[0][0], None) == None:
summed_blames[i[0][0]] = BlameEntry()

summed_blames[i[0][0]].rows += i[1].rows
summed_blames[i[0][0]].lines += i[1].lines
summed_blames[i[0][0]].skew += i[1].skew
summed_blames[i[0][0]].comments += i[1].comments

Expand Down
6 changes: 3 additions & 3 deletions gitinspector/html/html.header
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<script type="application/javascript">{jquery_flot_resize}</script>
<script type="application/javascript">
$(document).ready(function() {{
var row = 0;
var line = 0;
var MINOR_AUTHOR_PERCENTAGE = 1.00;
var isReversed = false;

var colorRows = function() {{
$(this).removeClass("odd");

if (row++ % 2 == 1) {{
if (line++ % 2 == 1) {{
$(this).addClass("odd");
}}

if(this == $(this).parent().find("tr:visible").get(-1)) {{
row = 0;
line = 0;
}}
}}

Expand Down
36 changes: 18 additions & 18 deletions gitinspector/output/blameoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def output_html(self):
total_blames = 0

for i in blames:
total_blames += i[1].rows
total_blames += i[1].lines

for i, entry in enumerate(blames):
work_percentage = str("{0:.2f}".format(100.0 * entry[1].rows / total_blames))
work_percentage = str("{0:.2f}".format(100.0 * entry[1].lines / total_blames))
blame_xml += "<tr " + ("class=\"odd\">" if i % 2 == 1 else ">")

if format.get_selected() == "html":
Expand All @@ -62,10 +62,10 @@ def output_html(self):
else:
blame_xml += "<td>" + entry[0] + "</td>"

blame_xml += "<td>" + str(entry[1].rows) + "</td>"
blame_xml += "<td>" + ("{0:.1f}".format(Blame.get_stability(entry[0], entry[1].rows, self.changes)) + "</td>")
blame_xml += "<td>" + "{0:.1f}".format(float(entry[1].skew) / entry[1].rows) + "</td>"
blame_xml += "<td>" + "{0:.2f}".format(100.0 * entry[1].comments / entry[1].rows) + "</td>"
blame_xml += "<td>" + str(entry[1].lines) + "</td>"
blame_xml += "<td>" + ("{0:.1f}".format(Blame.get_stability(entry[0], entry[1].lines, self.changes)) + "</td>")
blame_xml += "<td>" + "{0:.1f}".format(float(entry[1].skew) / entry[1].lines) + "</td>"
blame_xml += "<td>" + "{0:.2f}".format(100.0 * entry[1].comments / entry[1].lines) + "</td>"
blame_xml += "<td style=\"display: none\">" + work_percentage + "</td>"
blame_xml += "</tr>"
chart_data += "{{label: {0}, data: {1}}}".format(json.dumps(entry[0]), work_percentage)
Expand Down Expand Up @@ -104,12 +104,12 @@ def output_json(self):
name_json = "\t\t\t\t\"name\": \"" + i[0] + "\",\n"
email_json = "\t\t\t\t\"email\": \"" + author_email + "\",\n"
gravatar_json = "\t\t\t\t\"gravatar\": \"" + gravatar.get_url(author_email) + "\",\n"
rows_json = "\t\t\t\t\"lines\": " + str(i[1].rows) + ",\n"
stability_json = ("\t\t\t\t\"stability\": " + "{0:.1f}".format(Blame.get_stability(i[0], i[1].rows,
rows_json = "\t\t\t\t\"lines\": " + str(i[1].lines) + ",\n"
stability_json = ("\t\t\t\t\"stability\": " + "{0:.1f}".format(Blame.get_stability(i[0], i[1].lines,
self.changes)) + ",\n")
age_json = ("\t\t\t\t\"age\": " + "{0:.1f}".format(float(i[1].skew) / i[1].rows) + ",\n")
age_json = ("\t\t\t\t\"age\": " + "{0:.1f}".format(float(i[1].skew) / i[1].lines) + ",\n")
percentage_in_comments_json = ("\t\t\t\t\"percentage_in_comments\": " +
"{0:.2f}".format(100.0 * i[1].comments / i[1].rows) + "\n")
"{0:.2f}".format(100.0 * i[1].comments / i[1].lines) + "\n")
blame_json += ("{\n" + name_json + email_json + gravatar_json + rows_json + stability_json + age_json +
percentage_in_comments_json + "\t\t\t},")
else:
Expand All @@ -127,10 +127,10 @@ def output_text(self):

for i in sorted(self.blame.get_summed_blames().items()):
print(terminal.ljust(i[0], 20)[0:20 - terminal.get_excess_column_count(i[0])], end=" ")
print(str(i[1].rows).rjust(10), end=" ")
print("{0:.1f}".format(Blame.get_stability(i[0], i[1].rows, self.changes)).rjust(14), end=" ")
print("{0:.1f}".format(float(i[1].skew) / i[1].rows).rjust(12), end=" ")
print("{0:.2f}".format(100.0 * i[1].comments / i[1].rows).rjust(19))
print(str(i[1].lines).rjust(10), end=" ")
print("{0:.1f}".format(Blame.get_stability(i[0], i[1].lines, self.changes)).rjust(14), end=" ")
print("{0:.1f}".format(float(i[1].skew) / i[1].lines).rjust(12), end=" ")
print("{0:.2f}".format(100.0 * i[1].comments / i[1].lines).rjust(19))

def output_xml(self):
message_xml = "\t\t<message>" + _(BLAME_INFO_TEXT) + "</message>\n"
Expand All @@ -142,11 +142,11 @@ def output_xml(self):
name_xml = "\t\t\t\t<name>" + i[0] + "</name>\n"
email_xml = "\t\t\t\t<email>" + author_email + "</email>\n"
gravatar_xml = "\t\t\t\t<gravatar>" + gravatar.get_url(author_email) + "</gravatar>\n"
rows_xml = "\t\t\t\t<lines>" + str(i[1].rows) + "</lines>\n"
stability_xml = ("\t\t\t\t<stability>" + "{0:.1f}".format(Blame.get_stability(i[0], i[1].rows,
rows_xml = "\t\t\t\t<lines>" + str(i[1].lines) + "</lines>\n"
stability_xml = ("\t\t\t\t<stability>" + "{0:.1f}".format(Blame.get_stability(i[0], i[1].lines,
self.changes)) + "</stability>\n")
age_xml = ("\t\t\t\t<age>" + "{0:.1f}".format(float(i[1].skew) / i[1].rows) + "</age>\n")
percentage_in_comments_xml = ("\t\t\t\t<percentage-in-comments>" + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) +
age_xml = ("\t\t\t\t<age>" + "{0:.1f}".format(float(i[1].skew) / i[1].lines) + "</age>\n")
percentage_in_comments_xml = ("\t\t\t\t<percentage-in-comments>" + "{0:.2f}".format(100.0 * i[1].comments / i[1].lines) +
"</percentage-in-comments>\n")
blame_xml += ("\t\t\t<author>\n" + name_xml + email_xml + gravatar_xml + rows_xml + stability_xml +
age_xml + percentage_in_comments_xml + "\t\t\t</author>\n")
Expand Down
2 changes: 1 addition & 1 deletion gitinspector/responsibilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get(blame, author_name):

for i in blame.blames.items():
if author_name == i[0][0]:
total_rows = i[1].rows - i[1].comments
total_rows = i[1].lines - i[1].comments
if total_rows > 0:
author_blames[i[0][1]] = total_rows

Expand Down

0 comments on commit 21c85d9

Please sign in to comment.