Skip to content

Commit

Permalink
Fix formatting, and add python2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonTeixidor committed May 9, 2019
1 parent c5075b2 commit 7df4e23
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions beets/util/functemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,21 @@ def _parse(template):
parts.append(remainder)
return Expression(parts)

@functools.lru_cache(maxsize=128)

# Decorator that enables lru_cache on py3, and no caching on py2.
def cached(func):
if six.PY2:
# Sorry python2 users, no caching for you :(
return func
return functools.lru_cache(maxsize=128)(func)


@cached
def template(fmt):
return Template(fmt)

# External interface.

# External interface.
class Template(object):
"""A string template, including text, Symbols, and Calls.
"""
Expand Down

0 comments on commit 7df4e23

Please sign in to comment.