From 8ece64f818373258091f9ea18f3757b75ed8959a Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Thu, 8 Dec 2011 15:36:29 +0530 Subject: [PATCH] Added simple copy basic feature --- hyde/site.py | 4 +++- hyde/tests/test_site.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/hyde/site.py b/hyde/site.py index 1dc31c9..c741cbf 100644 --- a/hyde/site.py +++ b/hyde/site.py @@ -330,9 +330,11 @@ class RootNode(Node): if not node: node = self.add_node(afile.parent) - resource = node.add_child_resource(afile) self.resource_map[unicode(afile)] = resource + relative_path = resource.relative_path + resource.simple_copy = any(fnmatch.fnmatch(relative_path, pattern) for pattern in self.site.config.simple_copy) + logger.debug("Added resource [%s] to [%s]" % (resource.relative_path, self.source_folder)) return resource diff --git a/hyde/tests/test_site.py b/hyde/tests/test_site.py index dda2b79..af5c658 100644 --- a/hyde/tests/test_site.py +++ b/hyde/tests/test_site.py @@ -277,3 +277,32 @@ class TestSiteWithConfig(object): assert not blog_node git_node = s.content.node_from_relative_path('.git') assert not git_node + +class TestSimpleCopy(object): + @classmethod + def setup_class(cls): + cls.SITE_PATH = File(__file__).parent.child_folder('sites/test_jinja_with_config') + cls.SITE_PATH.make() + TEST_SITE_ROOT.copy_contents_to(cls.SITE_PATH) + + @classmethod + def teardown_class(cls): + cls.SITE_PATH.delete() + + @nottest + def setup_config(self, passthru): + self.config_file = File(self.SITE_PATH.child('site.yaml')) + with open(self.config_file.path) as config: + conf = yaml.load(config) + conf['simple_copy'] = passthru + self.config = Config(sitepath=self.SITE_PATH, config_dict=conf) + + def test_simple_copy_basic(self): + self.setup_config([ + 'about.html' + ]) + s = Site(self.SITE_PATH, config=self.config) + s.load() + res = s.content.resource_from_relative_path('about.html') + assert res + assert res.simple_copy