如何更改pybuilder中的配置,pybuilder中的配置如何工作?
如何找出可能的配置值及其默认值,如何在每个项目/每个模块/命令行/设置文件中覆盖或更改它们?哪些是设置文件?
更改现有项目的配置非常容易。访问build.py
项目根目录中的文件并确保其中包含以下代码:
from pybuilder.core import init
还有这个(不带点):
@init
def initialize(project):
...
插件使用他们所谓的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_glob
为unittest
值“*_unittest”。
有attributes
描述整个项目。例如,要更改项目的版本属性,请在initialize
方法中使用如下一行:
project.version = "0.1.14"
你.\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')
也可以使用命令行开关设置或覆盖属性:
$ pyb -P unittest_module_glob="*_unittest"
所有这些都在设置页面上进行了解释:
http://pybuilder.github.io/documentation/manual.html#Project-specificconfiguration