From eec8d5d2be922cd295f7888f656eef2545346168 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 1 Mar 2015 17:09:36 -0800 Subject: [PATCH] Doc rewording for #1330 --- beets/library.py | 17 ++++++++++++----- docs/changelog.rst | 2 +- docs/reference/query.rst | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/beets/library.py b/beets/library.py index fe9bee081..9b22fd4df 100644 --- a/beets/library.py +++ b/beets/library.py @@ -45,8 +45,9 @@ log = logging.getLogger('beets') class PathQuery(dbcore.FieldQuery): """A query that matches all items under a given path. - On Windows paths are case-insensitive by default, contrarly to UNIX - platforms. + Matching can either base case-sensitive or case-sensitive. By + default, the behavior depends on the OS: case-insensitive on Windows + and case-sensitive otherwise. """ escape_re = re.compile(r'[\\_%]') @@ -55,15 +56,21 @@ class PathQuery(dbcore.FieldQuery): _is_windows = platform.system() == 'Windows' def __init__(self, field, pattern, fast=True, case_sensitive=None): + """Create a path query. + + `case_sensitive` can be a bool or `None`, indicating that the + behavior should depend on the platform (the default). + """ super(PathQuery, self).__init__(field, pattern, fast) + # By default, the case sensitivity depends on the platform. if case_sensitive is None: - # setting this value as the default one would make it un-patchable - # and therefore un-testable case_sensitive = not self._is_windows + self.case_sensitive = case_sensitive + + # Use a normalized-case pattern for case-insensitive matches. if not case_sensitive: pattern = pattern.lower() - self.case_sensitive = case_sensitive # Match the path as a single file. self.file_path = util.bytestring_path(util.normpath(pattern)) diff --git a/docs/changelog.rst b/docs/changelog.rst index 449eb4017..11a64d3ad 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -76,7 +76,7 @@ Fixes: * :doc:`/plugins/replaygain`: Stop applying replaygain directly to source files when using the mp3gain backend. :bug:`1316` -* Path queries are case-sensitive on UNIX OSes. :bug:`1165` +* Path queries are case-sensitive on non-Windows OSes. :bug:`1165` * :doc:`/plugins/lyrics`: Silence a warning about insecure requests in the new MusixMatch backend. :bug:`1204` * Fix a crash when ``beet`` is invoked without arguments. :bug:`1205` diff --git a/docs/reference/query.rst b/docs/reference/query.rst index af676a50d..20c5360f8 100644 --- a/docs/reference/query.rst +++ b/docs/reference/query.rst @@ -184,7 +184,7 @@ Note that this only matches items that are *already in your library*, so a path query won't necessarily find *all* the audio files in a directory---just the ones you've already added to your beets library. -Such queries are case-sensitive on UNIX and case-insensitive on Microsoft +Path queries are case-sensitive on most platforms but case-insensitive on Windows. .. _query-sort: