本文整理汇总了Python中gittle.Gittle.checkout_all方法的典型用法代码示例。如果您正苦于以下问题:Python Gittle.checkout_all方法的具体用法?Python Gittle.checkout_all怎么用?Python Gittle.checkout_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gittle.Gittle
的用法示例。
在下文中一共展示了Gittle.checkout_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GitData
# 需要导入模块: from gittle import Gittle [as 别名]
# 或者: from gittle.Gittle import checkout_all [as 别名]
#.........这里部分代码省略.........
"""
Using this method I will check through all the saved commits and
evaluate the theoretic quality of these commits. Both algorithms
used here are based on a simple principle of added and removed
lines. According to these algorithms, there is a calculation of
the rating.
Output data structure is:
sha1-> range, removed_counter, added_counter, added_lines,
removed_lines, rating_one, rating_two etc.
sha2-> range, removed_counter, added_counter, added_lines,
removed_lines, rating etc.
etc.
The direction of rating goes from the first commit to the last one.
There are two different ways. The first algorithm ends if there are
no lines left of if it reaches the end of list. After that the rate
is being calculated.
The second algorithm is set for default rating value of 100. It
subtracts value from this default one and is calculated this way:
value = (100/added_lines) * removed lines
"""
for file_name in self.files.keys():
file_ = self.files[file_name]
#get size of df
size = file_.count().values[0]
for row in xrange(size):
#start index
start_index = row + 1
# how many commits we must iterate
max_size = size - start_index
added_lines = list(file_.at[row, "hash_added"])
threshold = max_size * 0.1
rating = 4
#special case when was only removing
if not any(added_lines):
continue
rating_two = 100
minus_val = len(added_lines)
for idx in xrange(start_index, size):
for line in (file_.at[idx, "hash_removed"]):
if line in added_lines:
added_lines.remove(line)
rating_two -= (100 / minus_val)
added_lines = added_lines
if len(added_lines) <= 0:
range_ = idx - start_index
rating = calculate_rating(range_, threshold)
break
if thresh_fl and idx >= (threshold * 5):
rating = 4
break
first_added = len(file_.at[row, "hash_added"])
if correction:
if rating > 1 and len(added_lines) < first_added / 4:
rating -= 2
elif rating > 0 and len(added_lines) < first_added / 2:
rating -= 1
rating = (rating / 4) * 100
self.files[file_name].at[row, "rating_one"] = rating
self.files[file_name].at[row, "rating_two"] = rating_two
def find_author_by_sha(self, sha):
"""This method finds the author by sha in dataFrame. If not found
return None.
"""
index = self._data_frame[self._data_frame.sha == sha]["author"]
if sha == '' or sha == []:
return None
try:
return index.values[0]["name"]
except IndexError:
LOGGER.warning(r"Sha {0}, {1} is not in data frame.".format(sha, index))
return None
def find_time_by_sha(self, sha):
"""This method finds timestamp by sha in dataFrame. If not found
return None.
"""
index = self._data_frame[self._data_frame.sha == sha].index
if sha == '' or sha == []:
return None
try:
return self._data_frame.time[index].values[0]
except IndexError:
LOGGER.warning("Sha {0}, {1} is not in data frame.".format(sha, index))
return None
def rollback(self, sha):
"""
This method will make rollback to version which is set by sha.
"""
try:
self.__repository.checkout_all(sha)
except IOError:
LOGGER.warning("Couldn't rollback on sha {0}.".format(sha))
except KeyError:
LOGGER.warning("Couldn't rollback on sha {0}.".format(sha))
def get_git_data(self):
""" This method returns data frame for project or None. """
return (self._data_frame, self.files)