Skip to content

Commit

Permalink
Reuse USAGE string to reduce duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
rdswift committed Oct 26, 2023
1 parent ceda8a4 commit c6e72e9
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions plugins/script_logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@

PLUGIN_NAME = 'Script Logger'
PLUGIN_AUTHOR = 'Bob Swift (rdswift)'
PLUGIN_DESCRIPTION = '''
This plugin provides a new script function `$logline()` to write entries
to Picard's system log. By default, the log level is set at `Info`, but
any level can be used by providing the level as an optional second
parameter to the function.
The function is used as:
PLUGIN_VERSION = '0.1'

USAGE = """\
`$logline(text[,level])`
where `text` is the text to write to the log. The entry will be written
Expand All @@ -42,29 +37,23 @@
If an unknown level is entered, the function will use the default `Info`
level.
'''
PLUGIN_VERSION = '0.1'
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.9']
PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.txt"
"""

PLUGIN_USER_GUIDE_URL = "https://github.com/rdswift/picard-plugins/blob/2.0_RDS_Plugins/plugins/script_logger/docs/README.md"
PLUGIN_DESCRIPTION = '''
This plugin provides a new script function `$logline()` to write entries
to Picard's system log. By default, the log level is set at `Info`, but
any level can be used by providing the level as an optional second
parameter to the function.
DOCUMENTATION = """\
`$logline(text[,level])`
The function is used as:
where `text` is the text to write to the log. The entry will be written
at log level `Info` by default, but this can be changed by specifying a
different level as an optional second parameter. Allowable log levels are:
''' + USAGE

- E (Error)
- W (Warning)
- I (Info)
- D (Debug)
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.9']
PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.txt"

If an unknown level is entered, the function will use the default `Info`
level.
"""
PLUGIN_USER_GUIDE_URL = "https://github.com/rdswift/picard-plugins/blob/2.0_RDS_Plugins/plugins/script_logger/docs/README.md"

from picard import log
from picard.script import register_script_function
Expand Down Expand Up @@ -93,4 +82,4 @@ def logline(_parser, text: str, level=None):
LEVELS[_level](text.strip())
return ''

register_script_function(logline, documentation=DOCUMENTATION)
register_script_function(logline, documentation=USAGE)

0 comments on commit c6e72e9

Please sign in to comment.