本文整理汇总了Python中hydeengine.siteinfo.SiteInfo类的典型用法代码示例。如果您正苦于以下问题:Python SiteInfo类的具体用法?Python SiteInfo怎么用?Python SiteInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SiteInfo类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_class
class TestCleanUrls:
def setup_class(self):
settings.GENERATE_ABSOLUTE_FS_URLS = False
settings.GENERATE_CLEAN_URLS = True
settings.APPEND_SLASH = False # See Also: TestCleanUrlsAppendSlash
settings.LISTING_PAGE_NAMES = ['listing']
self.site = SiteInfo(settings, TEST_SITE.path)
self.site.refresh()
settings.site = self.site.content_node
def test_homepage(self):
"""Regardless of whether APPEND_SLASH is true, the homepage's url
cannot be blank"""
assert self.site.content_node.listing_url == "/"
def test_regular_page(self):
"""Tests a non-listing page"""
page = self.site.content_node.children[1].children[2].pages[0]
assert page.name == "introducing-hyde.html"
assert page.url == "/blog/2009/introducing-hyde"
def test_auto_listing_page(self):
"""Tests listing pages whose filenames match the name of their
enclosing folders."""
blog = self.site.content_node.children[1]
assert blog.name == "blog"
assert blog.listing_url == "/blog"
def test_lpn_listing_page(self):
"""Tests listing pages whose names are in the LISTING_PAGE_NAMES
setting"""
page = self.site.content_node.children[1].children[0].listing_page
assert page.name == "listing.html"
assert page.url == "/blog/2007"
示例2: BaseHandler
class BaseHandler(tornado.web.RequestHandler):
def init_site(self, site, force=False):
if not site in self.settings['sites']:
raise Exception("Site [%s] is not configured." % (site, ))
self.site_path = FileSystemEntity(
self.settings['sites'][site]["path"]).humblepath
if not hasattr(settings, 'siteinfo'):
setup_env(self.site_path)
setattr(settings, 'siteinfo', {})
if not site in settings.siteinfo or force:
self.siteinfo = SiteInfo(settings, self.site_path)
self.siteinfo.refresh()
settings.siteinfo[site] = self.siteinfo
else:
self.siteinfo = settings.siteinfo[site]
def get(self, site):
self.init_site(site)
self.doget(site)
def doget(self, site): abstract
def post(self, site):
self.init_site(site)
self.dopost(site)
def dopost(self, site): abstract
示例3: test_recent_posts
def test_recent_posts(self):
site = SiteInfo(settings, TEST_SITE.path)
site.refresh()
self.generator = Generator(TEST_SITE.path)
self.generator.build_siteinfo()
self.generator.pre_process(site)
actual_resource = site.find_resource(File(site.content_folder.child('recent_posts.html')))
self.generator.process(actual_resource)
expected_text = File(
TEST_ROOT.child("recent_posts_dest.html")).read_all()
actual_text = actual_resource.temp_file.read_all()
assert expected_text == actual_text
示例4: test_render_direct
def test_render_direct(self):
render_folder = TEST_SITE.child_folder('content/render');
render_folder.make()
template_folder = TEST_SITE.child_folder('layout');
template_folder.make()
File(TEST_ROOT.child("render_tag/template.html")
).copy_to(template_folder.child('render.html'))
source = File(TEST_ROOT.child("render_tag/source.html")).copy_to(render_folder)
site = SiteInfo(settings, TEST_SITE.path)
site.refresh()
self.generator = Generator(TEST_SITE.path)
self.generator.build_siteinfo()
self.generator.pre_process(site)
actual_resource = site.find_resource(source)
self.generator.process(actual_resource)
expected_text = File(TEST_ROOT.child("render_tag/dest.html")).read_all()
actual_text = actual_resource.temp_file.read_all()
if ORIGINAL_PRE_PROCESSORS:
settings.SITE_PRE_PROCESSORS = ORIGINAL_PRE_PROCESSORS
assert_html_equals(expected_text, actual_text)
示例5: MonitorTests
class MonitorTests(object):
def clean_queue(self):
while not self.queue.empty():
try:
self.queue.get()
self.queue.task_done()
except Empty:
break
def setup_class(cls):
cls.site = None
cls.queue = Queue()
def teardown_class(cls):
if cls.site:
cls.site.dont_monitor()
def setup_method(self, method):
self.site = SiteInfo(settings, TEST_SITE.path)
self.site.refresh()
self.exception_queue = Queue()
self.clean_queue()
assert self.queue.empty()
示例6: init_site
def init_site(self, site, force=False):
if not site in self.settings["sites"]:
raise Exception("Site [%s] is not configured." % (site,))
self.site_path = FileSystemEntity(self.settings["sites"][site]["path"]).humblepath
if not hasattr(settings, "siteinfo"):
setup_env(self.site_path)
setattr(settings, "siteinfo", {})
if not site in settings.siteinfo or force:
self.siteinfo = SiteInfo(settings, self.site_path)
self.siteinfo.refresh()
settings.siteinfo[site] = self.siteinfo
else:
self.siteinfo = settings.siteinfo[site]
示例7: test_filters
def test_filters(self):
site = SiteInfo(settings, TEST_SITE.path)
for name in [".banjo", ".hidden", "junk.abc~"]:
f = File(site.content_folder.child(name))
self.files.append(f)
f.write("junk")
git = site.content_folder.child_folder(".git")
git_child = git.child_folder("child")
git_child_pack = File(git_child.child("pack"))
git.make()
git_child.make()
git_index = File(git.child("index"))
git_index.write("junk")
git_child_pack.write("junk")
original_exclude = settings.FILTER['exclude']
original_include = settings.FILTER['include']
settings.FILTER = {}
site = SiteInfo(settings, TEST_SITE.path)
site.refresh()
for f in self.files:
assert site.find_resource(f)
assert site.find_node(git)
assert site.find_resource(git_index)
assert site.find_node(git_child)
assert site.find_resource(git_child_pack)
settings.FILTER = {
'include': (),
'exclude': (".*","*~")
}
site = SiteInfo(settings, TEST_SITE.path)
site.refresh()
for f in self.files:
assert not site.find_resource(f)
assert not site.find_node(git)
assert not site.find_resource(git_index)
assert not site.find_node(git_child)
assert not site.find_resource(git_child_pack)
settings.FILTER = {
'include': (".banjo",),
'exclude': (".*","*~")
}
site = SiteInfo(settings, TEST_SITE.path)
site.refresh()
for f in self.files:
if f.name == ".banjo":
assert site.find_resource(f)
else:
assert not site.find_resource(f)
assert not site.find_node(git)
assert not site.find_resource(git_index)
settings.FILTER['exclude'] = original_exclude
settings.FILTER['include'] = original_include
self.files.append(git)
示例8: setup_method
def setup_method(self, method):
self.site = SiteInfo(settings, TEST_SITE.path)
self.site.refresh()
self.exception_queue = Queue()
self.clean_queue()
assert self.queue.empty()