4

如何更改pybuilder中的配置,pybuilder中的配置如何工作?

如何找出可能的配置值及其默认值,如何在每个项目/每个模块/命令行/设置文件中覆盖或更改它们?哪些是设置文件?

4

1 回答 1

5

1)定位初始化方法

更改现有项目的配置非常容易。访问build.py项目根目录中的文件并确保其中包含以下代码:

from pybuilder.core import init

还有这个(不带点):

@init
def initialize(project):
  ... 

2) 属性示例

插件使用他们所谓的properties. 此处提供了可用插件属性及其默认值的列表:http: //pybuilder.github.io/documentation/plugins.html如果您未配置某些内容,则将使用默认值。

还有一个 python 核心插件,您可以在其中更改默认目录

http://pybuilder.github.io/documentation/plugins.html#Pythondeployment

此示例显示如何更改插件的属性:

project.set_property('unittest_module_glob', '*_unittest')

这会将插件的属性设置unittest_module_globunittest值“*_unittest”。

3) 属性示例

attributes描述整个项目。例如,要更改项目的版本属性,请在initialize方法中使用如下一行:

project.version = "0.1.14"

4)完整的例子

.\build.py现在可能看起来像这样:

from pybuilder.core import use_plugin
from pybuilder.core import init

use_plugin("python.core")
use_plugin("python.unittest")

name = "myfirstproject"
default_task = "publish"

@init
def initialize(project):
  project.version = "0.1.14"
  project.set_property('unittest_module_glob', '*_unittest')

5) 从命令行设置属性

也可以使用命令行开关设置或覆盖属性:

$ pyb -P unittest_module_glob="*_unittest"

6) 延伸阅读

所有这些都在设置页面上进行了解释:

http://pybuilder.github.io/documentation/manual.html#Project-specificconfiguration

于 2014-03-23T14:27:22.213 回答