equal
deleted
inserted
replaced
36 return os.path.join(*(['..']*count)) |
36 return os.path.join(*(['..']*count)) |
37 |
37 |
38 class Folder (object) : |
38 class Folder (object) : |
39 def __init__ (self, name='.', parent=None) : |
39 def __init__ (self, name='.', parent=None) : |
40 # the directory name, no trailing / |
40 # the directory name, no trailing / |
41 self.name = name.rstrip(os.sep) |
41 self.name = unicode(name.rstrip(os.sep)) |
42 |
42 |
43 # our parent Folder, or None |
43 # our parent Folder, or None |
44 self.parent = parent |
44 self.parent = parent |
45 |
45 |
46 # the path to this dir, as a relative path to the root of the image gallery, always starts with . |
46 # the path to this dir, as a relative path to the root of the image gallery, always starts with . |
120 if (os.path.isdir(fpath) |
120 if (os.path.isdir(fpath) |
121 and (fname not in (settings.THUMB_DIR, settings.PREVIEW_DIR)) |
121 and (fname not in (settings.THUMB_DIR, settings.PREVIEW_DIR)) |
122 and (self.parent or fname not in settings.ROOT_IGNORE) |
122 and (self.parent or fname not in settings.ROOT_IGNORE) |
123 ) : |
123 ) : |
124 index.debug("Found subdir %s", fpath) |
124 index.debug("Found subdir %s", fpath) |
125 f = self.subdirs[fname] = Folder(fname, self) |
125 f = Folder(fname, self) |
126 if f.index(next_filter) : # recursion |
126 if f.index(next_filter) : # recursion |
127 # if a subdir is alive, we are alive as well |
127 # if a subdir is alive, we are alive as well |
|
128 self.subdirs[fname] = f |
128 self.alive = True |
129 self.alive = True |
129 |
130 |
130 # handle images |
131 # handle images |
131 elif os.path.isfile(fpath) and utils.isImage(fname) : |
132 elif os.path.isfile(fpath) and utils.isImage(fname) : |
132 index.debug("Found image %s", fname) |
133 index.debug("Found image %s", fname) |
164 title_path = self.pathFor(settings.TITLE_FILE) |
165 title_path = self.pathFor(settings.TITLE_FILE) |
165 |
166 |
166 self.title, self.descr = utils.readTitleDescr(title_path) |
167 self.title, self.descr = utils.readTitleDescr(title_path) |
167 |
168 |
168 # default title for the root dir |
169 # default title for the root dir |
169 if self.title : |
170 if self.title or self.descr : |
170 self.alive = True |
171 self.alive = True |
171 pass # use what was in the title file |
172 pass # use what was in the title file |
172 |
173 |
173 elif not self.parent : |
174 elif not self.parent : |
174 self.title = 'Index' |
175 self.title = 'Index' |
175 |
176 |
176 else : |
177 else : |
177 self.title = self.name |
178 self.title = self.name |
178 |
179 |
179 if self.descr : |
180 if not self.alive : |
180 self.alive = True |
181 index.debug("Dir %s isn't alive" % self.path) |
181 |
182 |
182 return self.alive |
183 return self.alive |
183 |
184 |
184 def getObjInfo (self) : |
185 def getObjInfo (self) : |
185 """ |
186 """ |