我正在尝试从另一个 python 应用程序发布到我的鹈鹕博客,所以我没有pelican ./output -s settings.py
从命令行进行。
我已经修改了 pelican 以接受模拟的 argparse 之类的对象来传递它需要的东西,所以我已经将函数的内容移到了main
__init__.py
接受 args的命名函数runPelican(args)
,以及像这样模拟 Argparse 的应用程序,
class MockArgparse(object):
"""Mock for argparse's to pass to pelican
"""
def __init__(self, verbosity=True, theme=None, output=None, path=None, delete_outputdir=None,
settings=None, ignore_cache=None, cache_path=None, selected_paths=None, autoreload=None):
"""
Args:
path (str): content path
settings(str): settings python file path
"""
super(MockArgparse, self).__init__()
self.theme = theme
self.cache_path = cache_path
self.ignore_cache = ignore_cache
self.delete_outputdir = delete_outputdir
self.settings = settings
self.output = output
self.verbosity = verbosity
self.autoreload = autoreload
self.path = path
self.selected_paths = selected_paths
我从我的 python 应用程序中调用 runPelican,如下所示:
if make_entry(args):
import pelican
arg = MockArgparse(path=CONTENT_PATH, theme=THEME_PATH, output=OUTPUT_PATH, settings=SETTINGS_PATH)
pelican.runPelican(arg)
一切似乎都很好,但没有生成博客文章,我得到的唯一错误是
CRITICAL: SimplerXMLGenerator instance has no attribute '_write'
任何帮助将不胜感激。