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的更多相关文章

  1. linux+jenkins+python+svn 自动化测试集成之路

    本文背景: 背景1---个人基础: 本机win7上安装pycharm,使用python搭建API自动化测试框架,本地运行Pass.本机上搭建jenkins,创建测试任务,定时构建Pass. 背景2-- ...

  2. windows平台python svn模块的一个小 bug

    环境 编程语言版本:python 2.7 操作系统:win10 64位 模块名:svn svn  checkout时报错 File "D:\Python27\lib\site-package ...

  3. SVN图形管理工具-Submint

    1.安装svn及相关依赖包 yum install subversion httpd mod_dav_svn apr-util-sqlite   2.下载submin wget https://sup ...

  4. linux+nginx+python+django环境配置

    Django是一个开放源代码的Web应用框架,由Python写成,它最初是被开发来用于管理劳伦斯出版集团旗下的一些以新闻内容为主的网站的.python+django也是web开发者最受欢迎的框架.今天 ...

  5. (源)V8 Engine 编译

    v8 engine编译 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !imp ...

  6. 向着DJANGO奔跑!

    这个项目明天上半年要弄好,就牛X了哈哈. 平台化运维.PYTHON,SVN,SALTSTACK,.....一锅端~~:) from django.contrib import admin # Regi ...

  7. PDFium-PDF开源之旅(1)-初探代码下载编译

    近日,Google和Foxit合作开源了Foxit的PDF源代码. 叫PDFium 相关新闻不少.哈,虽说已经不是程序猿了.只是还是有兴趣跑起来围观看看.废话少说.先说编译代码的步骤(事实上Googl ...

  8. MobaXterm使用

    MobaXterm: SSH/X远程客户端, Xmanager的最佳免费替代品   当需要连接远程linux并运行X程序时,很多朋友首先想到的是NetSarang Xmanager, 虽然这个工具的确 ...

  9. python+paramiko库+svn写的自动化部署脚本

    第一篇博文 直接开门见山的说了. 这是件什么事?:每次部署都是复制本地的文件粘贴到服务器端,因为路径复杂,所以费时且手工容易出漏洞. 一直在想有什么办法可以解决这种,因为以前在微软的一个牛人同事做过一 ...

随机推荐

  1. 新版本 JSAPI微信支付V3 C# DEMO

    小弟在公众号后台无意中点了更新(微信支付接口升级)PS:想都没有想,心里还乐滋滋的免费的干嘛不升级...后果来了.面临着支付不能用了,代码需要重新更新. /** * JS_API支付demo * == ...

  2. bzoj2396: 神奇的矩阵

    与51nod1140一样.不过这题是多组数据的...坑.... #include<cstdio> #include<cstring> #include<cctype> ...

  3. HDU 2159 FATE【二维完全背包】

    题意:xhd玩游戏,还需要n个经验值升级,还留有m的忍耐度,但是他最多打s只怪,给出k个怪的经验值a[i],以及消耗的忍耐度b[i],问xhd能不能升级-- 因为有两个限定,忍耐度,和最多打s只怪(即 ...

  4. 阿里云linux服务器安装Phalcon-----"phalcon Volt directory can't be written" "gcc: internal compiler error: Killed (program cc1)"

    这里特别蛋疼的一件事是官方英文文档和中文文档命令参数略有不同 中文文档: //通用平台下安装指定的软件包: sudo yum install git gcc make pcre-devel php-d ...

  5. 移植linux(1)

    硬件环境:TQ2440   软件环境:linux-2.6.30.4 下载源码:ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.4.tar ...

  6. 关于ios越狱开发的那些事

    也许吧,每每接触某些新东西的时候,都有点犯晕吧,这不是应该要的. 第一次接触ios越狱开发,也是这样吧.这篇主要是从无到有的说一下ios越狱的开发,网上很多的教程大部门都比较旧了吧,放在新设备上总是出 ...

  7. Spark 问题总结

    1 创建hive外部表 其实这个问题应该是hive的问题.就是外部表在创建的时候需要指定目录.举例说明 我们要创建一个外部表,其来源是test_tab这个文件,那么在LOCATION处是不是这样写呢? ...

  8. ecshop显示所有分类树栏目

    1.找到 category.php 和goods.php 两个文件修改: $smarty->assign('categories', get_categories_tree(0)); // 分类 ...

  9. SELinux Mysql的error-log文件位置的指定

    SELinux下,在配置my.cnf时,必须指定error-log的位置在/var/log/下, 否则error的默认位置为例如 /var/lib/mysql下的tyoyi.server.err文件, ...

  10. 扩容盘、SD卡扩容

    内存卡的前世今生回想当年,大家都还在用着非智能机,由于功能单一,需要存储的数据也就是通讯录和短信.虽然那时也有手机游戏,但大多都是几十KB,并不需要太大的存储空间.但随着手机功能的多样化,尤其是音乐. ...