将未使用的鸡蛋移动到指定目录的buildout扩展

buildout.eggscleaner的Python项目详细描述


构建Eggscleaner

简介

buildout.eggscleaner扩展可用于确保egg目录仅包含“used”eggs。 扩展可以报告,但也可以将未使用的鸡蛋移动到指定的目录。

安装

eggscleaner是一个buildout扩展,可以像这样添加它

[buildout]
extensions =
        buildout.eggscleaner

选项

旧鸡蛋目录
要buildout.eggscleaner将未使用的鸡蛋移动到的目录。 如果一个Excel鸡蛋已经存在,我们在“使用”鸡蛋目录中删除一个

示例

[buildout]
extensions =
        buildout.eggscleaner
old-eggs-directory = ${buildout:directory}/old-eggs/

测试

zc.buildout:1.4.3、1.5.1、1.5.2、1.6.0、2.2.1 Python:2.4.6,2.6.8

使用其他扩展

我研究了buildout.dumppickedversions的工作原理,并以类似的方式实现了这个扩展。 这个分机和那个分机并排运行得很好。

示例输出

什么都不做

*************** BUILDOUT EGGSCLEANER ****************
No unused eggs in eggs directory
*************** /BUILDOUT EGGSCLEANER ****************

移动鸡蛋

*************** BUILDOUT EGGSCLEANER ****************
Moved unused egg: webcouturier.dropdownmenu-2.3-py2.6.egg
Moved unused egg: collective.uploadify-1.0-py2.6.egg
Moved unused egg: collective.simplesocial-1.6-py2.6.egg
Moved unused egg: collective.autopermission-1.0b2-py2.6.egg
*************** /BUILDOUT EGGSCLEANER ****************

报告

*************** BUILDOUT EGGSCLEANER ****************
Don't have a 'old-eggs-directory' set, only reporting
Can add it by adding 'old-eggs-directory = ${buildout:directory}/old-eggs' to your [buildout]
Found unused egg: webcouturier.dropdownmenu-2.3-py2.6.egg
Found unused egg: plone.recipe.command-1.1-py2.6.egg
Found unused egg: collective.uploadify-1.0-py2.6.egg
Found unused egg: Products.DocFinderTab-1.0.5-py2.6.egg
Found unused egg: collective.simplesocial-1.6-py2.6.egg
Found unused egg: collective.autopermission-1.0b2-py2.6.egg
Found unused egg: Products.Clouseau-1.0-py2.6.egg
*************** /BUILDOUT EGGSCLEANER ****************

详细文档

让我们创建一个鸡蛋用于我们的测试:

>>> mkdir('myegg')
>>> write('myegg', 'setup.py',
... '''
... from setuptools import setup
... setup(name='myegg', version='1.0',)
... ''')
>>> write('myegg', 'README', '')
>>> print system(buildout+' setup myegg bdist_egg'), # doctest: +ELLIPSIS
Running setup script 'myegg/setup.py'.
...

>>> mkdir('baregg')
>>> write('baregg', 'setup.py',
... '''
... from setuptools import setup
... setup(name='baregg', version='1.0',)
... ''')
>>> write('baregg', 'README', '')
>>> print system(buildout+' setup baregg bdist_egg'), # doctest: +ELLIPSIS
Running setup script 'baregg/setup.py'.
...

现在,让我们创建一个buildout来安装egg并使用buildout.eggscleaner:

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = myegg
... ''' % join('myegg', 'dist'))

运行构建将打印有关未使用鸡蛋的信息:

>>> print system(buildout), # doctest: +ELLIPSIS
Getting distribution for 'buildout.eggscleaner'.
...

当我们只想报告未使用的鸡蛋时,我们省略了“old-eggs-directory”选项。

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = baregg
... ''' % join('baregg', 'dist'))
>>> print system(buildout) # doctest:+ELLIPSIS
Uninstalling foo.
Installing foo.
Getting distribution for 'baregg'.
Got baregg 1.0.
*************** BUILDOUT EGGSCLEANER ****************
Don't have a 'old-eggs-directory' set, only reporting
Can add it by adding 'old-eggs-directory = ${buildout:directory}/old-eggs' to your [buildout]
...
Found unused egg: myegg...
*************** /BUILDOUT EGGSCLEANER ****************
<BLANKLINE>

检查是否确实没有移动或删除任何内容:

>>> assert 'myegg' in  ''.join(os.listdir('eggs'))

如果我们想移动未使用的鸡蛋,只需添加一个old-eggs-directory选项并给出一个目录目标:

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... old-eggs-directory = ${buildout:directory}/old-eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = baregg
... ''' % join('baregg', 'dist'))

>>> print system(buildout) # doctest:+ELLIPSIS
Updating foo.
*************** BUILDOUT EGGSCLEANER ****************
...
Moved unused egg: myegg...
*************** /BUILDOUT EGGSCLEANER ****************
<BLANKLINE>

检查“myegg”是否确实已移动:

>>> assert 'myegg' not in  ''.join(os.listdir('eggs')), 'myegg has not been moved out of egg dir'
>>> assert 'myegg' in  ''.join(os.listdir('old-eggs')), 'myegg has not been moved to old-egg dir'

而且baregg仍然存在:

>>> assert 'baregg' in  ''.join(os.listdir('eggs')), 'baregg is not present in egg dir'

贡献者

  • Peter Uitenbroek,作者

更改历史记录

0.1.7(2014-07-18)

  • 凹凸版本以修复以前版本的混乱

0.1.6(错误未发布)

  • 把鸡蛋清理机放在窗户下面 [安东·塔古诺夫]
  • 让Eggscleaner与最新的Buildout一起工作(2.2.1) [安东·塔古诺夫]
  • 仅当eggs目录为本地时才运行eggscleaner [作业]

0.1.5(2012-08-17)

  • 重拨文档 [作业]
  • 添加了doctest [作业]

0.1(内部释放)

  • 创造 [作业]

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

推荐PyPI第三方库


热门话题
java无法使用JAXB配置Moxy   java如何让我的简单Swing telnet客户端正确显示字符?   java中从可运行线程调用主线程的多线程处理   java数据源。EBJ3会话bean中的getConnection()   使用java和正则表达式从xml文件提取值时出现问题   java定制Jersy胡须Mvc   在Java中,“限制并发”是什么意思?   java有没有更干净的方法可以在这里使用Optional,而不在三个地方返回“NA”?   java Tomcat启动,然后崩溃,除非我打电话   java理解客户机和服务器   java时间戳将在视图对象>实体转换期间丢失   如何在java中返回布尔值(基元)?   java使用spring mvc设置日志记录,希望仅对我的代码进行跟踪/调试   用Jackson解析嵌套对象