From: Benjamin Hiefner <benjamin.hiefner@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Benjamin Hiefner <benjamin.hiefner@xxxxxxxxxxxxxxxxxxxx>
---
codeface/fileCommit.py | 46 ++++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/codeface/fileCommit.py b/codeface/fileCommit.py
index c6b530a..c325ed5 100644
--- a/codeface/fileCommit.py
+++ b/codeface/fileCommit.py
@@ -14,17 +14,17 @@
# Copyright 2013, Siemens AG, Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
# All Rights Reserved.
-'''This class is a container to represent a commits relationship to the
+"""This class is a container to represent a commits relationship to the
other commits present in a particular file at the time of the commit.
The analysis is performed on a file by file basis. A commit can touch multiple
files however this class considers a given commit only in the context of a
-single file.'''
+single file.
+"""
-import commit
import bisect
-class FileDict:
+class FileDict(object):
"""
A generic dictionary for saving per-line information.
We assume that this information is available on any line,
@@ -32,6 +32,7 @@ class FileDict:
So we only save the information on lines that change that info
and use bisect to retrieve that information (for any line).
"""
+ #TODO Canidate for deletion?
def __init__(self, line_list, line_dict):
"""
:rtype : FileDict
@@ -60,7 +61,7 @@ class FileDict:
:return: the information for the given line.
"""
i = bisect.bisect_right(self.line_list, line_nr)
- info_line = self.line_list[i-1]
+ info_line = self.line_list[i - 1]
return self.line_dict[info_line]
def get_line_info(self, line_nr):
@@ -84,25 +85,25 @@ class FileDict:
return self.line_dict.values()
-class FileCommit:
+class FileCommit(object):
def __init__(self):
- #filename under investigation
+ # filename under investigation
self.filename = None
- #dictionary of dictionaries key is commit, value is a
- #dictionary with keys=lineNumbers value=commitHash, stores
- #the line number and corresponding commit hash for every
- #line of the file,
+ # dictionary of dictionaries key is commit, value is a
+ # dictionary with keys=lineNumbers value=commitHash, stores
+ # the line number and corresponding commit hash for every
+ # line of the file,
self.fileSnapShots = {}
- #stores the commit hash of all contributions to the file for a
- #particular revision
+ # stores the commit hash of all contributions to the file for a
+ # particular revision
self.revCmts = []
# dictionary with key = line number, value = function name
file_level = -1
- self.functionIds = {file_level:'File_Level'}
+ self.functionIds = {file_level: 'File_Level'}
# list of function line numbers in sorted order, this is for
# optimizing the process of finding a function Id given a line number
@@ -115,15 +116,16 @@ class FileCommit:
self.doxygen_analysis = False
# source code element list
- # stores all source code elements of interest and
+ # stores all source code elements of interest andg
# meta data
self._src_elem_list = []
- # dictionaries with key = line number, value = feature list|feature
expression
+ # dictionaries with key = line number,
+ # value = feature list|feature expression
self.feature_info = FileDict()
self.feature_expression_info = FileDict()
- #Getter/Setters
+ # Getter/Setters
def getFileSnapShots(self):
return self.fileSnapShots
@@ -139,7 +141,7 @@ class FileCommit:
def getrevCmts(self):
return self.revCmts
- def getFuncImpl(self,id):
+ def getFuncImpl(self, id):
if id in self.functionImpl:
return self.functionImpl[id]
else:
@@ -148,7 +150,7 @@ class FileCommit:
def setFunctionLines(self, functionIds):
self.functionIds.update(functionIds)
for id in self.functionIds.values():
- self.functionImpl.update({id:[]})
+ self.functionImpl.update({id: []})
self.functionLineNums.extend(sorted(self.functionIds.iterkeys()))
def setSrcElems(self, src_elem_list):
@@ -158,7 +160,7 @@ class FileCommit:
self.feature_info = feature_line_infos[0]
self.feature_expression_info = feature_line_infos[1]
- #Methods
+ # Methods
def addFileSnapShot(self, key, dict):
self.fileSnapShots[key] = dict
@@ -166,12 +168,12 @@ class FileCommit:
# returns the identifier of a function given a line number
func_id = 'File_Level'
line_num = int(line_num)
- if self.doxygen_analysis == True:
+ if self.doxygen_analysis:
if line_num in self.functionIds:
func_id = self.functionIds[line_num]
else:
i = bisect.bisect_right(self.functionLineNums, line_num)
- func_line = self.functionLineNums[i-1]
+ func_line = self.functionLineNums[i - 1]
func_id = self.functionIds[func_line]
return func_id
--
2.7.1