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