1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

df fix for trailining newline char

This commit is contained in:
Kelly Brazil
2022-05-12 16:06:44 -07:00
parent d7a884a567
commit 7047f0a449
4 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,7 @@ jc changelog
- Add git log command streaming parser
- Add top -b command parser tested on linux
- Add top -b command streaming parser tested on linux
- Fix df command parser for rare instances when a newline is found at the end
- Allow jc to pip install on unsupported python version 3.6
- Fix asciitable-m parser to skip some rows that contain column separator
characters in cell data. A warning message will be printed to STDOUT

View File

@ -120,4 +120,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@ -99,7 +99,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.9'
version = '1.10'
description = '`df` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -208,7 +208,9 @@ def parse(data, raw=False, quiet=False):
jc.utils.compatibility(__name__, info.compatible, quiet)
jc.utils.input_type_check(data)
cleandata = data.splitlines()
# remove blank lines
cleandata = list(filter(None, data.splitlines()))
fix_data = []
raw_output = []
filesystem_map = {}

View File

@ -125,6 +125,13 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.df.parse(self.generic_df_long_filesystem, quiet=True), self.generic_df_long_filesystem_json)
def test_df_centos_7_7_trailing_newline(self):
"""
Test plain 'df' on Centos 7.7 with a trailing newline
"""
cmd_output = self.centos_7_7_df + '\n'
self.assertEqual(jc.parsers.df.parse(cmd_output, quiet=True), self.centos_7_7_df_json)
if __name__ == '__main__':
unittest.main()