-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from adamjakab/devel
devel
- Loading branch information
Showing
13 changed files
with
184 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright: Copyright (c) 2020., Adam Jakab | ||
# | ||
# Author: Adam Jakab <adam at jakab dot pro> | ||
# Created: 3/27/20, 3:52 PM | ||
# License: See LICENSE.txt | ||
|
||
__author__ = u'Adam Jakab' | ||
__email__ = u'adam@jakab.pro' | ||
__copyright__ = u'Copyright (c) 2020, {} <{}>'.format(__author__, __email__) | ||
__license__ = u'License :: OSI Approved :: MIT License' | ||
__version__ = u'0.0.2' | ||
__status__ = u'Kickstarted' | ||
|
||
__PACKAGE_TITLE__ = u'Autofix' | ||
__PACKAGE_NAME__ = u'beets-autofix' | ||
__PACKAGE_DESCRIPTION__ = u'A beets plugin to execute repetitive tasks in one go.', | ||
__PACKAGE_URL__ = u'https://github.com/adamjakab/BeetsPluginAutofix' | ||
__PLUGIN_NAME__ = u'autofix' | ||
__PLUGIN_ALIAS__ = None | ||
__PLUGIN_SHORT_DESCRIPTION__ = u'execute repetitive tasks in one go' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright: Copyright (c) 2020., Adam Jakab | ||
# | ||
# Author: Adam Jakab <adam at jakab dot pro> | ||
# Created: 3/26/20, 8:14 PM | ||
# License: See LICENSE.txt | ||
|
||
from beetsplug.autofix.task import Task | ||
|
||
from beetsplug.autofix import common | ||
from beetsplug.yearfixer import YearFixerPlugin, YearFixerCommand | ||
|
||
|
||
class YearFixerTask(Task): | ||
plugin = None | ||
plugin_config = None | ||
year_fixed = False | ||
|
||
def __init__(self): | ||
super(YearFixerTask, self).__init__() | ||
assert common.is_plugin_enabled("yearfixer"), "The 'yearfixer' plugin is not enabled!" | ||
self.plugin = YearFixerPlugin() | ||
self.plugin_config = common.get_plugin_config("yearfixer") | ||
|
||
def setup(self, config, item): | ||
self.config = config | ||
self.item = item | ||
self.year_fixed = False | ||
|
||
def run(self): | ||
if not self._item_needs_processing(): | ||
return | ||
|
||
cmd: YearFixerCommand = self.plugin.commands()[0] | ||
|
||
orig_year = self.item.get("year") | ||
orig_original_year = self.item.get("original_year") | ||
self._say("Calling yearfixer plugin for item: {}".format(self.item), log_only=True) | ||
cmd.process_item(self.item) | ||
if orig_year != self.item.get("year") or orig_original_year != self.item.get("original_year"): | ||
self.year_fixed = True | ||
|
||
def _item_needs_processing(self): | ||
answer = False | ||
|
||
if not self.item.get("year") or not self.item.get("original_year"): | ||
answer = True | ||
|
||
return answer | ||
|
||
def needs_item_store(self): | ||
return self.year_fixed | ||
|
||
def needs_item_write(self): | ||
return self.year_fixed |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright: Copyright (c) 2020., Adam Jakab | ||
# | ||
# Author: Adam Jakab <adam at jakab dot pro> | ||
# Created: 3/26/20, 4:50 PM | ||
# License: See LICENSE.txt | ||
|
||
|
||
from beetsplug.autofix import about | ||
from test.helper import TestHelper, Assertions, \ | ||
PLUGIN_NAME, PLUGIN_SHORT_DESCRIPTION, PACKAGE_NAME, PACKAGE_TITLE, PLUGIN_VERSION, \ | ||
capture_log | ||
|
||
plg_log_ns = 'beets.{}'.format(PLUGIN_NAME) | ||
|
||
|
||
class CompletionTest(TestHelper, Assertions): | ||
"""Test invocation of the plugin and basic package health. | ||
""" | ||
|
||
def test_about_descriptor_file(self): | ||
self.assertTrue(hasattr(about, "__author__")) | ||
self.assertTrue(hasattr(about, "__email__")) | ||
self.assertTrue(hasattr(about, "__copyright__")) | ||
self.assertTrue(hasattr(about, "__license__")) | ||
self.assertTrue(hasattr(about, "__version__")) | ||
self.assertTrue(hasattr(about, "__status__")) | ||
self.assertTrue(hasattr(about, "__PACKAGE_TITLE__")) | ||
self.assertTrue(hasattr(about, "__PACKAGE_NAME__")) | ||
self.assertTrue(hasattr(about, "__PACKAGE_DESCRIPTION__")) | ||
self.assertTrue(hasattr(about, "__PACKAGE_URL__")) | ||
self.assertTrue(hasattr(about, "__PLUGIN_NAME__")) | ||
self.assertTrue(hasattr(about, "__PLUGIN_ALIAS__")) | ||
self.assertTrue(hasattr(about, "__PLUGIN_SHORT_DESCRIPTION__")) | ||
|
||
def test_application(self): | ||
output = self.runcli() | ||
self.assertIn(PLUGIN_NAME, output) | ||
self.assertIn(PLUGIN_SHORT_DESCRIPTION, output) | ||
|
||
def test_application_plugin_list(self): | ||
output = self.runcli("version") | ||
self.assertIn("plugins: {0}".format(PLUGIN_NAME), output) | ||
|
||
def test_run_plugin(self): | ||
with capture_log(plg_log_ns) as logs: | ||
self.runcli(PLUGIN_NAME) | ||
self.assertIn("autofix: Done.", "\n".join(logs)) | ||
|
||
def test_plugin_version(self): | ||
with capture_log(plg_log_ns) as logs: | ||
self.runcli(PLUGIN_NAME, "--version") | ||
|
||
versioninfo = "{pt}({pn}) plugin for Beets: v{ver}".format( | ||
pt=PACKAGE_TITLE, | ||
pn=PACKAGE_NAME, | ||
ver=PLUGIN_VERSION | ||
) | ||
self.assertIn(versioninfo, "\n".join(logs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright: Copyright (c) 2020., Adam Jakab | ||
# | ||
# Author: Adam Jakab <adam at jakab dot pro> | ||
# Created: 3/28/20, 11:21 AM | ||
# License: See LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters