本文整理汇总了Python中pelican.Pelican.run方法的典型用法代码示例。如果您正苦于以下问题:Python Pelican.run方法的具体用法?Python Pelican.run怎么用?Python Pelican.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pelican.Pelican
的用法示例。
在下文中一共展示了Pelican.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
settings = read_settings(filename=SAMPLE_CONFIG, override={"PATH": INPUT_PATH, "OUTPUT_PATH": self.temp_path})
pelican = Pelican(settings=settings)
pelican.run()
dcmp = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "custom")))
self.assertFilesEqual(recursiveDiff(dcmp))
示例2: setUp
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def setUp (self, override = None):
self.output_path = mkdtemp (prefix = TEST_DIR_PREFIX)
self.content_path = mkdtemp (prefix = TEST_DIR_PREFIX)
settings = {
'PATH': self.content_path,
'OUTPUT_PATH': self.output_path,
'PLUGINS': [linkclass],
'CACKHE_CONTENT': False,
'LINKCLASS_INTERNAL_CLASS': INTERNAL_CLASS,
'LINKCLASS_EXTERNAL_CLASS': EXTERNAL_CLASS
}
if override:
settings.update (override)
## Generate the test Markdown source file
fid = open (os.path.join (self.content_path, '%s.md' % TEST_FILE_STEM),
'w')
fid.write ('''Title: Test
Date:
[%s](%s)
[%s](%s)
[%s](%s)
''' % (INTERNAL_TEXT, INTERNAL_LINK,
EXTERNAL_TEXT, EXTERNAL_LINK_HTTP,
EXTERNAL_TEXT, EXTERNAL_LINK_HTTPS))
fid.close ()
## Run teh Pelican instance
self.settings = read_settings (override = settings)
pelican = Pelican (settings = self.settings)
pelican.run ()
示例3: test_sites_generation
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_sites_generation(self):
'''Test generation of sites with the plugin
Compare with recorded output via ``git diff``.
To generate output for comparison run the command
``pelican -o test_data/output -s test_data/pelicanconf.py \
test_data/content``
Remember to remove the output/ folder before that.
'''
base_path = os.path.dirname(os.path.abspath(__file__))
base_path = os.path.join(base_path, 'test_data')
content_path = os.path.join(base_path, 'content')
output_path = os.path.join(base_path, 'output')
settings_path = os.path.join(base_path, 'pelicanconf.py')
settings = read_settings(path=settings_path, override={
'PATH': content_path,
'OUTPUT_PATH': self.temp_path,
'CACHE_PATH': self.temp_cache,
'PLUGINS': [i18ns],
}
)
pelican = Pelican(settings)
pelican.run()
# compare output
out, err = subprocess.Popen(
['git', 'diff', '--no-ext-diff', '--exit-code', '-w', output_path,
self.temp_path], env={'PAGER': ''},
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
self.assertFalse(out, 'non-empty `diff` stdout:\n{}'.format(out))
self.assertFalse(err, 'non-empty `diff` stderr:\n{}'.format(out))
示例4: run_pelican
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def run_pelican(self, settings):
implicit_settings = {
# Contains just stuff that isn't required by the m.css theme itself,
# but is needed to have the test setup working correctly
'RELATIVE_URLS': True,
'TIMEZONE': 'UTC',
'READERS': {'html': None},
'SITEURL': '.',
'PATH': os.path.join(self.path),
'OUTPUT_PATH': os.path.join(self.path, 'output'),
'PAGE_PATHS': [''],
'PAGE_SAVE_AS': '{slug}.html',
'PAGE_URL': '{slug}.html',
'PAGE_EXCLUDES': ['output'],
'ARTICLE_PATHS': ['articles'], # does not exist
# Don't render feeds, we don't want to test them all the time
'FEED_ALL_ATOM': None,
'CATEGORY_FEED_ATOM': None,
'THEME': '../pelican-theme',
'PLUGIN_PATHS': ['.'],
'THEME_STATIC_DIR': 'static',
'M_CSS_FILES': ['https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i',
'static/m-dark.css'],
'M_FINE_PRINT': None,
'M_DISABLE_SOCIAL_META_TAGS': True,
'DIRECT_TEMPLATES': [],
'SLUGIFY_SOURCE': 'basename'
}
implicit_settings.update(settings)
settings = read_settings(path=None, override=implicit_settings)
pelican = Pelican(settings=settings)
pelican.run()
示例5: TestPelicanResume
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
class TestPelicanResume(unittest.TestCase):
def setUp(self):
self.temp_path = mkdtemp(prefix="pelican_resume.")
self.settings = read_settings(path=None, override={
"PATH": INPUT_PATH,
"OUTPUT_PATH": self.temp_path,
"PLUGINS": [pelican_resume],
"FEED_ALL_ATOM": None,
"CATEGORY_FEED_ATOM": None,
"TRANSLATION_FEED_ATOM": None,
"AUTHOR_FEED_ATOM": None,
"AUTHOR_FEED_RSS": None,
})
self.pelican = Pelican(self.settings)
self.pelican.run()
def tearDown(self):
rmtree(self.temp_path)
def test_resume_exists(self):
pdf = os.path.join(self.temp_path, "pdfs", "resume.pdf")
self.assertTrue(os.path.exists(pdf))
self.assertTrue(os.stat(pdf).st_size > 0)
def test_moderncv(self):
self.assertTrue(os.path.exists(os.path.join(pelican_resume.CSS_DIR, "moderncv.css")))
示例6: test_custom_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
pelican = Pelican(path=INPUT_PATH, output_path=self.temp_path,
settings=read_settings(SAMPLE_CONFIG))
pelican.run()
diff = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "custom")))
self.assertFilesEqual(diff)
示例7: testKnitrSettings2
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def testKnitrSettings2(self):
settings = read_settings(path=None, override={
'LOAD_CONTENT_CACHE': False,
'PATH': self.contentdir,
'OUTPUT_PATH': self.outputdir,
'RMD_READER_KNITR_OPTS_CHUNK': {'fig.path' : '%s/' % self.figpath},
'RMD_READER_KNITR_OPTS_KNIT': {'progress' : True, 'verbose': True},
'RMD_READER_RENAME_PLOT': True,
'PLUGIN_PATHS': ['../'],
'PLUGINS': ['rmd_reader'],
})
pelican = Pelican(settings=settings)
pelican.run()
outputfilename = os.path.join(self.outputdir,'%s.html' % self.testtitle)
self.assertTrue(os.path.exists(outputfilename),'File %s was not created.' % outputfilename)
imagesdir = os.path.join(self.outputdir, self.figpath)
self.assertTrue(os.path.exists(imagesdir), 'figpath not created.')
imagefile = os.path.join(imagesdir, os.path.splitext(os.path.split(self.contentfile)[1])[0]) + '-1-1.png'
logging.debug(imagefile)
self.assertTrue(os.path.exists(imagefile), 'image correctly named.')
images = glob.glob('%s/*' % imagesdir)
logging.debug(images)
self.assertTrue(len(images) == 1,'Contents of images dir is not correct: %s' % ','.join(images))
示例8: test_custom_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
with temporary_folder() as temp_path:
pelican = Pelican(path=INPUT_PATH, output_path=temp_path,
settings=read_settings(SAMPLE_CONFIG))
pelican.run()
diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "custom")))
self.assertEqual(diff.left_only, [])
self.assertEqual(diff.right_only, [])
self.assertEqual(diff.diff_files, [])
示例9: test_basic_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate the output without raising any exception / issuing
# any warning.
with temporary_folder() as temp_path:
pelican = Pelican(path=INPUT_PATH, output_path=temp_path)
pelican.run()
diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic")))
self.assertEqual(diff.left_only, [])
self.assertEqual(diff.right_only, [])
self.assertEqual(diff.diff_files, [])
示例10: test_basic_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate correct output without raising any exception
settings = read_settings(filename=None, override={
'PATH': INPUT_PATH,
'OUTPUT_PATH': self.temp_path,
})
pelican = Pelican(settings=settings)
pelican.run()
dcmp = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "basic")))
self.assertFilesEqual(recursiveDiff(dcmp))
示例11: test_custom_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
settings = read_settings(path=SAMPLE_CONFIG, override={
'PATH': INPUT_PATH,
'OUTPUT_PATH': self.temp_path,
'LOCALE': locale.normalize('en_US'),
})
pelican = Pelican(settings=settings)
pelican.run()
dcmp = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "custom")))
self.assertFilesEqual(recursiveDiff(dcmp))
示例12: test_basic_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate the output without raising any exception / issuing
# any warning.
with temporary_folder() as temp_path:
pelican = Pelican(path=INPUT_PATH, output_path=temp_path)
pelican.run()
# the same thing with a specified set of settins should work
with temporary_folder() as temp_path:
pelican = Pelican(path=INPUT_PATH, output_path=temp_path,
settings=read_settings(SAMPLE_CONFIG))
示例13: pelican_generate
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def pelican_generate(files_path):
content_path = os.path.join(files_path, 'content')
conf_path = os.path.join(files_path, 'pelicanconf.py')
output_path = os.path.join(files_path, 'output')
settings = read_settings(conf_path)
pelican = Pelican(
settings=settings,
path=content_path,
output_path=output_path,
theme='notmyidea'
)
pelican.run()
示例14: call_pelican
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def call_pelican(settings_path, content_path):
settings_path = os.path.abspath(settings_path)
content_path = os.path.abspath(content_path)
settings = read_settings(settings_path)
settings_dir = os.path.split(settings_path)[0]
curdir = os.getcwd()
os.chdir(settings_dir)
settings["THEME"] = os.path.abspath(settings["THEME"])
os.chdir(curdir)
p = Pelican(settings=settings)
p.run()
示例15: test_basic_generation_works
# 需要导入模块: from pelican import Pelican [as 别名]
# 或者: from pelican.Pelican import run [as 别名]
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate the output without raising any exception / issuing
# any warning.
with patch("pelican.contents.getenv") as mock_getenv:
# force getenv('USER') to always return the same value
mock_getenv.return_value = "Dummy Author"
pelican = Pelican(path=INPUT_PATH, output_path=self.temp_path)
pelican.run()
diff = dircmp(
self.temp_path, os.sep.join((OUTPUT_PATH, "basic")))
self.assertFilesEqual(diff)