Ejemplo n.º 1
0
def update_category(opts):
    session = table.Session()

    for s in query.get_by(session, opts):
        dirname = opts.to
        if opts.tags_to_category:
            join = "/".join([t.name for t in s.tags])
            dirname = os.path.join(dirname, join)

        category = query.CategoryQuery(session).get(dirname)
        dst = opts.root_direcotry + category.dirname

        if not opts.dry_run:
            content = s.filepath.content
            s.filepath.remove()
            s.category = category
            s.filepath.content = content
            session.add(s)
            session.commit()
        if opts.verbose:
            click.secho("move '%s' to '%s'" % (s, dst), fg='green')
Ejemplo n.º 2
0
def execute(opts):
    with open(opts.export, "w") as f:
        writer = csv.writer(f)
        for s in query.get_by(table.Session(), opts):
            if not opts.dry_run:
                writer.writerow(s.to_list())