欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python的高級Git庫 Gittle

 更新時間:2014年09月22日 14:36:49   投稿:mdxy-dxy  
Gittle是一個高級純python git 庫。構建在dulwich之上,提供了大部分的低層機制

Gittle是一個高級純python git 庫。構建在dulwich之上,提供了大部分的低層機制。

Install it

pip install gittle

Examples :

Clone a repository

from gittle import Gittle
 
repo_path = '/tmp/gittle_bare'
repo_url = 'git://github.com/FriendCode/gittle.git'
 
repo = Gittle.clone(repo_url, repo_path)

With authentication (see Authentication section for more information) :

auth = GittleAuth(pkey=key)
Gittle.clone(repo_url, repo_path, auth=auth)

Or clone bare repository (no working directory) :

repo = Gittle.clone(repo_url, repo_path, bare=True) 

Init repository from a path

repo = Gittle.init(path) 

Get repository information

# Get list of objects
repo.commits
 
# Get list of branches
repo.branches
 
# Get list of modified files (in current working directory)
repo.modified_files
 
# Get diff between latest commits
repo.diff('HEAD', 'HEAD~1')

Commit

# Stage single file
repo.stage('file.txt')
 
# Stage multiple files
repo.stage(['other1.txt', 'other2.txt'])
 
# Do the commit
repo.commit(name="Samy Pesse", email="samy@friendco.de", message="This is a commit")

Pull

repo = Gittle(repo_path, origin_uri=repo_url)
 
# Authentication with RSA private key
key_file = open('/Users/Me/keys/rsa/private_rsa')
repo.auth(pkey=key_file)
 
# Do pull
repo.pull()

Push

repo = Gittle(repo_path, origin_uri=repo_url)
 
# Authentication with RSA private key
key_file = open('/Users/Me/keys/rsa/private_rsa')
repo.auth(pkey=key_file)
 
# Do push
repo.push()

Authentication for remote operations

# With a key
key_file = open('/Users/Me/keys/rsa/private_rsa')
repo.auth(pkey=key_file)
 
# With username and password
repo.auth(username="your_name", password="your_password")

Branch

# Create branch off master
repo.create_branch('dev', 'master')
 
# Checkout the branch
repo.switch_branch('dev')
 
# Create an empty branch (like 'git checkout --orphan')
repo.create_orphan_branch('NewBranchName')
 
# Print a list of branches
print(repo.branches)
 
# Remove a branch
repo.remove_branch('dev')
 
# Print a list of branches
print(repo.branches)

Get file version

versions = repo.get_file_versions('gittle/gittle.py')
print("Found %d versions out of a total of %d commits" % (len(versions), repo.commit_count()))

Get list of modified files (in current working directory)

repo.modified_files 

Count number of commits

repo.commit_count 

Get information for commits

List commits :

# Get 20 first commits repo.commit_info(start=0, end=20) 

With a given commit :

commit = "a2105a0d528bf770021de874baf72ce36f6c3ccc" 

Diff with another commit :

old_commit = repo.get_previous_commit(commit, n=1)
print repo.diff(commit, old_commit)

Explore commit files using :

commit = "a2105a0d528bf770021de874baf72ce36f6c3ccc"
 
# Files tree
print repo.commit_tree(commit)
 
# List files in a subpath
print repo.commit_ls(commit, "testdir")
 
# Read a file
print repo.commit_file(commit, "testdir/test.txt")

Create a GIT server

from gittle import GitServer
 
# Read only
GitServer('/', 'localhost').serve_forever()
 
# Read/Write
GitServer('/', 'localhost', perm='rw').serve_forever()

相關文章

  • Python爬蟲輔助利器PyQuery模塊的安裝使用攻略

    Python爬蟲輔助利器PyQuery模塊的安裝使用攻略

    這篇文章主要介紹了Python爬蟲輔助利器PyQuery模塊的安裝使用攻略,PyQuery可以方便地用來解析HTML內容,使其成為眾多爬蟲程序開發(fā)者的大愛,需要的朋友可以參考下
    2016-04-04
  • 關于AnacondaNavigator?Jupyter?Notebook更換Python內核的問題

    關于AnacondaNavigator?Jupyter?Notebook更換Python內核的問題

    因為新安裝的Anaconda?Navigator默認安裝了一個Python,Jupyter?Notebook默認使用的內核就是這個Python,跟我系統(tǒng)安裝好的Python沖突了,下面小編給大家介紹AnacondaNavigator?Jupyter?Notebook更換Python內核的問題,需要的朋友可以參考下
    2022-02-02
  • Django生成PDF文檔顯示網頁上以及PDF中文顯示亂碼的解決方法

    Django生成PDF文檔顯示網頁上以及PDF中文顯示亂碼的解決方法

    今天小編就為大家分享一篇Django生成PDF文檔顯示網頁上以及PDF中文顯示亂碼的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • Python多繼承順序實例分析

    Python多繼承順序實例分析

    這篇文章主要介紹了Python多繼承順序,結合實例形式分析了Python多繼承情況下繼承順序對同名函數(shù)覆蓋的影響,需要的朋友可以參考下
    2018-05-05
  • python matplotlib 在指定的兩個點之間連線方法

    python matplotlib 在指定的兩個點之間連線方法

    今天小編就為大家分享一篇python matplotlib 在指定的兩個點之間連線方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • OpenCV結合selenium實現(xiàn)滑塊驗證碼

    OpenCV結合selenium實現(xiàn)滑塊驗證碼

    本文主要介紹了OpenCV結合selenium實現(xiàn)滑塊驗證碼,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Python作用域用法實例詳解

    Python作用域用法實例詳解

    這篇文章主要介紹了Python作用域用法,結合實例形式詳細分析了Python作用域概念,用法與相關函數(shù)的使用技巧,需要的朋友可以參考下
    2016-03-03
  • python使用多線程備份數(shù)據(jù)庫的步驟

    python使用多線程備份數(shù)據(jù)庫的步驟

    在日常服務器運維工作中,備份數(shù)據(jù)庫是必不可少的,剛工作那會看到公司都是用shell腳本循環(huán)備份數(shù)據(jù)庫,到現(xiàn)在自己學習python語言后,利用多進程多線程相關技術來實現(xiàn)并行備份數(shù)據(jù)庫,充分利用服務器資源,提高備份速度。
    2021-05-05
  • Django中的靜態(tài)文件管理過程解析

    Django中的靜態(tài)文件管理過程解析

    這篇文章主要介紹了Django中的靜態(tài)文件管理過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-08-08
  • Python使用cx_Freeze庫生成msi格式安裝文件的方法

    Python使用cx_Freeze庫生成msi格式安裝文件的方法

    這篇文章主要介紹了Python使用cx_Freeze庫生成msi格式安裝文件的方法,結合實例形式分析了Python基于cx_Freeze庫生成msi格式安裝文件操作技巧與相關問題解決方法,需要的朋友可以參考下
    2018-07-07

最新評論