手册:Pywikibot/兼容/弃用内容

This page is a translated version of the page Manual:Pywikibot/Compat/deprecation and the translation is 40% complete.
Outdated translations are marked like this.

Pywikibot兼容版已弃用。仍然使用兼容版的用户应迁移到核心版本。

背景

Pywikibot(后更名为“Pywikipediabot”)于2002年开始开发。当时 MediaWiki 并没有 API 接口所以 pywikibot 使用屏幕抓取技术(英文)来与 MediaWiki 交互。2007年新的分支(经过重写,现在是核心版本) 使用当时新的 MediaWiki API 抓取数据。多年以来,核心版本变得越来越成熟,许多脚本也迁移到了核心版本。在2013年核心版本在更新次数上超过了兼容版本。2015年 Pywikibot 的开发者们决定 停止对 Pywikibot 兼容版本的开发与支持。(参见phab:T99365phab:T101214)。 In 2002 MediaWiki didn't have an api so pywikibot used screen scraping to interact with MediaWiki. In 2007 a new branch (rewrite, now core) was started from scratch using the (then new) MediaWiki api. Over the years core got more mature and most scripts were migrated. In 2013 core surpassed compat in number of changes. In 2015 the developers of Pywikibot decided to deprecate the compat version of Pywikibot and discontinue support for compat (see phab:T99365 and phab:T101214). MediaWiki 1.27 曾是由兼容分支所支持的最后一个发行版本(参见phab:T150613)。

使用脚本

如果你正在使用 Pywikibot 脚本的话,你可以马上安装 Pywikibot 核心版本。大多数脚本已经迁移。 Pywikibot 核心版本使用包装器来运行所有脚本。如果你正在使用标准脚本(例如 redirect.py ),你可以使用 pwb.py 来运行。例如: Most scripts have been migrated. Pywikibot core uses a wrapper to run all the scripts. If you are using standard scripts (like redirect.py), you can run it in core by using pwb.py. For example:

$ python pwb.py redirect # instead of python redirect.py

迁移代码

如果你已经在兼容版本下编写了代码,可以在这里找到新旧版本的差异,你还可以在这里 找到自动迁移的代码。 And there is a script that automatically port your compat-based scripts to core.

如果你对代码迁移有译文欢迎联系我们

已知问题

pywikibot.Site().dbName() 不再添加 “_p” 前缀,所以如果你使用 MySQL 库来链接 WMF 实验室数据库的话,你必须在数据库名字的尾部手动添加 “_p” 。例如:

mysqldb.connect("testwiki.labsdb", db = pywikibot.Site().dbName() + "_p", user = config.db_username, passwd = config.db_password)

发现了阻止发布的 bug 时

如果你发现了任何阻止你在核心版本里运行脚本的 bug ,请在

Phabricator  提交错误报告(如果没有提交过的话),并在phab:T99365中提出。