From afd66b913158fdca95d1a30a0518808afb437374 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 12 May 2013 03:12:39 +0200 Subject: [PATCH] Coalesce local isolated pages. --- manga/local.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/manga/local.py b/manga/local.py index d1a839c..3051013 100644 --- a/manga/local.py +++ b/manga/local.py @@ -151,9 +151,15 @@ class manga(lib.manga): oids.append(cur) ret = [] for id in oids: - cur = interm(id, id, p.stack + [(p, len(ret))], []) - cur.direct = constree(cur, [(nm, st) for nm, st in structs if st[var[idx]] == id], idx + 1) - ret.append(cur) + sub = [(nm, st) for nm, st in structs if st[var[idx]] == id] + if len(sub) == 1: + nm, st = sub[0] + id = "".join(st[var[idx]:]) + ret.append(page(self, pj(self.path, orig[nm]), id, id, p.stack + [(p, len(ret))])) + else: + cur = interm(id, id, p.stack + [(p, len(ret))], []) + cur.direct = constree(cur, sub, idx + 1) + ret.append(cur) return ret return constree(self, structs, 0) -- 2.11.0