コード例 #1
0
ファイル: blame.py プロジェクト: Eric--/cowry
	def __init__(self, hard):
		self.blames = {}
		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout
		lines = ls_tree_r.readlines()

		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()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				if not missing.add(row):
					blame_string = "git blame -w {0} ".format("-C -C -M" if hard else "") + \
					               interval.get_since() + interval.get_ref() + " -- \"" + row + "\""
					thread = BlameThread(blame_string, FileDiff.get_extension(row), self.blames, row.strip())
					thread.daemon = True
					thread.start()

					if hard:
						Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
コード例 #2
0
    def __init__(self, hard, useweeks, changes):
        self.blames = {}
        ls_tree_r = subprocess.Popen(
            ["git", "ls-tree", "--name-only", "-r",
             interval.get_ref()],
            bufsize=1,
            stdout=subprocess.PIPE).stdout
        lines = ls_tree_r.readlines()
        ls_tree_r.close()

        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()

            if FileDiff.is_valid_extension(row) and not filtering.set_filtered(
                    FileDiff.get_filename(row)):
                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())
                thread.daemon = True
                thread.start()

                if hard:
                    Blame.output_progress(i, len(lines))

        # Make sure all threads have completed.
        for i in range(0, NUM_THREADS):
            __thread_lock__.acquire()
コード例 #3
0
ファイル: metrics.py プロジェクト: TradeHero/gitinspector
    def __init__(self):
        self.eloc = {}
        self.cyclomatic_complexity = {}
        self.cyclomatic_complexity_density = {}

        ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
                                     stdout=subprocess.PIPE).stdout

        for i in ls_tree_r.readlines():
            i = i.strip().decode("unicode_escape", "ignore")
            i = i.encode("latin-1", "replace")
            i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
                file_r = subprocess.Popen("git show " + interval.get_ref() + ":" + i.strip(), shell=True, bufsize=1,
                                          stdout=subprocess.PIPE).stdout.readlines()

                extension = FileDiff.get_extension(i)
                lines = MetricsLogic.get_eloc(file_r, extension)
                cc = MetricsLogic.get_cyclomatic_complexity(file_r, extension)

                if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
                    self.eloc[i.strip()] = lines

                if METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD < cc:
                    self.cyclomatic_complexity[i.strip()] = cc

                if lines > 0 and METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD < cc / float(lines):
                    self.cyclomatic_complexity_density[i.strip()] = cc / float(lines)
コード例 #4
0
ファイル: blame.py プロジェクト: marham/gitinspector
	def __init__(self, hard, useweeks, changes):
		self.blames = {}
		ls_tree_r = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1,
		                             stdout=subprocess.PIPE).stdout
		lines = ls_tree_r.readlines()
		ls_tree_r.close()

		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()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				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())
				thread.daemon = True
				thread.start()

				if hard:
					Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
コード例 #5
0
	def __init__(self, hard):
		self.blames = {}
		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout
		lines = ls_tree_r.readlines()

		for i, row in enumerate(lines):
			row = codecs.getdecoder("unicode_escape")(row.strip())[0]
			row = row.encode("latin-1", "replace")
			row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				if not missing.add(row):
					blame_string = "git blame -w {0} ".format("-C -C -M" if hard else "") + \
					               interval.get_since() + interval.get_ref() + " -- \"" + row + "\""
					thread = BlameThread(blame_string, FileDiff.get_extension(row), self.blames, row.strip())
					thread.daemon = True
					thread.start()

					if hard:
						Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
コード例 #6
0
ファイル: metrics.py プロジェクト: romanlevin/gitinspector
	def __init__(self):
		self.eloc = {}
		self.cyclomatic_complexity = {}
		self.cyclomatic_complexity_density = {}

		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout

		for i in ls_tree_r.readlines():
			i = i.strip().decode("unicode_escape", "ignore")
			i = i.encode("latin-1", "replace")
			i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
				file_r = subprocess.Popen("git show " + interval.get_ref() + ":\"{0}\"".format(i.strip()),
				                          shell=True, bufsize=1, stdout=subprocess.PIPE).stdout.readlines()

				extension = FileDiff.get_extension(i)
				lines = MetricsLogic.get_eloc(file_r, extension)
				cycc = MetricsLogic.get_cyclomatic_complexity(file_r, extension)

				if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
					self.eloc[i.strip()] = lines

				if METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD < cycc:
					self.cyclomatic_complexity[i.strip()] = cycc

				if lines > 0 and METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD < cycc / float(lines):
					self.cyclomatic_complexity_density[i.strip()] = cycc / float(lines)
コード例 #7
0
ファイル: metrics.py プロジェクト: davidfraser/gitinspector
	def output_html(self):
		metrics_logic = MetricsLogic()
		metrics_xml = "<div><div class=\"box\" id=\"metrics\">"

		if not metrics_logic.eloc and not metrics_logic.cyclomatic_complexity and not metrics_logic.cyclomatic_complexity_density:
			metrics_xml += "<p>" + _(METRICS_MISSING_INFO_TEXT) + ".</p>"

		if metrics_logic.eloc:
			metrics_xml += "<div><h4>" + _(ELOC_INFO_TEXT) + ".</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.eloc.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(__metric_eloc__[FileDiff.get_extension(i[1])], i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1} estimated lines of code)").format(i[1], str(i[0])) + "</div>"
			metrics_xml += "</div>"

		if metrics_logic.cyclomatic_complexity:
			metrics_xml += "<div><h4>" +  _(CYCLOMATIC_COMPLEXITY_TEXT) + "</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD, i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1} in cyclomatic complexity)").format(i[1], str(i[0])) + "</div>"
			metrics_xml += "</div>"

		if metrics_logic.cyclomatic_complexity_density:
			metrics_xml += "<div><h4>" +  _(CYCLOMATIC_COMPLEXITY_DENSITY_TEXT) + "</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity_density.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD, i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1:.3f} in cyclomatic complexity density)").format(i[1], i[0]) + "</div>"
			metrics_xml += "</div>"

		metrics_xml += "</div></div>"
		print(metrics_xml)
