mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
fix for no data
This commit is contained in:
@ -216,7 +216,7 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
version = '1.4'
|
||||||
description = 'lsblk command parser'
|
description = 'lsblk command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -330,6 +330,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
linedata = data.splitlines()
|
linedata = data.splitlines()
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
cleandata = list(filter(None, linedata))
|
cleandata = list(filter(None, linedata))
|
||||||
|
raw_output = []
|
||||||
|
|
||||||
|
if cleandata:
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
|
||||||
cleandata[0] = cleandata[0].lower()
|
cleandata[0] = cleandata[0].lower()
|
||||||
|
@ -107,7 +107,7 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.1'
|
version = '1.2'
|
||||||
description = 'lsmod command parser'
|
description = 'lsmod command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -175,6 +175,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
raw_output = []
|
||||||
|
|
||||||
|
if list(filter(None, cleandata)):
|
||||||
cleandata[0] = cleandata[0].lower()
|
cleandata[0] = cleandata[0].lower()
|
||||||
|
|
||||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||||
|
@ -35,6 +35,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/lsblk-allcols.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/lsblk-allcols.json'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_lsblk_allcols_json = json.loads(f.read())
|
self.ubuntu_18_4_lsblk_allcols_json = json.loads(f.read())
|
||||||
|
|
||||||
|
def test_lsblk_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'lsblk' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.lsblk.parse('', quiet=True), [])
|
||||||
|
|
||||||
def test_lsblk_centos_7_7(self):
|
def test_lsblk_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test 'lsblk' on Centos 7.7
|
Test 'lsblk' on Centos 7.7
|
||||||
|
@ -23,6 +23,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/lsmod.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/lsmod.json'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_lsmod_json = json.loads(f.read())
|
self.ubuntu_18_4_lsmod_json = json.loads(f.read())
|
||||||
|
|
||||||
|
def test_lsmod_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'lsmod' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.lsmod.parse('', quiet=True), [])
|
||||||
|
|
||||||
def test_lsmod_centos_7_7(self):
|
def test_lsmod_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test 'lsmod' on Centos 7.7
|
Test 'lsmod' on Centos 7.7
|
||||||
|
Reference in New Issue
Block a user