当前位置: 首页>>代码示例>>Python>>正文


Python SiteInfo.refresh方法代码示例

本文整理汇总了Python中hydeengine.siteinfo.SiteInfo.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python SiteInfo.refresh方法的具体用法?Python SiteInfo.refresh怎么用?Python SiteInfo.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hydeengine.siteinfo.SiteInfo的用法示例。


在下文中一共展示了SiteInfo.refresh方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BaseHandler

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
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
开发者ID:Psycojoker,项目名称:hyde,代码行数:32,代码来源:clyde.py

示例2: setup_class

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
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"
开发者ID:jmjeong,项目名称:hyde,代码行数:37,代码来源:test_urls.py

示例3: test_recent_posts

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
 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
开发者ID:timfreund,项目名称:hyde,代码行数:14,代码来源:test_hydetags.py

示例4: test_render_direct

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
 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)
开发者ID:pib,项目名称:hyde-old,代码行数:22,代码来源:test_hydetags.py

示例5: MonitorTests

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
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()
开发者ID:lachenmayer,项目名称:hyde,代码行数:25,代码来源:test_siteinfo.py

示例6: test_filters

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
    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)
开发者ID:lachenmayer,项目名称:hyde,代码行数:69,代码来源:test_siteinfo.py

示例7: setup_method

# 需要导入模块: from hydeengine.siteinfo import SiteInfo [as 别名]
# 或者: from hydeengine.siteinfo.SiteInfo import refresh [as 别名]
class TestSiteInfo:

    def setup_method(self, method):
        self.site = SiteInfo(settings, TEST_SITE.path)
        self.site.refresh()
        
    def assert_node_complete(self, node, folder):
        assert node.folder.path == folder.path
        test_case = self
        class Visitor(object):
            def visit_folder(self, folder):
                child = node.find_child(folder)
                assert child
                test_case.assert_node_complete(child, folder)
                
            def visit_file(self, a_file):
                assert node.find_resource(a_file)
        folder.list(Visitor())

    def test_population(self):
        assert self.site.name == "Your Site"
        self.assert_node_complete(self.site.content_node,
                                    TEST_SITE.child_folder("content"))
        self.assert_node_complete(self.site.media_node,
                                    TEST_SITE.child_folder("media"))
        self.assert_node_complete(self.site.layout_node, 
                                    TEST_SITE.child_folder("layout"))
        
    def test_type(self):
        def assert_node_type(node_dir, type):
           node = self.site.find_child(Folder(node_dir))
           assert node
           assert Folder(node_dir).same_as(node.folder)
           for child in node.walk():
               assert child.type == type
        assert_node_type(settings.CONTENT_DIR, "content")
        assert_node_type(settings.MEDIA_DIR, "media")
        assert_node_type(settings.LAYOUT_DIR, "layout")
            
        
    def test_attributes(self):
        for node in self.site.walk():
           self.assert_node_attributes(node)
           for resource in node.resources:
               self.assert_resource_attributes(resource)
                           
    def assert_node_attributes(self, node):
        fragment = self.get_node_fragment(node)
        if node.type == "content":
            fragment = node.folder.get_fragment(self.site.content_folder)
        elif node.type == "media":
            fragment = node.folder.get_fragment(self.site.folder)
        if node.type in ("content", "media"):
            fragment = ("/" + fragment.strip("/")).rstrip("/")
            assert fragment == node.url
            assert settings.SITE_WWW_URL + fragment == node.full_url
        else:    
            assert not node.url
            assert not node.full_url

        if node.type == "content":    
            for ancestor in node.ancestors:
                assert( 
                    ancestor.folder.is_ancestor_of(node.folder) or 
                    ancestor.folder.same_as(node.folder))
                
        assert node.source_folder == node.folder
        if not node == self.site and node.type not in ("content", "media"):
            assert not node.target_folder
            assert not node.temp_folder
        else:
            assert node.target_folder.same_as(Folder(
                            os.path.join(settings.DEPLOY_DIR,
                                fragment.lstrip("/"))))
            assert node.temp_folder.same_as(Folder(
                            os.path.join(settings.TMP_DIR, 
                                fragment.lstrip("/"))))
                       
    def assert_resource_attributes(self, resource):
        node = resource.node
        fragment = self.get_node_fragment(node)
        assert resource.name == resource.file.name
        if resource.node.type in ("content", "media"):
            assert (resource.url ==  
                        url.join(node.url, resource.file.name))
            assert (resource.full_url ==  
                        url.join(node.full_url, resource.file.name))
            assert resource.target_file.same_as(
                    File(node.target_folder.child(
                            resource.file.name)))
            assert resource.temp_file.same_as(
                    File(node.temp_folder.child(resource.file.name)))
        else:
            assert not resource.url
            assert not resource.full_url
        if resource.node.type == "content":
            self.assert_page_attributes(resource)
            
    def assert_page_attributes(self, page):
        if page.page_name in (
#.........这里部分代码省略.........
开发者ID:lachenmayer,项目名称:hyde,代码行数:103,代码来源:test_siteinfo.py


注:本文中的hydeengine.siteinfo.SiteInfo.refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。