beetbox / beetbox/beets

Using flexible attribute in path definition

Open
#816 6 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

This is a follow-up from a [discussion on the mailing-list](https://groups.google.com/forum/#!topic/beets-users/cuZ-hvk2prU).

When using flexible attributes in path definition, missing fields are not expanded, meaning that they appear in the result as they were defined in the path. For example :

```
beet ls -f '$test_attr' album:Madame
```

Could return someting like :

```
flexattr_value
$test_attr
$test_attr
flexattr_value
```

The current behavior has the following advantages :
- It provides a way to differentiate between a missing and empty field.
- It makes debugging path templates easier : you can easily see if you misspelled a field rather than just having it disappear.
- Symmetry with Python's built-in templating.

One the other hand, this can be quite annoying as you generally do not want the `$'field_name'` string to appear in your path and missing fields are very common when using flexible attributes.

They seems to be several option to make this simpler :
- create a new construct for path definition %ifdef{field,true,false}
- output an empty string for the missing field, one can always use the already existing %if construct to specify a default value when needed.

Contributor guide

Open the contributing guide

Research direction

Start with the path-definition and flexible-attribute behavior described in the issue, then review the linked mailing-list discussion to understand the unresolved alternatives. Use the shown `beet ls -f '$test_attr' album:Madame` example to compare missing-field behavior and define the expected result before identifying the relevant implementation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.