mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
fix for no data
This commit is contained in:
@ -4,6 +4,8 @@ jc changelog
|
||||
- Update airport_s parser to fix error on parsing empty data
|
||||
- Update arp parser to fix error on parsing empty data
|
||||
- Update blkid parser to fix error on parsing empty data
|
||||
- Update crontab parser to fix error on parsing empty data
|
||||
- Update crontab_u parser to fix error on parsing empty data
|
||||
- Add tests to all parsers for no data condition
|
||||
|
||||
20200610 v1.11.4
|
||||
|
@ -132,7 +132,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'crontab command and file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -225,6 +225,7 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
|
@ -133,7 +133,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'crontab file parser with user support'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -226,6 +226,7 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
|
@ -17,6 +17,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_crontab_json = json.loads(f.read())
|
||||
|
||||
def test_crontab_nodata(self):
|
||||
"""
|
||||
Test 'crontab' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.crontab.parse('', quiet=True), {})
|
||||
|
||||
def test_crontab_centos_7_7(self):
|
||||
"""
|
||||
Test 'crontab' on Centos 7.7
|
||||
|
@ -23,6 +23,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab-u.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_crontab_u_json = json.loads(f.read())
|
||||
|
||||
def test_crontab_u_nodata(self):
|
||||
"""
|
||||
Test 'crontab' with no data (has a user field)
|
||||
"""
|
||||
self.assertEqual(jc.parsers.crontab_u.parse('', quiet=True), {})
|
||||
|
||||
def test_crontab_u_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'crontab' on Ubuntu 18.4 (has a user field)
|
||||
|
Reference in New Issue
Block a user