以编程方式确定 Bazaar 插件目录

发布于 2024-08-13 13:45:20 字数 63 浏览 2 评论 0原文

有没有办法以编程方式确定 Bazaar 目录? 如果有一个bazaar命令来确定插件目录,这将是最好的解决方案。

Is there a way to determine the Bazaar directory programmatically?
If there is a bazaar command to determine the plugin directory, this would be the best solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我的黑色迷你裙 2024-08-20 13:45:20

在以下目录中搜索 Bazaar 插件:

* <pythonlib>/site-packages/bzrlib/plugins/ 
      (where <pythonlib> is something like usr/lib/python2.4, 
       depending on your installation)

* $HOME/.bazaar/plugins/

您也可以通过 BZR_PLUGIN_PATH 环境变量设置 bazaar 插件目录。

有关集市插件的更多信息:http://bazaar-vcs.org/BzrPlugins

Bazaar plugins are searched for in the following directories:

* <pythonlib>/site-packages/bzrlib/plugins/ 
      (where <pythonlib> is something like usr/lib/python2.4, 
       depending on your installation)

* $HOME/.bazaar/plugins/

You can set the bazaar plugins directory via BZR_PLUGIN_PATH environement variable, also.

More on bazaar plugins: http://bazaar-vcs.org/BzrPlugins

听不够的曲调 2024-08-20 13:45:20

根据集市网站
默认情况下,在 ~/.bazaar/plugins 中查找用户插件,但可能会被环境变量 BZR_PLUGIN_PATH 覆盖。
因此测试该变量是否已设置,否则返回默认值。在 python 中:

import os
user_plugin_path = os.environ.get('BZR_PLUGIN_PATH', '~/.bazaar/plugins')

编辑:这适用于基于 UNIX 的系统,对于 Windows,使用插件路径是 $APPDATA/bazaar/2.0/plugins

系统范围的插件位于 bzrlib/plugins 中,请参阅页面下方的安装插件此处< /a>.使用 distutils 获取前缀(例如 /usr/lib/python2.4/site-packages/bzrlib/plugins/):(

from distutils.sysconfig import get_python_lib
global_plugin_path = os.path.join(get_python_lib(), 'bzrlib/plugins')

感谢 MYYN 提供其他文档页面)

According to the bazaar website,
user plugins are looked for in ~/.bazaar/plugins by default, but may be overridden by the environment variable BZR_PLUGIN_PATH.
So test if this variable is set, otherwise return the default. In python:

import os
user_plugin_path = os.environ.get('BZR_PLUGIN_PATH', '~/.bazaar/plugins')

Edit: this works for unix based systems, for windows the uses plugin path is $APPDATA/bazaar/2.0/plugins.

The system wide plugin is in bzrlib/plugins, see Installing a plugin down the page here. Use distutils to get the prefix (e.g. /usr/lib/python2.4/site-packages/bzrlib/plugins/) :

from distutils.sysconfig import get_python_lib
global_plugin_path = os.path.join(get_python_lib(), 'bzrlib/plugins')

(Thanks to The MYYN for providing the other documentation page)

蓝礼 2024-08-20 13:45:20

查看 bzr 版本Bazaar 配置: 输出。另请参阅 bzrlib/version.py 中的函数 show_version

对于配置目录,请使用:

from bzrlib import config
print config.config_dir()

或者,对于用户插件路径(请参阅 bzrlib/plugin.py):

from bzrlib import plugin
print plugin.get_user_plugin_path()

有关插件路径的完整列表:

from bzrlib import plugin
print plugin.get_standard_plugins_path()

Have a look at the Bazaar configuration: output of bzr version. Also see function show_version in bzrlib/version.py.

For the configuration directory use:

from bzrlib import config
print config.config_dir()

Or, for the user plugin path (see bzrlib/plugin.py):

from bzrlib import plugin
print plugin.get_user_plugin_path()

For a full list of plugin paths:

from bzrlib import plugin
print plugin.get_standard_plugins_path()
硪扪都還晓 2024-08-20 13:45:20

如果您的系统中安装了 bzr,您可以使用以下 Python 代码片段来获取 bzr 查找插件的目录列表:

 >>> import os
 >>> from bzrlib import plugin
 >>> list_of_bzr_plugins_paths = [os.path.abspath(p) 
         for p in plugin.get_standard_plugins_path()]

If you have bzr installed in your system you can use following Python snippet to get the list of directories where bzr looking for plugins:

 >>> import os
 >>> from bzrlib import plugin
 >>> list_of_bzr_plugins_paths = [os.path.abspath(p) 
         for p in plugin.get_standard_plugins_path()]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文