python svn
svn 0.3.36
Intuitive Subversion wrapper.
Introduction
svn is a simple Subversion library for Python. I wrote it so that there could be a lightweight and accessible library that was also available on PyPI. It is compatible with both Python 2.7 and 3.3+.
I’ve only implemented the functionality that I have required:
- Listing entries
- Getting info
- Getting log
- Checking-out
- Exporting
You are more than welcome to submit pull-requests to add more support for additional subcommands.
Usage
Usage is divided between two clients that either allow for access to a local working-directory or a remote repository.
Both clients inherit a common set of methods that work with both local working- directories and remote repositories.
svn.utility.get_client is provided for convenience. If you provide a location that starts with a backslash, it will return a LocalClient instance. Otherwise, it will return a RemoteClient instance.
LocalClient
LocalClient allows access to a local working copy.
RemoteClient
RemoteClient allows access to a remote repository.
- checkout(path)
Example:
import svn.remote
r = svn.remote.RemoteClient('https://repo.local/svn')
r.checkout('/tmp/working')
Common Functionality
These methods are available on both clients.
info(rel_path=None)
Get information about the directory.
Example:
import pprint
import svn.local
r = svn.local.LocalClient('/tmp/test_repo.co')
info = r.info()
pprint.pprint(info)
#{'commit#revision': 0,
# 'commit/author': None,
# 'commit/date': datetime.datetime(2015, 4, 24, 2, 53, 21, 874970, tzinfo=tzutc()),
# 'commit_author': None,
# 'commit_date': datetime.datetime(2015, 4, 24, 2, 53, 21, 874970, tzinfo=tzutc()),
# 'commit_revision': 0,
# 'entry#kind': 'dir',
# 'entry#path': '/tmp/test_repo.co',
# 'entry#revision': 0,
# 'entry_kind': 'dir',
# 'entry_path': '/tmp/test_repo.co',
# 'entry_revision': 0,
# 'relative_url': None,
# 'repository/root': 'file:///tmp/test_repo',
# 'repository/uuid': '7446d4e9-8846-46c0-858a-34a2a1739d1c',
# 'repository_root': 'file:///tmp/test_repo',
# 'repository_uuid': '7446d4e9-8846-46c0-858a-34a2a1739d1c',
# 'url': 'file:///tmp/test_repo',
# 'wc-info/depth': None,
# 'wc-info/schedule': None,
# 'wc-info/wcroot-abspath': None,
# 'wcinfo_depth': None,
# 'wcinfo_schedule': None,
# 'wcinfo_wcroot_abspath': None}
NOTE: The keys named with dashes, slashes, and hashes are considered
obsolete, and only available for backwards compatibility. We
have since moved to using only underscores to separate words.
cat(rel_filepath)
Get file-data as string.
Example:
import svn.local
l = svn.local.LocalClient('/tmp/test_repo')
content = l.cat('test_file')
log_default(timestamp_from_dt=None, timestamp_to_dt=None, limit=None, rel_filepath=”)
Perform a log-listing that can be bounded by time and/or take a maximum- count.
Example:
import svn.local
l = svn.local.LocalClient('/tmp/test_repo.co')
for e in l.log_default():
print(e)
#LogEntry(date=datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()), msg='Added second file.', revision=2, author='dustin')
#LogEntry(date=datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()), msg='Initial commit.', revision=1, author='dustin')
export(to_path, revision=None)
Checkout the tree without embedding an meta-information.
Example:
import svn.remote
r = svn.remote.RemoteClient('file:///tmp/test_repo')
r.export('/tmp/test_export')
list(extended=False, rel_path=None)
Return either a flat-list of filenames or a list of objects describing even more information about each.
Example:
import pprint
import svn.local
l = svn.local.LocalClient('/tmp/test_repo.co')
# Flat list.
entries = l.list()
for filename in entries:
print(filename)
#aa
#bb
# Extended information.
entries = l.list(extended=True)
for entry in entries:
pprint.pprint(entry)
#{'author': 'dustin',
# 'commit_revision': 1,
# 'date': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'aa',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc())}
#{'author': 'dustin',
# 'commit_revision': 2,
# 'date': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'bb',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc())}
list_recursive(rel_path=None, yield_dirs=False, path_filter_cb=None)
List all entries at and beneath the root or given relative-path.
Example:
import pprint
import svn.local
l = svn.local.LocalClient('/tmp/test_repo.co')
for rel_path, e in l.list_recursive():
print('')
print('[' + rel_path + ']')
print('')
pprint.pprint(e)
#[]
#
#{'author': 'dustin',
# 'commit_revision': 1,
# 'date': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'aa',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc())}
#
#[]
#
#{'author': 'dustin',
# 'commit_revision': 2,
# 'date': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'bb',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc())}
#
#[dir1]
#
#{'author': 'dustin',
# 'commit_revision': 3,
# 'date': datetime.datetime(2015, 4, 24, 3, 25, 13, 479212, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'cc',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 25, 13, 479212, tzinfo=tzutc())}
Important
Previously, the LocalClient and RemoteClient classes were exposed at the package level:
- svn.LocalClient
- svn.RemoteClient
Unfortunately, this interfered with dependency management during installation. The imports will now have to be, respectively:
- svn.local (for LocalClient)
- svn.remote (for RemoteClient)
We’re sorry for the inconvenience.
python svn的更多相关文章
- linux+jenkins+python+svn 自动化测试集成之路
本文背景: 背景1---个人基础: 本机win7上安装pycharm,使用python搭建API自动化测试框架,本地运行Pass.本机上搭建jenkins,创建测试任务,定时构建Pass. 背景2-- ...
- windows平台python svn模块的一个小 bug
环境 编程语言版本:python 2.7 操作系统:win10 64位 模块名:svn svn checkout时报错 File "D:\Python27\lib\site-package ...
- SVN图形管理工具-Submint
1.安装svn及相关依赖包 yum install subversion httpd mod_dav_svn apr-util-sqlite 2.下载submin wget https://sup ...
- linux+nginx+python+django环境配置
Django是一个开放源代码的Web应用框架,由Python写成,它最初是被开发来用于管理劳伦斯出版集团旗下的一些以新闻内容为主的网站的.python+django也是web开发者最受欢迎的框架.今天 ...
- (源)V8 Engine 编译
v8 engine编译 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !imp ...
- 向着DJANGO奔跑!
这个项目明天上半年要弄好,就牛X了哈哈. 平台化运维.PYTHON,SVN,SALTSTACK,.....一锅端~~:) from django.contrib import admin # Regi ...
- PDFium-PDF开源之旅(1)-初探代码下载编译
近日,Google和Foxit合作开源了Foxit的PDF源代码. 叫PDFium 相关新闻不少.哈,虽说已经不是程序猿了.只是还是有兴趣跑起来围观看看.废话少说.先说编译代码的步骤(事实上Googl ...
- MobaXterm使用
MobaXterm: SSH/X远程客户端, Xmanager的最佳免费替代品 当需要连接远程linux并运行X程序时,很多朋友首先想到的是NetSarang Xmanager, 虽然这个工具的确 ...
- python+paramiko库+svn写的自动化部署脚本
第一篇博文 直接开门见山的说了. 这是件什么事?:每次部署都是复制本地的文件粘贴到服务器端,因为路径复杂,所以费时且手工容易出漏洞. 一直在想有什么办法可以解决这种,因为以前在微软的一个牛人同事做过一 ...
随机推荐
- Uploadify上传Excel到数据库
前两章简单的介绍了Uploadify上传插件的基本使用和相关的属性说明.这一章结合Uploadify+ssh框架+jquery实现Excel上传并保存到数据库. 以前写的这篇文章 Jq ...
- STM32-F0/F1/F2
用到的资源是:A.ST公司提供:STM32F10x开发标准库V3.5B.实验平台:战舰开发板V2.1C.编译软件:MDK3.8D.编辑软件:Source Insight_V3.5E.RTOS:ucos ...
- 集成框架jar包的一些选择
我们往往在官网上下载了框架需要的jar却不知道该导入什么. required包里面的是必须导入的jar jar应该一切从简
- HDU 4750
解题方法,,,首先应该可以看出来是一颗 最小生成树,任意一条的边的价值是不同的:所以计算出最小生成树的每一条边有多少对顶点满足他的 f 值就是这条边的 权值,因此可以在生成最小生成树的时候,进行一下统 ...
- org.hibernate.MappingException: duplicate import异常
在开发hibernate时,一起多谢ORM类和映射文件时,报出:org.hibernate.MappingException: duplicate import com.XXX异常 解决方案: 检查你 ...
- window 7 下一台cp 两个mysql 配置主从
环境 : 个人 pc windows7 一台 ; 使用 : 官方下载: mysql-noinstall-5.5.11-win32.zip 1. 解压 成2个 (文件夹) mysql_master (主 ...
- ACE_SOCK
该类属中的类都位于ACE_SOCK之下:它提供使用BSD socket编程接口的Internet域和UNIX域协议族的接口.这个类属中的类被进一步划分为: Dgram类, Acceptor类和Stre ...
- PyPI镜像网站
镜像列表:http://www.pypi-mirrors.org/ 清华镜像:http://e.pypi.python.org/
- Oracle优化器介绍
Oracle优化器介绍 本文讲述了Oracle优化器的概念.工作原理和使用方法,兼顾了Oracle8i.9i以及最新的10g三个版本.理解本文将有助于您更好的更有效的进行SQL优化工作. RBO优化器 ...
- selenium python (五)打印信息及设置等待时间
#!/usr/bin/python# -*- coding: utf-8 -*-__author__ = 'zuoanvip' #一般情况下我们要验证打开的页面是否正确,可通过网页的Title和Cur ...