"""
Implementations of the core CLI commands
"""
import log, shorturl, folder
def main (dir='.', targets=()) :
"""
Scan the given root dir for all images, and render updated ones
"""
root_filter = {}
# parse the targets into the hierarchial root_filter that we use
for target in targets :
f = root_filter
for path_part in target.split('/') :
if path_part :
if path_part not in f :
f[path_part] = {}
f = f[path_part]
# build the index
log.title("Indexing %s...", dir)
root = folder.Folder(dir)
root.index(root_filter)
log.up()
# XXX: maintain shorturls stuff
if False :
log.title("Syncing ShortURLs...")
shorturl.updateDB(root)
log.up()
# render output
log.title("Rendering updated dirs...")
root.render()
log.up()
return 0