def _gen_music_dir(verbose, um, targetdir, music, refresh): for link_name, entry in music.iteritems(): file, details=entry artist, album, _title = details if verbose: print "> processing music file: %s" % file ## generate album sub-dir ad=os.path.join(targetdir, "m", artist, album) ## don't worry if we can't create the 'album' sub-dir just yet safe_makedirs(ad) link_path=os.path.join(targetdir, "m", artist, album, link_name) exists=os.path.islink(link_path) if exists: if verbose: print "! symlink exists: %s" % link_path if refresh: try: os.unlink(link_path) except: pass if not exists or (exists and refresh): try: os.symlink(file, link_path) except: um.error(messages["error_symlink"] % link_path) sys.exit(1)
def _create_top_level_dirs(targetdir): m=os.path.join(targetdir, "m") d=os.path.join(targetdir, "d") safe_makedirs(m, ex=True) safe_makedirs(d, ex=True)