kvbik的python工具
KviPyTools的Python项目详细描述
一些用于各种用途的有用脚本
rename: | do recursive rename of files, directories and all its content (does not work on ms windows) |
---|---|
run: | run specified command in multiple directories |
重命名
为git存储库调用rename.shwrapper,它将.gitdir移走, 执行所有重命名,将.gitdir移回并创建提交:
./scripts/rename.sh \ djangobaselibrary=yournewsupercoollibrary \ django-base-library=your-new-super-cool-library \ "Django Base Library=You New Super Cool Library"
每个参数都是一个重命名模式。
运行
您可以直接传递参数:
./scripts/run 'git checkout master' ./first-repo/ /tmp/second-repo/ ~/third-repo/
或者在runcommand.py中定义一些替换项, 将进行评估它位于实际目录中:
# beginnig of runcommand.py import os.path MY_DIRS = ( './first-repo', '/tmp/second-repo', os.path.expanduser('~/third-repo/'), ) my_command = 'git checkout master' # end of runcommand.py
通话时间:
./scripts/run my_command MY_DIRS
你可以定义任意多的变量, 有两个特殊的名字_cmd和_ALL, 如果未给出参数,则采用以下参数:
# beginnig of runcommand.py import os.path MY_DIRS = ( './first-repo', '/tmp/second-repo', os.path('~/third-repo/'), ) my_command = 'git checkout master' _ALL = MY_DIRS _cmd = my_command # end of runcommand.py
所以,如果您现在拨打电话:
./scripts/run
现在这三个脚本调用都是等价的