Commit e5b58b0a authored by inkhey's avatar inkhey

autopep8+flake8

parent 3164f45e
......@@ -12,15 +12,18 @@
import sqlite3
import os
from subprocess import Popen, PIPE
from walkdir import filtered_walk, all_paths
from walkdir import filtered_walk
# use walkir instead of os.walk to be able
# to select a depth
class sqlGit(object):
''' Transform Git data into sqlite database to
analyse these datas into program like gephi'''
# CREATE
def __init__(self, db):
''' Initialise sqlite database file'''
self.conn = sqlite3.connect(db)
......@@ -90,7 +93,7 @@ class sqlGit(object):
log = Popen("git log --format=%aN;;;;%aE".split(), stdout=PIPE)
sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE)
log.stdout.close()
f = sort.stdout.read().decode('utf-8','replace')
f = sort.stdout.read().decode('utf-8', 'replace')
dAuthor = f.splitlines()
c = self.conn.cursor()
for line in dAuthor:
......@@ -102,13 +105,13 @@ class sqlGit(object):
def insert_commit(self):
''' insert commit data into commits table'''
log = Popen("git log --format=%s;;;;%H;;;;%t;;;;%at".split(), stdout=PIPE)
log = Popen(
"git log --format=%s;;;;%H;;;;%t;;;;%at".split(), stdout=PIPE)
sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE)
log.stdout.close()
f = sort.stdout.read().decode('utf-8','replace')
f = sort.stdout.read().decode('utf-8', 'replace')
dCommit = f.splitlines()
c = self.conn.cursor()
i = 0
for line in dCommit:
data = line.split(';;;;')
c.execute(
......@@ -150,11 +153,11 @@ class sqlGit(object):
''' insert link data between author and commit into
link_author_commits table'''
log = Popen('git log --pretty=format:%aN;;;;%aE;;;;%H'.split(), stdout=PIPE)
f = log.stdout.read().decode('utf-8','replace')
log = Popen(
'git log --pretty=format:%aN;;;;%aE;;;;%H'.split(), stdout=PIPE)
f = log.stdout.read().decode('utf-8', 'replace')
dLinkC_A = f.splitlines()
c = self.conn.cursor()
i = 0
for line in dLinkC_A:
data = line.split(';;;;')
c.execute(
......@@ -174,7 +177,7 @@ class sqlGit(object):
path = os.path.join(row[0], row[1])
cmd = 'git log --pretty=format:%H' + ' -- ' + path
log = Popen(cmd.split(), stdout=PIPE)
f = log.stdout.read().decode('utf-8','replace')
f = log.stdout.read().decode('utf-8', 'replace')
dLinkF_C = f.splitlines()
for commits in dLinkF_C:
data = (row[1], row[0], commits)
......@@ -188,7 +191,7 @@ class sqlGit(object):
'''View with 3 types of nodes : author,commit,file'''
c = self.conn.cursor()
c.execute(
'''create view nodes as
'''create view nodes as
select dir || name as id ,
size as taille,
dir as dir,
......@@ -220,7 +223,7 @@ class sqlGit(object):
from commits;
''')
c.execute(
'''create view edges as
'''create view edges as
select author_mail as source,
commits as target,
author_name,
......@@ -284,7 +287,7 @@ class sqlGit(object):
''' drop current view'''
c = self.conn.cursor()
listTable = ('nodes','edges')
listTable = ('nodes', 'edges')
for table in listTable:
c.execute('DROP VIEW IF EXISTS ' + table + ' ;')
self.conn.commit()
......
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