Skip to content

Commit da65553

Browse files
committed
Change function name and correct documentation style
1 parent 84da4b8 commit da65553

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

beetsplug/zero.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self):
4242
self.config.add({
4343
'fields': [],
4444
'keep_fields': [],
45-
'update_database': False
45+
'update_database': False,
4646
})
4747

4848
self.patterns = {}
@@ -51,15 +51,15 @@ def __init__(self):
5151
if self.config['fields']:
5252
self.validate_config('fields')
5353
for field in self.config['fields'].as_str_seq():
54-
self.write_patterns(field)
54+
self.set_pattern(field)
5555

5656
elif self.config['keep_fields']:
5757
self.validate_config('keep_fields')
5858

5959
for field in MediaFile.fields():
6060
if field in self.config['keep_fields'].as_str_seq():
6161
continue
62-
self.write_patterns(field)
62+
self.set_pattern(field)
6363

6464
# These fields should be preserved
6565
for key in ('id', 'path', 'album_id'):
@@ -79,7 +79,10 @@ def validate_config(self, mode):
7979
u'it would be dangerous', field)
8080
continue
8181

82-
def write_patterns(self, field):
82+
def set_pattern(self, field):
83+
"""Set a field in `self.patterns` to a string list corresponding to
84+
the configuration, or `True` if the field has no specific configuration.
85+
"""
8386
try:
8487
self.patterns[field] = self.config[field].as_str_seq()
8588
except confit.NotFoundError:

docs/plugins/zero.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ Zero Plugin
22
===========
33

44
The ``zero`` plugin allows you to null fields in files' metadata tags. Fields
5-
can be nulled unconditionally or conditioned on a pattern match. It works in
6-
two independent modes - blacklist and whitelist. You can only choose one option,
7-
however blacklist is the default. For example, the plugin can strip useless
8-
comments like "ripped by MyGreatRipper."
5+
can be nulled unconditionally or conditioned on a pattern match. For example,
6+
the plugin can strip useless comments like "ripped by MyGreatRipper."
97

108
To use the ``zero`` plugin, enable the plugin in your configuration
119
(see :ref:`using-plugins`).
@@ -20,9 +18,9 @@ fields to nullify and the conditions for nullifying them:
2018
get the list of all available fields by running ``beet fields``. In
2119
addition, the ``images`` field allows you to remove any images
2220
embedded in the media file.
23-
* Set ``keep_fields`` respectively to list of fields that plugin should
24-
preserve. That way ``zero`` cleans anything other than fields written in this
25-
option.
21+
* Set ``keep_fields`` to *invert* the logic of the plugin. Only these fields
22+
will be kept; other fields will be removed. Remember to set only
23+
``fields`` or ``keep_fields``, not both!
2624
* To conditionally filter a field, use ``field: [regexp, regexp]`` to specify
2725
regular expressions.
2826
* By default this plugin only affects files' tags ; the beets database is left
@@ -36,6 +34,10 @@ For example::
3634
genre: [rnb, 'power metal']
3735
update_database: true
3836

37+
The plugin can work in one of two modes. The first mode, the default,
38+
is a blacklist, where you choose the tags you want to remove. The second mode
39+
is a whitelist where you instead specify the tags you want to keep.
40+
3941
If a custom pattern is not defined for a given field, the field will be nulled
4042
unconditionally.
4143

0 commit comments

Comments
 (0)