Inconsistency in relative path handling in the config

I’ve noticed that handling of relative paths in config.yaml is inconsistent, which makes it difficult to have a self contained library and beets configuration. It’d be nice if either this was consistent, or if we could use some form of templating scheme, i.e. string.format or string.Template, to access the most common paths. It could be worthwhile to provide a new type when plugins interact with the config to handle this transparently for their options as well, giving them an absolute path.

From what I’ve seen (where BEETSDIR is the path where config.yaml lives):

  • directory: relative to BEETSDIR
  • library: relative to BEETSDIR
  • pluginpath: relative to PWD
  • importfeeds: m3u: relative to directory
  • importfeeds: m3u_multi: relative to BEETSDIR
  • alternatives: relative to directory

Any thoughts on the cleanest way to address this? I was going to start working on a pull request, but would like to determine the correct approach.

-kergoth

Good catches! For what it’s worth, Confuse (our configuration library) provides built-in functionality that defaults to "relative to BEETSDIR". That’s the as_filename method—like this, for example.

Other config options that use as_str or just plain get should probably be changed to use as_filename.

Ah, great, thanks. That’s simple enough. pluginpath currently uses as_str_seq(), guessing we can just do [p.as_filename() for p in config[‘pluginpath’]] or so, instead?

Well, that one might be a bit more complicated. The as_str_seq thing is a bit more powerful—it can take a single string and split it on whitespace. Maybe we should leave that one alone for a little bit while we take a look at the others, which are hopefully easier?