Skip to content

Using flexible attribute in path definition #816

@PierreRust

Description

@PierreRust

This is a follow-up from a discussion on the mailing-list.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions