From 69905dde9b7efacd8a8d4f3f13e241ba11ba662d Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 21 Jan 2014 19:37:54 -0800 Subject: [PATCH] resolve FIXMEs from query refactor --- beets/dbcore/query.py | 11 +++++++---- beets/library.py | 11 +++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index f5d670956..755e45301 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -166,14 +166,17 @@ class NumericQuery(FieldQuery): ``year:2001..`` finds music released since the turn of the century. """ def _convert(self, s): - """Convert a string to the appropriate numeric type. If the + """Convert a string to a numeric type (float or int). If the string cannot be converted, return None. """ + # This is really just a bit of fun premature optimization. try: - # FIXME should work w/ either integer or float - return float(s) + return int(s) except ValueError: - return None + try: + return float(s) + except ValueError: + return None def __init__(self, field, pattern, fast=True): super(NumericQuery, self).__init__(field, pattern, fast) diff --git a/beets/library.py b/beets/library.py index e91d7676d..48af99f8d 100644 --- a/beets/library.py +++ b/beets/library.py @@ -239,7 +239,6 @@ class LibModel(dbcore.Model): """Shared concrete functionality for Items and Albums. """ _bytes_keys = ('path', 'artpath') - # FIXME should be able to replace this with field types. def _template_funcs(self): funcs = DefaultTemplateFunctions(self, self._db).functions() @@ -771,12 +770,12 @@ def parse_query_part(part, query_classes={}, prefixes={}, class is available, `default_class` is used. For instance, - parse_query('stapler') == (None, 'stapler', SubstringQuery) - parse_query('color:red') == ('color', 'red', SubstringQuery) - parse_query(':^Quiet') == (None, '^Quiet', RegexpQuery) - parse_query('color::b..e') == ('color', 'b..e', RegexpQuery) + 'stapler' -> (None, 'stapler', SubstringQuery) + 'color:red' -> ('color', 'red', SubstringQuery) + ':^Quiet' -> (None, '^Quiet', RegexpQuery) + 'color::b..e' -> ('color', 'b..e', RegexpQuery) - Prefixes may be 'escaped' with a backslash to disable the keying + Prefixes may be "escaped" with a backslash to disable the keying behavior. """ part = part.strip()