From f86627177c2ed53f288f101364528b1e23e03ea8 Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Wed, 13 Apr 2011 12:48:24 +0530 Subject: [PATCH] Added path normalization to make sure resources can be found on windows using relative path --- hyde/site.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hyde/site.py b/hyde/site.py index cbeedb5..c403b42 100644 --- a/hyde/site.py +++ b/hyde/site.py @@ -8,7 +8,13 @@ from hyde.fs import FS, File, Folder from hyde.model import Config from hyde.util import getLoggerWithNullHandler +from functools import wraps +def path_normalized(f): + @wraps(f) + def wrapper(self, path): + return f(self, str(path).replace('/', os.sep)) + return wrapper logger = getLoggerWithNullHandler('hyde.engine') @@ -210,6 +216,7 @@ class RootNode(Node): self.resource_map = {} self.resource_deploy_map = {} + @path_normalized def node_from_path(self, path): """ Gets the node that maps to the given path. @@ -219,6 +226,7 @@ class RootNode(Node): return self return self.node_map.get(str(Folder(path)), None) + @path_normalized def node_from_relative_path(self, relative_path): """ Gets the content node that maps to the given relative path. @@ -227,6 +235,7 @@ class RootNode(Node): return self.node_from_path( self.source_folder.child(str(relative_path))) + @path_normalized def resource_from_path(self, path): """ Gets the resource that maps to the given path. @@ -234,6 +243,7 @@ class RootNode(Node): """ return self.resource_map.get(str(File(path)), None) + @path_normalized def resource_from_relative_path(self, relative_path): """ Gets the content resource that maps to the given relative path. @@ -249,6 +259,7 @@ class RootNode(Node): """ self.resource_deploy_map[str(resource.relative_deploy_path)] = resource + @path_normalized def resource_from_relative_deploy_path(self, relative_deploy_path): """ Gets the content resource whose deploy path maps to