Drop redundant filters

Dropping two filters that can be replaced by just using ternary and some
string concatenation instead.

Change-Id: I3893e62ecca0b8fe4f84e3a7570efedf99aa54cf
This commit is contained in:
Alex Schultz 2020-01-08 09:35:54 -07:00
parent 8c937edbae
commit af542e25b8
2 changed files with 1 additions and 45 deletions

View File

@ -18,16 +18,9 @@
class FilterModule(object):
def filters(self):
return {
'shell_arg_enabled': self.shell_arg_enabled,
'shell_arg_list': self.shell_arg_list,
'shell_logging_path': self.shell_logging_path
'shell_arg_list': self.shell_arg_list
}
def shell_arg_enabled(self, arg, enabled=True):
if not enabled:
return ''
return arg
def shell_arg_list(self, arg, parameter=None):
if not isinstance(arg, (list, tuple)):
arg = [arg]
@ -38,11 +31,3 @@ class FilterModule(object):
else:
return_value.append(a)
return ' '.join(return_value)
def shell_logging_path(self, location, combine=True, enabled=False):
output = ''
if not enabled:
return output
if combine:
output = "{} {}".format(output, '2>&1')
return "{} >{}".format(output, location)

View File

@ -24,14 +24,6 @@ class TestShellArgsFilters(tests_base.TestCase):
super(TestShellArgsFilters, self).setUp()
self.filter = shell_args.FilterModule()
def test_shell_arg_enabled_default(self):
self.assertEqual('foo',
self.filter.shell_arg_enabled('foo'))
def test_shell_arg_enabled_disabled(self):
self.assertEqual('',
self.filter.shell_arg_enabled('foo', enabled=False))
def test_shell_arg_list_default(self):
arg = ['a', 'b']
expected = 'a b'
@ -47,24 +39,3 @@ class TestShellArgsFilters(tests_base.TestCase):
expected = '--p a --p b'
self.assertEqual(expected,
self.filter.shell_arg_list(arg, parameter='--p'))
def test_shell_logging_path_default(self):
location = '/tmp/foo.log'
expected = ''
self.assertEqual(expected,
self.filter.shell_logging_path(location))
def test_shell_logging_path_enabled(self):
location = '/tmp/foo.log'
expected = ' 2>&1 >/tmp/foo.log'
self.assertEqual(expected,
self.filter.shell_logging_path(location,
enabled=True))
def test_shell_logging_path_enabled_not_combined(self):
location = '/tmp/foo.log'
expected = ' >/tmp/foo.log'
self.assertEqual(expected,
self.filter.shell_logging_path(location,
combine=False,
enabled=True))