X-Git-Url: http://dolda2000.com/gitweb/?p=automanga.git;a=blobdiff_plain;f=manga%2Fprofile.py;h=2ff6be5d9b4ff7b835e7989d653c73641137e03e;hp=87f02a9e5fffadebbe6c682f9c7ae87c2e97a77f;hb=271d68da6cb2a273fd3ce29e95c4a021cc6da125;hpb=68143b859bf970b53bc19ec19b25228a5ddfc60f diff --git a/manga/profile.py b/manga/profile.py index 87f02a9..2ff6be5 100644 --- a/manga/profile.py +++ b/manga/profile.py @@ -182,6 +182,30 @@ class profile(object): with openwdir(pj(basedir, "last"), "w") as f: f.write(self.name + "\n") + def getaliases(self): + ret = {} + if os.path.exists(pj(self.dir, "alias")): + with openwdir(pj(self.dir, "alias")) as f: + for ln in f: + ln = splitline(ln) + if len(ln) < 1: continue + if ln[0] == "alias" and len(ln) > 3: + ret[ln[1]] = ln[2], ln[3] + return ret + + def savealiases(self, map): + with openwdir(pj(self.dir, "alias"), "w") as f: + for nm, (libnm, id) in map.iteritems(): + f.write(consline("alias", nm, libnm, id) + "\n") + + def getalias(self, nm): + return self.getaliases()[nm] + + def setalias(self, nm, libnm, id): + aliases = self.getaliases() + aliases[nm] = libnm, id + self.savealiases(aliases) + @classmethod def byname(cls, name): if not name or name == "last" or name[0] == '.':