コード例 #8
0
ファイル: metrics.py プロジェクト: romanlevin/gitinspector
	def output_html(self):
		metrics_logic = MetricsLogic()
		metrics_xml = "<div><div class=\"box\" id=\"metrics\">"

		if not metrics_logic.eloc and not metrics_logic.cyclomatic_complexity and not metrics_logic.cyclomatic_complexity_density:
			metrics_xml += "<p>" + _(METRICS_MISSING_INFO_TEXT) + ".</p>"

		if metrics_logic.eloc:
			metrics_xml += "<div><h4>" + _(ELOC_INFO_TEXT) + ".</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.eloc.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(__metric_eloc__[FileDiff.get_extension(i[1])], i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1} estimated lines of code)").format(i[1], str(i[0])) + "</div>"
			metrics_xml += "</div>"

		if metrics_logic.cyclomatic_complexity:
			metrics_xml += "<div><h4>" +  _(CYCLOMATIC_COMPLEXITY_TEXT) + "</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD, i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1} in cyclomatic complexity)").format(i[1], str(i[0])) + "</div>"
			metrics_xml += "</div>"

		if metrics_logic.cyclomatic_complexity_density:
			metrics_xml += "<div><h4>" +  _(CYCLOMATIC_COMPLEXITY_DENSITY_TEXT) + "</h4>"
			for num, i in enumerate(sorted(set([(j, i) for (i, j) in metrics_logic.cyclomatic_complexity_density.items()]), reverse = True)):
				metrics_xml += "<div class=\"" + __get_metrics_score__(METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD, i[0]) + \
				               (" odd\">" if num % 2 == 1 else "\">") + \
				               _("{0} ({1:.3f} in cyclomatic complexity density)").format(i[1], i[0]) + "</div>"
			metrics_xml += "</div>"

		metrics_xml += "</div></div>"
		print(metrics_xml)
	def __init__(self):
		self.eloc = {}
		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r HEAD", shell=True, bufsize=1, stdout=subprocess.PIPE).stdout

		for i in ls_tree_r.readlines():
			i = codecs.getdecoder("unicode_escape")(i.strip())[0]
			i = i.encode("latin-1", "replace")
			i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
				if not missing.add(i):
					file_r = open(i.strip(), "rb")
					extension = FileDiff.get_extension(i)
					lines = MetricsLogic.get_eloc(file_r, extension)

					if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
						self.eloc[i.strip()] = lines
コード例 #10
0
    def __init__(self):
        self.eloc = {}
        ls_tree_r = subprocess.Popen(
            "git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1, stdout=subprocess.PIPE
        ).stdout

        for i in ls_tree_r.readlines():
            i = i.strip().decode("unicode_escape", "ignore")
            i = i.encode("latin-1", "replace")
            i = i.decode("utf-8", "replace").strip('"').strip("'").strip()

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
                file_r = subprocess.Popen(
                    "git show " + interval.get_ref() + ":" + i.strip(), shell=True, bufsize=1, stdout=subprocess.PIPE
                ).stdout

                extension = FileDiff.get_extension(i)
                lines = MetricsLogic.get_eloc(file_r, extension)

                if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
                    self.eloc[i.strip()] = lines
コード例 #11
0
    def __init__(self):
        self.eloc = {}
        ls_tree_r = subprocess.Popen("git ls-tree --name-only -r HEAD",
                                     shell=True,
                                     bufsize=1,
                                     stdout=subprocess.PIPE).stdout

        for i in ls_tree_r.readlines():
            i = codecs.getdecoder("unicode_escape")(i.strip())[0]
            i = i.encode("latin-1", "replace")
            i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(
                    FileDiff.get_filename(i)):
                if not missing.add(i):
                    file_r = open(i.strip(), "rb")
                    extension = FileDiff.get_extension(i)
                    lines = MetricsLogic.get_eloc(file_r, extension)

                    if __metric_eloc__.get(
                            extension, None
                    ) != None and __metric_eloc__[extension] < lines:
                        self.eloc[i.strip()] = lines
コード例 #12
0
ファイル: blame.py プロジェクト: RaginBajin/dotfiles
	def __init__(self, repo, hard):
		self.blames = {}
		f = sysrun.run(repo, "git ls-tree --name-only -r HEAD")

		for i in f.readlines():
			if FileDiff.is_valid_extension(i):
				g = sysrun.run(repo, "git blame {0} ".format("-C -M" if hard else "") + i.strip())

				for j in g.readlines():
					author = Blame.get_author(j)

					if self.blames.get(author, None) == None:
						self.blames[author] = 0

					self.blames[author] += 1
コード例 #13
0
ファイル: blame.py プロジェクト: marfarma/dotfiles-2
    def __init__(self, repo, hard):
        self.blames = {}
        f = sysrun.run(repo, "git ls-tree --name-only -r HEAD")

        for i in f.readlines():
            if FileDiff.is_valid_extension(i):
                g = sysrun.run(
                    repo, "git blame {0} ".format("-C -M" if hard else "") +
                    i.strip())

                for j in g.readlines():
                    author = Blame.get_author(j)

                    if self.blames.get(author, None) == None:
                        self.blames[author] = 0

                    self.blames[author] += 1