From 9d1f2864240857468f0c23ca57074e25d578ac29 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 25 Mar 2013 19:47:29 +0100 Subject: [PATCH] Improved documentation. --- dosagelib/events.py | 8 +++++--- scripts/order-symlinks.py | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dosagelib/events.py b/dosagelib/events.py index d79766497..673218633 100644 --- a/dosagelib/events.py +++ b/dosagelib/events.py @@ -198,6 +198,7 @@ class JSONEventHandler(EventHandler): return fn def getComicData(self, comic): + """Return dictionary with comic info.""" if comic not in self.data: if os.path.exists(self.jsonFn(comic)): with codecs.open(self.jsonFn(comic), 'r', 'utf-8') as f: @@ -207,6 +208,7 @@ class JSONEventHandler(EventHandler): return self.data[comic] def getPageInfo(self, comic, url): + """Return dictionary with comic page info.""" comicData = self.getComicData(comic) if url not in comicData['pages']: comicData['pages'][url] = {'images':{}} @@ -260,12 +262,12 @@ class MultiHandler(object): """Encapsulate a list of handlers.""" def start(self): - """Emit a start event. Should be overridden in subclass.""" + """Emit start events for handlers.""" for handler in _handlers: handler.start() def comicDownloaded(self, comic, filename): - """Emit a comic downloaded event. Should be overridden in subclass.""" + """Emit comic downloaded events for handlers.""" for handler in _handlers: handler.comicDownloaded(comic, filename) @@ -275,7 +277,7 @@ class MultiHandler(object): handler.comicPageLink(comic, url, prevUrl) def end(self): - """Emit an end event. Should be overridden in subclass.""" + """Emit end events for handlers.""" for handler in _handlers: handler.end() diff --git a/scripts/order-symlinks.py b/scripts/order-symlinks.py index 3d1308f91..413bfce8b 100755 --- a/scripts/order-symlinks.py +++ b/scripts/order-symlinks.py @@ -12,14 +12,16 @@ import codecs import json def jsonFn(d): + """Get JSON filename.""" return os.path.join(d, 'dosage.json') def loadJson(d): + """Return JSON data.""" with codecs.open(jsonFn(d), 'r', 'utf-8') as f: - data = json.load(f) - return data + return json.load(f) def prepare_output(d): + """Clean pre-existing links in output directory.""" outDir = os.path.join(d, 'inorder') if not os.path.exists(outDir): os.mkdir(outDir) @@ -30,6 +32,7 @@ def prepare_output(d): return outDir def create_symlinks(d): + """Create new symbolic links in output directory.""" data = loadJson(d) outDir = prepare_output(d)