Only give last part of path in subalbum listings.
This commit is contained in:
parent
141af1e1a4
commit
7ce3c03225
@ -8,12 +8,14 @@ def set_cache_path_base(base):
|
|||||||
trim_base.base = base
|
trim_base.base = base
|
||||||
def untrim_base(path):
|
def untrim_base(path):
|
||||||
return os.path.join(trim_base.base, path)
|
return os.path.join(trim_base.base, path)
|
||||||
def trim_base(path):
|
def trim_base_custom(path, base):
|
||||||
if path.startswith(trim_base.base):
|
if path.startswith(base):
|
||||||
path = path[len(trim_base.base):]
|
path = path[len(base):]
|
||||||
if path.startswith('/'):
|
if path.startswith('/'):
|
||||||
path = path[1:]
|
path = path[1:]
|
||||||
return path
|
return path
|
||||||
|
def trim_base(path):
|
||||||
|
return trim_base_custom(path, trim_base.base)
|
||||||
def cache_base(path):
|
def cache_base(path):
|
||||||
path = trim_base(path).replace('/', '-').replace(' ', '_')
|
path = trim_base(path).replace('/', '-').replace(' ', '_')
|
||||||
if len(path) == 0:
|
if len(path) == 0:
|
||||||
@ -88,14 +90,13 @@ class Album(object):
|
|||||||
def to_dict(self, cripple=True):
|
def to_dict(self, cripple=True):
|
||||||
self._sort()
|
self._sort()
|
||||||
if cripple:
|
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:
|
else:
|
||||||
subalbums = self._albums
|
subalbums = self._albums
|
||||||
return { "path": self.path, "date": self.date, "albums": subalbums, "photos": self._photos }
|
return { "path": self.path, "date": self.date, "albums": subalbums, "photos": self._photos }
|
||||||
def photo_from_path(self, path):
|
def photo_from_path(self, path):
|
||||||
for photo in self._photos:
|
for photo in self._photos:
|
||||||
if trim_base(path) == photo._path:
|
if trim_base(path) == photo._path:
|
||||||
print "cache hit %s" % path
|
|
||||||
return photo
|
return photo
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user