mirror of
https://github.com/iluvcapra/mfbatch.git
synced 2025-12-31 08:50:51 +00:00
pylint
This commit is contained in:
@@ -14,7 +14,7 @@ import inspect
|
||||
from tqdm import tqdm
|
||||
|
||||
from mfbatch.util import readline_with_escaped_newlines
|
||||
import mfbatch.metaflac as flac
|
||||
import mfbatch.metaflac as metadata_funcs
|
||||
from mfbatch.commands import BatchfileParser
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def create_batch_list(command_file: str, recursive=True):
|
||||
flac_files = glob('./**/*.flac', recursive=recursive)
|
||||
flac_files = sorted(flac_files)
|
||||
for path in tqdm(flac_files, unit='File', desc='Scanning FLAC files'):
|
||||
this_file_metadata = flac.read_metadata(path)
|
||||
this_file_metadata = metadata_funcs.read_metadata(path)
|
||||
for this_key, this_value in this_file_metadata.items():
|
||||
if this_key not in metadatums:
|
||||
f.write(f":set {this_key} "
|
||||
@@ -66,7 +66,8 @@ def main():
|
||||
"""
|
||||
Entry point implementation
|
||||
"""
|
||||
op = ArgumentParser(prog='mfbatch', usage='%(prog)s (-c | -e | -W) [options]')
|
||||
op = ArgumentParser(
|
||||
prog='mfbatch', usage='%(prog)s (-c | -e | -W) [options]')
|
||||
|
||||
op.add_argument('-c', '--create', default=False,
|
||||
action='store_true',
|
||||
|
||||
@@ -11,7 +11,7 @@ import os.path
|
||||
|
||||
from typing import Dict, Tuple, Optional
|
||||
|
||||
from mfbatch.metaflac import write_metadata as flac
|
||||
from mfbatch.metaflac import write_metadata as flac
|
||||
|
||||
|
||||
class UnrecognizedCommandError(Exception):
|
||||
@@ -64,8 +64,10 @@ class CommandEnv:
|
||||
self.incr.pop(k, None)
|
||||
self.patterns.pop(k, None)
|
||||
|
||||
|
||||
def reset_keys(self):
|
||||
"""
|
||||
Reset all keys in the environment
|
||||
"""
|
||||
all_keys = list(self.metadatums.keys())
|
||||
|
||||
for key in all_keys:
|
||||
@@ -74,7 +76,6 @@ class CommandEnv:
|
||||
self.patterns = {}
|
||||
self.incr = {}
|
||||
|
||||
|
||||
def set_pattern(self, to: str, frm: str, pattern: str, repl: str):
|
||||
"""
|
||||
Establish a pattern replacement in the environment
|
||||
|
||||
@@ -6,42 +6,49 @@ from typing import cast
|
||||
|
||||
from mfbatch.commands import BatchfileParser
|
||||
|
||||
|
||||
class CommandTests(unittest.TestCase):
|
||||
"""
|
||||
Tests the BatchfileParser class
|
||||
"""
|
||||
def setUp(self):
|
||||
self.command_parser = BatchfileParser()
|
||||
self.command_parser.dry_run = False
|
||||
self.command_parser.write_metadata_f = MagicMock()
|
||||
self.command_parser.write_metadata_f = MagicMock()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testSetWithoutWrite(self):
|
||||
def test_set_without_write(self):
|
||||
"Test setting a key without writing"
|
||||
self.command_parser.set(['TYPE', 'Everything'])
|
||||
self.assertFalse(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).called)
|
||||
self.assertFalse(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).called)
|
||||
self.assertEqual(self.command_parser.env.metadatums['TYPE'],
|
||||
'Everything')
|
||||
|
||||
def testSetCommand(self):
|
||||
def test_set_command(self):
|
||||
"Test set command"
|
||||
self.command_parser.set(['X', 'Y'])
|
||||
self.command_parser.eval("./testfile.flac", lineno=1,
|
||||
interactive=False)
|
||||
self.assertTrue(cast(MagicMock,
|
||||
self.assertTrue(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).called)
|
||||
self.assertEqual(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).call_args.args,
|
||||
self.assertEqual(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).call_args.args,
|
||||
('./testfile.flac', {'X': 'Y'}))
|
||||
|
||||
def testUnsetCommand(self):
|
||||
def test_unset_command(self):
|
||||
"Test unset command"
|
||||
self.command_parser.set(['A', '1'])
|
||||
self.assertEqual(self.command_parser.env.metadatums['A'], '1')
|
||||
self.command_parser.unset(['A'])
|
||||
self.assertNotIn('A', self.command_parser.env.metadatums.keys())
|
||||
|
||||
def testSetP(self):
|
||||
pass
|
||||
def test_setp(self):
|
||||
"Test setp command"
|
||||
|
||||
def testEval(self):
|
||||
def test_eval(self):
|
||||
"Test eval"
|
||||
self.command_parser.eval(":set A 1", 1, False)
|
||||
self.assertEqual(self.command_parser.env.metadatums['A'], '1')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user