Commit a2a2176a authored by Inkhey's avatar Inkhey
Browse files

rename method

parent 5fbcf305
...@@ -19,7 +19,7 @@ class sqlGit(object): ...@@ -19,7 +19,7 @@ class sqlGit(object):
''' Transform Git data into sqlite database to ''' Transform Git data into sqlite database to
analyse these datas into program like gephi''' analyse these datas into program like gephi'''
# CREATE # CREATE
def __init__(self, db): def __init__(self, db):
''' Initialise sqlite database file''' ''' Initialise sqlite database file'''
self.conn = sqlite3.connect(db) self.conn = sqlite3.connect(db)
...@@ -73,18 +73,17 @@ class sqlGit(object): ...@@ -73,18 +73,17 @@ class sqlGit(object):
# INSERT # INSERT
# DATA # DATA
def getContent(self, path, depth): def insert_all(self, path, depth):
''' get_all_content and delete unused file''' ''' insert all content and delete unused file'''
os.chdir(path) os.chdir(path)
self.getAuthor() self.insert_author()
self.getCommit() self.insert_commit()
self.getFile(1) self.insert_file(depth)
self.getFile(depth) self.insert_link_A_C()
self.getLink_A_C() self.insert_link_F_C()
self.getLink_F_C() self.delete_unused_file()
self.deleteUnusedFile()
def insert_author(self):
def getAuthor(self):
''' insert author data into author table''' ''' insert author data into author table'''
f = os.popen("git log --format='%aN;;%aE'| sort -u") f = os.popen("git log --format='%aN;;%aE'| sort -u")
dAuthor = f.read().splitlines() dAuthor = f.read().splitlines()
...@@ -96,7 +95,7 @@ class sqlGit(object): ...@@ -96,7 +95,7 @@ class sqlGit(object):
values (?,?);''', data) values (?,?);''', data)
self.conn.commit() self.conn.commit()
def getCommit(self): def insert_commit(self):
''' insert commit data into commits table''' ''' insert commit data into commits table'''
f = os.popen("git log --format='%s;;%H;;%t;;%at' | sort -u") f = os.popen("git log --format='%s;;%H;;%t;;%at' | sort -u")
...@@ -110,7 +109,7 @@ class sqlGit(object): ...@@ -110,7 +109,7 @@ class sqlGit(object):
values (?,?,?,?);''', data) values (?,?,?,?);''', data)
self.conn.commit() self.conn.commit()
def getFile(self, depth): def insert_file(self, depth):
''' insert file data into file table, depth define how precise ''' insert file data into file table, depth define how precise
file data will be.''' file data will be.'''
...@@ -127,7 +126,7 @@ class sqlGit(object): ...@@ -127,7 +126,7 @@ class sqlGit(object):
self.conn.commit() self.conn.commit()
# LINKS # LINKS
def getLink_A_C(self): def insert_link_A_C(self):
''' insert link data between author and commit into ''' insert link data between author and commit into
link_author_commits table''' link_author_commits table'''
...@@ -143,7 +142,7 @@ class sqlGit(object): ...@@ -143,7 +142,7 @@ class sqlGit(object):
values (?,?,?);''', data) values (?,?,?);''', data)
self.conn.commit() self.conn.commit()
def getLink_F_C(self): def insert_link_F_C(self):
''' insert link data between file and commit into ''' insert link data between file and commit into
link_author_commits table''' link_author_commits table'''
...@@ -162,29 +161,30 @@ class sqlGit(object): ...@@ -162,29 +161,30 @@ class sqlGit(object):
self.conn.commit() self.conn.commit()
# VIEW # VIEW
def 3nodestypeView(): def view_3nodestype():
'''View with 3 types of nodes : author,commit,file'''' '''View with 3 types of nodes : author,commit,file'''
pass pass
def 2nodestypeView(): def view_2nodestype():
'''View with 2 types of nodes : author,file'''' '''View with 2 types of nodes : author,file'''
pass pass
def fileView(): def view_files():
'''View of relation between files'''' '''View of relation between files'''
pass pass
def authorView(): def view_authors():
'''View of relation between authors'''' '''View of relation between authors'''
pass pass
def fileCommitView(): def view_file_commits():
pass pass
def authorCommitView(): def view_authors_commits():
pass pass
# CLEAN # CLEAN
def deleteUnusedFile(self):
def delete_unused_file(self):
''' delete unused file (who are not linked to any commit.)''' ''' delete unused file (who are not linked to any commit.)'''
c = self.conn.cursor() c = self.conn.cursor()
...@@ -200,7 +200,7 @@ class sqlGit(object): ...@@ -200,7 +200,7 @@ class sqlGit(object):
'" and dir="' + row[1] + '";') '" and dir="' + row[1] + '";')
self.conn.commit() self.conn.commit()
def cleanDB(self): def clean_DB(self):
''' drop alls tables''' ''' drop alls tables'''
c = self.conn.cursor() c = self.conn.cursor()
...@@ -210,10 +210,9 @@ class sqlGit(object): ...@@ -210,10 +210,9 @@ class sqlGit(object):
c.execute('DROP TABLE ' + table + ' ;') c.execute('DROP TABLE ' + table + ' ;')
self.conn.commit() self.conn.commit()
# autotest # autotest
if __name__ == '__main__': if __name__ == '__main__':
db = sqlGit('self.db') db = sqlGit('self.db')
#db.cleanDB() db.clean_DB()
db.create_table() db.create_table()
db.getContent('.', 0) db.insert_all('.', 0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment