Cache photodbs throughout runtime.
This commit is contained in:
parent
d531c66bf0
commit
3738a60195
1 changed files with 8 additions and 0 deletions
|
@ -8,15 +8,23 @@ import etiquette
|
||||||
class CantFindPhotoDB(Exception):
|
class CantFindPhotoDB(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
photodbs = {}
|
||||||
|
|
||||||
def find_photodb():
|
def find_photodb():
|
||||||
path = pathclass.cwd()
|
path = pathclass.cwd()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
|
return photodbs[path]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
if path.with_child('_etiquette').is_dir:
|
if path.with_child('_etiquette').is_dir:
|
||||||
break
|
break
|
||||||
if path == path.parent:
|
if path == path.parent:
|
||||||
raise CantFindPhotoDB()
|
raise CantFindPhotoDB()
|
||||||
path = path.parent
|
path = path.parent
|
||||||
photodb = etiquette.photodb.PhotoDB(path.with_child('_etiquette'), create=False)
|
photodb = etiquette.photodb.PhotoDB(path.with_child('_etiquette'), create=False)
|
||||||
|
photodbs[path] = photodb
|
||||||
return photodb
|
return photodb
|
||||||
|
|
||||||
def search_argparse(args):
|
def search_argparse(args):
|
||||||
|
|
Loading…
Reference in a new issue