From fa7b9999e75e81a47ee27376b2f6b8e5b8a86dff Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 25 Jun 2016 19:06:01 -0700 Subject: [PATCH] Add `as_str` shortcut to Confuse --- beets/util/confit.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/beets/util/confit.py b/beets/util/confit.py index 61062839b..f2a919cd4 100644 --- a/beets/util/confit.py +++ b/beets/util/confit.py @@ -386,17 +386,34 @@ class ConfigView(object): # Shortcuts for common templates. def as_filename(self): + """Get the value as a path. Equivalent to `get(Filename())`. + """ return self.get(Filename()) def as_choice(self, choices): + """Get the value from a list of choices. Equivalent to + `get(Choice(choices))`. + """ return self.get(Choice(choices)) def as_number(self): + """Get the value as any number type: int or float. Equivalent to + `get(Number())`. + """ return self.get(Number()) def as_str_seq(self): + """Get the value as a sequence of strings. Equivalent to + `get(StrSeq())`. + """ return self.get(StrSeq()) + def as_str(self): + """Get the value as a (Unicode) string. Equivalent to + `get(unicode)` on Python 2 and `get(str)` on Python 3. + """ + return self.get(String()) + # Redaction. @property