Browse Source

Added simple copy basic feature

main
Lakshmi Vyasarajan 13 years ago
parent
commit
8ece64f818
2 changed files with 32 additions and 1 deletions
  1. +3
    -1
      hyde/site.py
  2. +29
    -0
      hyde/tests/test_site.py

+ 3
- 1
hyde/site.py View File

@@ -330,9 +330,11 @@ class RootNode(Node):


if not node: if not node:
node = self.add_node(afile.parent) node = self.add_node(afile.parent)

resource = node.add_child_resource(afile) resource = node.add_child_resource(afile)
self.resource_map[unicode(afile)] = resource 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]" % logger.debug("Added resource [%s] to [%s]" %
(resource.relative_path, self.source_folder)) (resource.relative_path, self.source_folder))
return resource return resource


+ 29
- 0
hyde/tests/test_site.py View File

@@ -277,3 +277,32 @@ class TestSiteWithConfig(object):
assert not blog_node assert not blog_node
git_node = s.content.node_from_relative_path('.git') git_node = s.content.node_from_relative_path('.git')
assert not git_node 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

Loading…
Cancel
Save