diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2011-05-05 09:04:06 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2011-05-05 09:04:06 -0400 |
commit | 7ce3c03225da2072bf37a7f39d9b06d477937ec0 (patch) | |
tree | c6540c420e8ffa5f42736b4286f63dd2dca46ad1 /PhotoAlbum.py | |
parent | Bigger square thumbs. (diff) | |
download | PhotoFloat-7ce3c03225da2072bf37a7f39d9b06d477937ec0.tar.xz PhotoFloat-7ce3c03225da2072bf37a7f39d9b06d477937ec0.zip |
Only give last part of path in subalbum listings.
Diffstat (limited to '')
-rw-r--r-- | PhotoAlbum.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/PhotoAlbum.py b/PhotoAlbum.py index 6c3f359..547ad61 100644 --- a/PhotoAlbum.py +++ b/PhotoAlbum.py @@ -8,12 +8,14 @@ def set_cache_path_base(base): trim_base.base = base def untrim_base(path): return os.path.join(trim_base.base, path) -def trim_base(path): - if path.startswith(trim_base.base): - path = path[len(trim_base.base):] +def trim_base_custom(path, base): + if path.startswith(base): + path = path[len(base):] if path.startswith('/'): path = path[1:] return path +def trim_base(path): + return trim_base_custom(path, trim_base.base) def cache_base(path): path = trim_base(path).replace('/', '-').replace(' ', '_') if len(path) == 0: @@ -88,14 +90,13 @@ class Album(object): def to_dict(self, cripple=True): self._sort() if cripple: - subalbums = [ { "path": sub.path, "date": sub.date } for sub in self._albums ] + subalbums = [ { "path": trim_base_custom(sub.path, self._path), "date": sub.date } for sub in self._albums ] else: subalbums = self._albums return { "path": self.path, "date": self.date, "albums": subalbums, "photos": self._photos } def photo_from_path(self, path): for photo in self._photos: if trim_base(path) == photo._path: - print "cache hit %s" % path return photo return None |