예제 #1
0
파일: mpdstats.py 프로젝트: yejun5022/beets
 def get_item(self, path):
     """Return the beets item related to path.
     """
     query = library.PathQuery('path', path)
     item = self.lib.items(query).get()
     if item:
         return item
     else:
         self._log.info(u'item not found: {0}', displayable_path(path))
예제 #2
0
def handle_cli_exit(lib, **_kwargs):
    for src_dir, dst_dir in directories_moved.iteritems():
        if dst_dir is MULTIPLE_DESTS:
            print ("moves out of %s have multiple dests, will not moveall" %
                   (src_dir,))
            continue
        remaining_items = lib.items(library.PathQuery('path', src_dir))
        if next(iter(remaining_items), None):
            print "some Beets items left in %s, will not moveall" % (src_dir,)
        elif os.path.exists(src_dir):
            print "moving all leftovers in %s to %s" % (src_dir, dst_dir)
            for dirent in os.listdir(src_dir):
                dirent_path = os.path.join(src_dir, dirent)
                try:
                    shutil.move(dirent_path, dst_dir)
                except shutil.Error, ex:
                    # Log it but move on.
                    # XXX unicode problem here if path has non-ascii
                    log.critical("failed to move {0} to {1}: {2}", dirent_path,
                                 dst_dir, ex)
            util.prune_dirs(src_dir)