New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bracket argument to aunique #2399

Merged
merged 6 commits into from Jan 21, 2017

Conversation

Projects
None yet
2 participants
@diomekes

diomekes commented Jan 19, 2017

A little background as to why I felt this was needed:

If I have two albums that are disambiguated by albumdisambig, and one album has that field empty, then it would have an empty []. In this case, I would only want the brackets gone.

Also, if I do something like [$year%aunique{}], then I would have two sets of brackets, with the inner set possibly empty. Plus, in this case, if the inner brackets are removed, then there is still a white space after the year and before the closing bracket.

So this change does a few things:

  • It adds a third argument to %aunique{} that should be two characters to be used as brackets.
  • It removes the blank space along with any brackets created from an empty disambiguator.
  • It adds brackets when the fallback album_id is used as the disambiguator (I decided to add this for consistency, but maybe it was left out originally for a reason I'm not aware of).

This will close #2397.

Finally, I think adding the brackets to the album_id fallback messed up the test for library.py. I fixed it, but I don't know if I did it correctly.

And I'm totally fine if this request is considered unnecessary for whatever reason, especially if some of my changes look "ugly".

@sampsyo

Aha! Thanks for diagnosing this—you're right that empty brackets look weird and we should dispense with them. And in addition, the new brackets parameter seems useful. I'm all for this.

It would be awesome to have small tests for the new functionality (dropping empty disambiguation strings and changing the brackets) and a changelog entry.

@@ -1447,7 +1447,7 @@ def tmpl_time(s, fmt):
cur_fmt = beets.config['time_format'].as_str()
return time.strftime(fmt, time.strptime(s, cur_fmt))
def tmpl_aunique(self, keys=None, disam=None):
def tmpl_aunique(self, keys=None, disam=None, bracket=None):

This comment has been minimized.

@sampsyo

sampsyo Jan 19, 2017

Member

Could you please add a description of bracket to the docstring?

@sampsyo

sampsyo Jan 19, 2017

Member

Could you please add a description of bracket to the docstring?

Show outdated Hide outdated beets/library.py Outdated
Show outdated Hide outdated beets/library.py Outdated
Show outdated Hide outdated beets/library.py Outdated
Show outdated Hide outdated beets/library.py Outdated
Show outdated Hide outdated docs/reference/pathformat.rst Outdated
self._assert_dest(b'/base/foo 1/the title', self.i1)
self._assert_dest(b'/base/foo 2/the title', self.i2)
self._assert_dest(b'/base/foo [1]/the title', self.i1)
self._assert_dest(b'/base/foo [2]/the title', self.i2)

This comment has been minimized.

@sampsyo

sampsyo Jan 19, 2017

Member

That looks like the right change to me!

@sampsyo

sampsyo Jan 19, 2017

Member

That looks like the right change to me!

Show outdated Hide outdated test/test_library.py Outdated

diomekes added some commits Jan 20, 2017

diomekes
@sampsyo

Looking great. Here's one last suggestion and a question.

Show outdated Hide outdated beets/library.py Outdated
Show outdated Hide outdated docs/reference/pathformat.rst Outdated

diomekes added some commits Jan 21, 2017

sampsyo added a commit that referenced this pull request Jan 21, 2017

Merge pull request #2399 from diomekes/aunique-bracket
Add bracket argument to aunique

sampsyo added a commit that referenced this pull request Jan 21, 2017

Remove an unnecessary list conversion (#2399)
Indexing a string works just fine.

@sampsyo sampsyo merged commit 672fc36 into beetbox:master Jan 21, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

sampsyo added a commit that referenced this pull request Jan 21, 2017

Merge pull request #2399 from diomekes/aunique-bracket
Add bracket argument to aunique

sampsyo added a commit that referenced this pull request Jan 21, 2017

Remove an unnecessary list conversion (#2399)
Indexing a string works just fine.
@sampsyo

This comment has been minimized.

Show comment
Hide comment
@sampsyo

sampsyo Jan 21, 2017

Member

Fantastic; thank you for finishing this up! It's all merged.

Member

sampsyo commented Jan 21, 2017

Fantastic; thank you for finishing this up! It's all merged.

@diomekes diomekes deleted the diomekes:aunique-bracket branch Jan 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment