def modify(opts, paths): cache = dumbattr.CachingAttributeStore() for path in paths: attrs = dumbattr.load(path) tags = util.get_tags(attrs) orig_tags = tags.copy() if opts.set_tags is not None: tags = util.parse_tag_str(opts.set_tags) else: tags.update(opts.add_tags) tags.difference_update(opts.remove_tags) if tags != orig_tags: if tags: attrs[TAGS] = util.render_tags(tags) else: del attrs[TAGS] # print "Updated tags to %r for %s" % (tags, path) if opts.set_rating is not None: if opts.set_rating: attrs[RATING] = str(opts.set_rating) else: del attrs[RATING] # print "Updated rating to %r for %s" % (rating, path) if opts.set_comment is not None: if opts.set_comment: attrs[COMMENT] = opts.set_comment else: del attrs[COMMENT]
def ls(roots, show_details=True): for root in roots: for path, attrs in _each(root): _print(path, rating=util.get_rating(attrs), tags=util.get_tags(attrs), comment=util.get_comment(attrs), show_details=show_details)
def ls(roots, show_details=True): for root in roots: for path, attrs in _each(root): _print( path, rating=util.get_rating(attrs), tags=util.get_tags(attrs), comment=util.get_comment(attrs), show_details=show_details)
def query(predicate, roots, show_details=True): expr = compile(predicate, '(predicate)', 'eval') for root in roots: for path, attrs in _each(root): rating = util.get_rating(attrs) tags = util.get_tags(attrs) comment = util.get_comment(attrs) show = eval(expr, { 'rating': rating, 'tags': tags, 'r':rating, 't':tags, 'comment':comment, 'c':comment, 'op':operator, }) if show: _print(path, rating=rating, tags=tags, comment=comment, show_details=show_details)
def query(predicate, roots, show_details=True): expr = compile(predicate, '(predicate)', 'eval') for root in roots: for path, attrs in _each(root): rating = util.get_rating(attrs) tags = util.get_tags(attrs) comment = util.get_comment(attrs) show = eval( expr, { 'rating': rating, 'tags': tags, 'r': rating, 't': tags, 'comment': comment, 'c': comment, 'op': operator, }) if show: _print(path, rating=rating, tags=tags, comment=comment, show_details=show_details)