本文整理汇总了Python中gittle.Gittle.auth方法的典型用法代码示例。如果您正苦于以下问题:Python Gittle.auth方法的具体用法?Python Gittle.auth怎么用?Python Gittle.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gittle.Gittle
的用法示例。
在下文中一共展示了Gittle.auth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gittle import Gittle [as 别名]
# 或者: from gittle.Gittle import auth [as 别名]
class GitStat:
'''
print " This class is for parsed git repository.\n\
Returns parsed dictionary filled by name of users/commiters which add/modify files.\n\
Every item has own directory which contains some counters: \
counter for adding files\n\
counter for deleting files\n\
counter for files which has been modify\n\
Next:\n \
all git commits in array\n\
directory which lines in which files was modify and how many times who\n"
'''
def __init__(self,git_path,rskey= None,logger=dg):
self.User = {}
self.Commits = {}
self.__logger = logger
self.__tmp_repository = "/tmp/temporary_git_repository"
if(os.path.exists(self.__tmp_repository)):
self.__tmp_repository = self.__tmp_repository+"_"+datetime.datetime.now().isoformat()
print git_path
try:
Gittle.clone(git_path,self.__tmp_repository)
except:
pass
#self.__logger("Error could not clone repository.")
#return
self.__repository = Gittle(self.__tmp_repository)
if rskey != None:
key_file = open(rskey)
self.__repository.auth(pkey=key_file)
#print self.__tmp_repository
self.fill_User()
def parse(self,name,commit,time):
#print "asd",name, commit
file_pattern = re.compile("diff --git a/(.*) b/(.*)")
line_pattern = re.compile("@@ (.*) (.*) @@")
regex = file_pattern.search(commit)
file1,file2 = regex.group(1),regex.group(2)
regex = line_pattern.search(commit)
line1,line2 = regex.group(1),regex.group(2)
#self.__logger("Files : ",file1,file2,line1,line2)
# print self.User[name].has_key(file1)
if self.User[name].has_key(file1):
#self.User[name][file1]['line_str'].append(line1+" "+line2)
if self.User[name][file1].has_key(line1):
self.User[name][file1][line1]["counter"] += 1
self.User[name][file1][line1]['time'].append(time)
else:
self.User[name][file1][line1] = {}
self.User[name][file1][line1]["counter"] = 1
self.User[name][file1][line1]['time'] = []
self.User[name][file1][line1]['time'].append(time)
self.User[name][file1]['modify'] += 1
self.User[name][file1]['time'].append(time)
if os.path.isfile(self.__tmp_repository+'/'+file1):
self.User[name][file1]['exist'] = True
else:
self.User[name][file1]['exist'] = False
self.Commits[name][file1]['array_commits'].append(commit)
self.Commits[name][file1]['time'].append(time)
else:
self.User[name][file1] = {}
self.User[name][file1][line1] = {}
self.User[name][file1][line1]["counter"] = 1
self.User[name][file1][line1]['time'] = []
self.User[name][file1][line1]['time'].append(time)
self.User[name][file1]['modify'] = 1
self.User[name][file1]['time'] = []
self.User[name][file1]['time'].append(time)
if os.path.isfile(self.__tmp_repository+'/'+file1):
self.User[name][file1]['exist'] = True
else:
self.User[name][file1]['exist'] = False
self.Commits[name][file1] = {}
self.Commits[name][file1]['array_commits'] = []
self.Commits[name][file1]['array_commits'].append(commit)
self.Commits[name][file1]['time'] = []
self.Commits[name][file1]['time'].append(time)
return file1
def fill_User(self):
for commit in self.__repository.commit_info():
sha = [commit['sha']]
#print commit
try:
if not self.User.has_key(commit['committer']['name']):
#print commit#['committer']['name']
#print self.__repository.diff(*sha)[0]['diff']
self.User[commit['committer']['name']] = {}
self.Commits[commit['committer']['name']] = {}
self.parse(commit['committer']['name'],self.__repository.diff(*sha)[0]['diff'],commit['time'])
else:
self.parse(commit['committer']['name'],self.__repository.diff(*sha)[0]['diff'],commit['time'])
except:
pass
#return file1
def return_User(self):
#.........这里部分代码省略.........
示例2: Gittle
# 需要导入模块: from gittle import Gittle [as 别名]
# 或者: from gittle.Gittle import auth [as 别名]
from gittle import Gittle
from config import repo_path, repo_url, key_file
# Gittle repo
g = Gittle(repo_path, origin_uri=repo_url)
# Authentication
g.auth(pkey=key_file)
# Do push
g.push()
示例3: Gittle
# 需要导入模块: from gittle import Gittle [as 别名]
# 或者: from gittle.Gittle import auth [as 别名]
# /usr/bin/python
# coding=utf-8
'''help me to git add changes '''
from gittle import Gittle
import sys
conf = [
['/home/zhang/www/php', '[email protected]:tianyunchong/php.git']
]
for con in conf:
repo = Gittle(con[0], con[1])
#拉取远程代码到本地
key_file = open("/home/zhang/.ssh/id_rsa")
repo.auth(key_file)
repo.pull(con[1], "origin/master")
sys.exit()
untracks = repo.untracked_files
if not untracks:
print "暂时没有文件新增!"
changes = repo.modified_files
print changes