Example #1
0
	def run(self):
		git_blame_r = subprocess.Popen(self.blame_string, shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
		is_inside_comment = False

		for j in git_blame_r.readlines():
			j = j.decode("utf-8", "replace")
			if Blame.is_blame_line(j):
				author = Blame.get_author(j)
				content = Blame.get_content(j)
				__blame_lock__.acquire() # Global lock used to protect calls from here...

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

				if comment.is_comment(self.extension, content):
					self.blames[(author, self.filename)].comments += 1
				if is_inside_comment:
					if comment.has_comment_end(self.extension, content):
						is_inside_comment = False
					else:
						self.blames[(author, self.filename)].comments += 1
				elif comment.has_comment_begining(self.extension, content):
					is_inside_comment = True

				self.blames[(author, self.filename)].rows += 1
				__blame_lock__.release() # ...to here.

		git_blame_r.close()
		__thread_lock__.release() # Lock controlling the number of threads running
	def get_eloc(file_r, extension):
		is_inside_comment = False
		eloc_counter = 0

		for j in file_r.readlines():
			j = j.decode("utf-8", "replace")
			if is_inside_comment and comment.has_comment_end(extension, j):
				is_inside_comment = False
			elif comment.has_comment_begining(extension, j):
				is_inside_comment = True

			if not is_inside_comment and not comment.is_comment(extension, j):
				eloc_counter += 1

		return eloc_counter
Example #3
0
    def get_eloc(file_r, extension):
        is_inside_comment = False
        eloc_counter = 0

        for j in file_r.readlines():
            j = j.decode("utf-8", "replace")
            if is_inside_comment and comment.has_comment_end(extension, j):
                is_inside_comment = False
            elif comment.has_comment_begining(extension, j):
                is_inside_comment = True

            if not is_inside_comment and not comment.is_comment(extension, j):
                eloc_counter += 1

        return eloc_counter