Skip to content
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

Capitalize letters after punctuations #3411

Open
wants to merge 5 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -23,8 +23,8 @@
import time
import re
import six
import string

from titlecase import titlecase
from beets import logging
from mediafile import MediaFile, UnreadableFileError
from beets import plugins
@@ -130,17 +130,17 @@ def format(self, value):
return time.strftime(beets.config['time_format'].as_str(),
time.localtime(value or 0))

def parse(self, string):
def parse(self, s):

This comment has been minimized.

Copy link
@sampsyo

sampsyo Feb 15, 2020

Member

Let's change these argument names back (because the change is not relevant to the feature at hand).

try:
# Try a formatted date string.
return time.mktime(
time.strptime(string,
time.strptime(s,
beets.config['time_format'].as_str())
)
except ValueError:
# Fall back to a plain timestamp number.
try:
return float(string)
return float(s)
except ValueError:
return self.null

@@ -1485,7 +1485,7 @@ def tmpl_upper(s):
@staticmethod
def tmpl_title(s):
"""Convert a string to title case."""
return string.capwords(s)
return titlecase(s)

@staticmethod
def tmpl_left(s, chars):
@@ -73,6 +73,9 @@ New features:

Fixes:

* Fixed a bug where letters were not being capitalized after punctuation
characters when using the %title title case function.
:bug:`3298`
* :doc:`/plugins/inline`: In function-style field definitions that refer to
flexible attributes, values could stick around from one function invocation
to the next. This meant that, when displaying a list of objects, later
@@ -93,6 +93,7 @@ def build_manpages():
'pyyaml',
'mediafile>=0.2.0',
'confuse>=1.0.0',
'titlecase',
] + [
# Avoid a version of munkres incompatible with Python 3.
'munkres~=1.0.0' if sys.version_info < (3, 5, 0) else
@@ -118,7 +119,8 @@ def build_manpages():
'responses',
'pyxdg',
'python-mpd2',
'discogs-client'
'discogs-client',
'titlecase',
] + (
# Tests for the thumbnails plugin need pathlib on Python 2 too.
['pathlib'] if (sys.version_info < (3, 4, 0)) else []
@@ -585,13 +585,49 @@ def test_upper_case_variable(self):
self._assert_dest(b'/base/THE TITLE')

def test_title_case_variable(self):
self._setf(u'%title{$title}')
self._assert_dest(b'/base/The Title')
self._setf(u'%title{title}')
self._assert_dest(b'/base/Title')

This comment has been minimized.

Copy link
@sampsyo

sampsyo Feb 15, 2020

Member

I'm not sure why this test changed? We should add a new one if we just want to test non-variable title-casing.


def test_title_case_variable_aphostrophe(self):
self._setf(u'%title{I can\'t}')
self._assert_dest(b'/base/I Can\'t')

def test_title_case_variable_after_single_quote(self):
self._setf(u"%title{'title'}")
self._assert_dest(b"/base/'Title'")

def test_title_case_variable_after_slash(self):
self._setf(u'%title{first/second}')
self._assert_dest(b'/base/First/Second')

def test_title_case_variable_after_parenthesis(self):
self._setf(u'%title{(title)}')
self._assert_dest(b'/base/(Title)')

def test_title_case_variable_after_bracket(self):
self._setf(u'%title{[title]}')
self._assert_dest(b'/base/[Title]')

def test_title_case_variable_hythen_separator(self):
self._setf(u'%title{first-second}')
self._assert_dest(b'/base/First-Second')

def test_title_case_variable_single_slash_separator(self):
self._setf(u'%title{first/second}')
self._assert_dest(b'/base/First/Second')

def test_title_case_variable_small_words(self):
self._setf(u'%title{first and second}')
self._assert_dest(b'/base/First and Second')

def test_title_case_variable_all_caps(self):
self._setf(u'%title{THE TITLE}')
self._assert_dest(b'/base/The Title')

def test_title_case_variable_multi_words(self):
self._setf(u'%title{a longer title}')
self._assert_dest(b'/base/A Longer Title')

def test_asciify_variable(self):
self._setf(u'%asciify{ab\xa2\xbdd}')
self._assert_dest(b'/base/abC_ 1_2 d')
@@ -12,6 +12,7 @@ envlist = py27-test, py37-test, py27-flake8, docs
[_test]
deps =
beautifulsoup4
titlecase
flask
mock
nose
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.