1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
This commit is contained in:
Kelly Brazil
2019-10-18 18:40:56 -07:00
parent 4d93b38fe4
commit a9294f32a0
3 changed files with 32 additions and 35 deletions

View File

@ -1,13 +1,10 @@
jc changelog
2019xxxx v0.5.0
20191018 v0.5.4
- Fix netstat -p parsing for Ubuntu
- Add ps parser
- Add route parser
+ Change some ifconfig fields to integers
+ Use maxsplit option in split in ls.py line 109... otherwise filenames with multiple spaces
between words can be incorrectly represented with the .join operation
+ Use list(filter(None, cleandata)) or list comprehension to clean any blank entries in ls.py line 98
- ls parser fixes
20191017 v0.2.0
- ifconfig, ls, and netstat support

View File

@ -89,25 +89,25 @@ import re
def parse(data):
output = []
cleandata = data.splitlines()
linedata = data.splitlines()
# Delete first line if it starts with 'total'
if cleandata[0].find('total') == 0:
cleandata.pop(0)
if linedata[0].find('total') == 0:
linedata.pop(0)
# Delete last line if it is blank
if cleandata[-1] == '':
cleandata.pop(-1)
# Clear any blank lines
cleandata = list(filter(None, linedata))
if cleandata:
# Check if -l was used to parse extra data
if re.match('^[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', cleandata[0]):
for entry in cleandata:
output_line = {}
parsed_line = entry.split()
parsed_line = entry.split(maxsplit=8)
# split filenames and links
filename_field = ' '.join(parsed_line[8:]).split(' -> ')
filename_field = parsed_line[8].split(' -> ')
# create list of dictionaries
output_line['filename'] = filename_field[0]

View File

@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
setuptools.setup(
name='jc',
version='0.5.3',
version='0.5.4',
author='Kelly Brazil',
author_email='kellyjonbrazil@gmail.com',
description='This tool serializes the output of popular command line tools to structured JSON output.',