def __init__(self, path): self.path = path_strip(path, DIRECTORY) self.url_rel = self.path.replace("\\","/") self.head = os.path.split(path)[0] self.filename = os.path.split(path)[1] self.filename_lower = self.filename.lower() # important for sorting self.filetype = get_file_type(self.filename)
def _walk(self, path, filelisting): """ Recursively walks the path and collects all files and directories. Danger: Symbolic links can create cycles and this function ends up in a regression. """ dirs, files = self.site.storage.listdir(path) if dirs: for d in dirs: self._walk(os.path.join(path, d), filelisting) filelisting.extend([path_strip(os.path.join(path,d), self.site.directory)]) if files: for f in files: filelisting.extend([path_strip(os.path.join(path,f), self.site.directory)])
def _walk(self, path, filelisting): """ Recursively walks the path and collects all files and directories. Danger: Symbolic links can create cycles and this function ends up in a regression. """ dirs, files = self.site.storage.listdir(path) if dirs: for d in dirs: self._walk(os.path.join(path, d), filelisting) filelisting.extend( [path_strip(os.path.join(path, d), self.site.directory)]) if files: for f in files: filelisting.extend( [path_strip(os.path.join(path, f), self.site.directory)])
def _path_relative_directory(self): "path relative to DIRECTORY" return path_strip(self.path, self.site.directory)
def _folder(self): return os.path.dirname( path_strip(os.path.join(self.head, ''), self.site.directory))
def _directory(self): return path_strip(self.path, self.site.directory)
def _folder(self): return path_strip(self.head, os.path.join(MEDIA_ROOT, DIRECTORY))
def _directory(self): return path_strip(self.path, os.path.join(MEDIA_ROOT, self.media_directory))
def _path_relative_directory(self): "path relative to MEDIA_ROOT + DIRECTORY" return path_strip(self.path, os.path.join(MEDIA_ROOT,self.media_directory))
def _path_relative(self): "path relative to MEDIA_ROOT" return path_strip(self.path, MEDIA_ROOT)
def _folder(self): return path_strip(self.head, self.media_root)
def _directory(self): return path_strip(self.path, self.media_root)
def _path_relative(self): "path relative to MEDIA_ROOT" return path_strip(self.path, self.media_root)
def _folder(self): return path_strip(self.head, os.path.join(MEDIA_ROOT, self.media_directory))
def _folder(self): return os.path.dirname(path_strip(os.path.join(self.head,''), self.site.directory))
def _directory(self): return path_strip(self.path, os.path.join(MEDIA_ROOT, DIRECTORY))