mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Add as_str shortcut to Confuse
This commit is contained in:
parent
c8816df9fd
commit
fa7b9999e7
1 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue