mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
fix for lines that start with tab
This commit is contained in:
@ -138,7 +138,7 @@ from jc.parsers.kv import parse as kv_parse
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = '`zpool status` command parser'
|
description = '`zpool status` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -233,7 +233,7 @@ def parse(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# preserve indentation in continuation lines
|
# preserve indentation in continuation lines
|
||||||
if line.startswith(' '):
|
if line.startswith(' ') or line.startswith('\t'):
|
||||||
pool_str += line + '\n'
|
pool_str += line + '\n'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
1
tests/fixtures/generic/zpool-status-v4.json
vendored
Normal file
1
tests/fixtures/generic/zpool-status-v4.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"pool":"pool1","state":"ONLINE","status":"Some supported and requested features are not enabled on the pool.\nThe pool can still be used, but some features are unavailable.","action":"Enable all features using 'zpool upgrade'. Once this is done,\nthe pool may no longer be accessible by software that does not support\nthe features. See zpool-features(7) for details.","scan":"scrub repaired 0B in 11:16:03 with 0 errors on Sun Feb 12 11:40:04 2023","config":[{"name":"pool1","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-0","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"wwn-0x5000c500c65ac66f","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"wwn-0x5000c500c5eee542","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-1","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"wwn-0x5000c500e39e8af6","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"wwn-0x5000c500e3b3a41e","state":"ONLINE","read":0,"write":0,"checksum":0}],"errors":"No known data errors"}]
|
21
tests/fixtures/generic/zpool-status-v4.out
vendored
Normal file
21
tests/fixtures/generic/zpool-status-v4.out
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
pool: pool1
|
||||||
|
state: ONLINE
|
||||||
|
status: Some supported and requested features are not enabled on the pool.
|
||||||
|
The pool can still be used, but some features are unavailable.
|
||||||
|
action: Enable all features using 'zpool upgrade'. Once this is done,
|
||||||
|
the pool may no longer be accessible by software that does not support
|
||||||
|
the features. See zpool-features(7) for details.
|
||||||
|
scan: scrub repaired 0B in 11:16:03 with 0 errors on Sun Feb 12 11:40:04 2023
|
||||||
|
config:
|
||||||
|
|
||||||
|
NAME STATE READ WRITE CKSUM
|
||||||
|
pool1 ONLINE 0 0 0
|
||||||
|
mirror-0 ONLINE 0 0 0
|
||||||
|
wwn-0x5000c500c65ac66f ONLINE 0 0 0
|
||||||
|
wwn-0x5000c500c5eee542 ONLINE 0 0 0
|
||||||
|
mirror-1 ONLINE 0 0 0
|
||||||
|
wwn-0x5000c500e39e8af6 ONLINE 0 0 0
|
||||||
|
wwn-0x5000c500e3b3a41e ONLINE 0 0 0
|
||||||
|
|
||||||
|
errors: No known data errors
|
||||||
|
|
@ -22,7 +22,10 @@ class MyTests(unittest.TestCase):
|
|||||||
'fixtures/generic/zpool-status-v2.json'),
|
'fixtures/generic/zpool-status-v2.json'),
|
||||||
'zpool_status3': (
|
'zpool_status3': (
|
||||||
'fixtures/generic/zpool-status-v3.out',
|
'fixtures/generic/zpool-status-v3.out',
|
||||||
'fixtures/generic/zpool-status-v3.json')
|
'fixtures/generic/zpool-status-v3.json'),
|
||||||
|
'zpool_status4': (
|
||||||
|
'fixtures/generic/zpool-status-v4.out',
|
||||||
|
'fixtures/generic/zpool-status-v4.json')
|
||||||
}
|
}
|
||||||
|
|
||||||
for file, filepaths in fixtures.items():
|
for file, filepaths in fixtures.items():
|
||||||
@ -66,6 +69,15 @@ class MyTests(unittest.TestCase):
|
|||||||
self.f_json['zpool_status3']
|
self.f_json['zpool_status3']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_zpool_status_v_with_tabs(self):
|
||||||
|
"""
|
||||||
|
Test 'zpool status -v' with tabs instead of spaces
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['zpool_status4'], quiet=True),
|
||||||
|
self.f_json['zpool_status4']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user