高级目录树同步工具

dirsync的Python项目详细描述


版权所有2014-2019 Thomas Khyn 2003-2015年Anand B Pillai

高级目录树同步工具

基于Anand B Pillai的Python robocopier

如果你喜欢Dirsync并且想办法感谢我和/或鼓励我 未来发展,这是我的BTC或BCH捐赠地址: 1EwENyR8RV6tMc1hsLTkPURtn5wJgaBfG9

用法

从命令行:

dirsync <sourcedir> <targetdir> [options]

来自python:

from dirsync import sync
sync(sourcedir, targetdir, action, **options)

主要选项

必须在下列选项中选择一个

--diff, -dOnly report difference between sourcedir and targetdir
--sync, -sSynchronize content between sourcedir and targetdir
--update, -uUpdate existing content between sourcedir and targetdir

如果您大部分时间使用上述选项之一(例如sync),则 可以考虑在解析的Configuration file中定义action选项 通过dirsync。

其他选项

--verbose, -vProvide verbose output
--purge, -pPurge files when synchronizing (does not purge by default)
--force, -fForce copying of files, by trying to change file permissions
--twoway, -2Update files in source directory from target directory (only updates target from source by default)
--create, -cCreate target directory if it does not exist (By default, target directory should exist.)
--ctimeAlso takes into account the source file’s creation time (Windows) or the source file’s last metadata change (Unix)
--contentTakes into account ONLY content of files. Synchronize ONLY different files. At two-way synchronization source files content have priority if destination and source are existed
--ignore, -x patterns
Regex patterns to ignore
--only, -o patterns
Regex patterns to include (exclude every other)
--exclude, -e patterns
Regex patterns to exclude
--include, -i patterns
Regex patterns to include (with precedence over excludes)

配置文件

注意

配置文件仅在使用命令行时使用,并被忽略 当从python中调用dirsync时。

如果您想一直使用预定义的选项,或者如果您需要特定的 选项当“dirsync”特定源目录时,dirsync查找 两个配置文件,按顺序或优先级排列(最后一个优先):

~/.dirsync
source/directory/.dirsync

注意

第一次自动创建~/.dirsync配置文件 从命令行运行dirsync。默认情况下,它启用sync模式。

警告

任何source/directory/.dirsync文件都自动从 要比较的文件。必须显式包含使用--include 如果你想让它被比较所覆盖,请选择它。

命令行选项总是覆盖 配置文件。

配置文件必须有一个defaults节,选项如下 如上所述。唯一的例外是选项action,它可以 取3个值diffsyncupdate

配置文件示例:

[defaults]
action = sync
create = True

自定义记录器

从python中,您可能不希望将输出发送到stdout。为此, 您只需通过的logger关键字参数传递自定义记录器 sync函数:

sync(sourcedir, targetdir, action, logger=my_logger, **options)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
junit有没有办法在Java中重新初始化静态类?   在浏览器中点击应用程序时java Play框架挂起   文件Java错误中的NullPointerException   使用Java中的SNMP查找网络中计算机的登录名   java包装服务器引导程序已弃用,有什么替代方案?   当客户在等待理发时,java信号量值是否存在问题?   java如何使用JavaMail仅下载特定类型的附件   如何在java中将十进制转换为十六进制   java Slick2D粒子系统不会生成粒子   java检测更改事件来自何处   将Java集合类型参数类设置为数组   java如何从eclipse导出为可运行JAR文件?   java EntityManager对象未注入Glassfish和Spring   swing从actionPerformed和actionListener Java返回字符串   java在给定另一个等价键对象的情况下获取映射项的当前键   无论输入如何,java网络都会产生相同的输出