Dolda2000 GitWeb
/
automanga.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
75732d5
)
Added a lazy-loading dict of known, named libraries.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 11 May 2013 14:22:05 +0000
(16:22 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 11 May 2013 14:22:05 +0000
(16:22 +0200)
manga/lib.py
patch
|
blob
|
blame
|
history
diff --git
a/manga/lib.py
b/manga/lib.py
index
ffea7a3
..
2a11cb1
100644
(file)
--- a/
manga/lib.py
+++ b/
manga/lib.py
@@
-171,3
+171,18
@@
class cursor(object):
def __iter__(self):
return self
+
+def _lazymod(name):
+ return __import__(name, fromlist=["dummy"])
+class _lazydict(object):
+ def __init__(self):
+ self.bk = {}
+ def __setitem__(self, key, val):
+ self.bk[key] = "u", val
+ def __getitem__(self, key):
+ st, v = self.bk[key]
+ if st == "u":
+ v = self.bk[key] = v()
+ return v
+libraries = _lazydict()
+libraries["mf"] = lambda: _lazymod("manga.mangafox").library()