mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
#482 Quickfix to parse mount output
This commit is contained in:
@ -70,6 +70,8 @@ Example:
|
||||
...
|
||||
]
|
||||
"""
|
||||
import re
|
||||
|
||||
import jc.utils
|
||||
|
||||
|
||||
@ -133,15 +135,25 @@ def _linux_parse(data):
|
||||
|
||||
for entry in data:
|
||||
output_line = {}
|
||||
parsed_line = entry.split()
|
||||
|
||||
output_line['filesystem'] = parsed_line[0]
|
||||
output_line['mount_point'] = parsed_line[2]
|
||||
output_line['type'] = parsed_line[4]
|
||||
output_line['options'] = parsed_line[5].lstrip('(').rstrip(')').split(',')
|
||||
pattern = re.compile(
|
||||
r'''
|
||||
(?P<filesystem>\S+)\s+
|
||||
on\s+
|
||||
(?P<mount_point>.*?)\s+
|
||||
type\s+
|
||||
(?P<type>\S+)\s+
|
||||
\((?P<options>.*?)\)\s*''',
|
||||
re.VERBOSE)
|
||||
|
||||
match = pattern.match(entry)
|
||||
groups = match.groupdict()
|
||||
|
||||
output_line['filesystem'] = groups["filesystem"]
|
||||
output_line['mount_point'] = groups["mount_point"]
|
||||
output_line['type'] = groups["type"]
|
||||
output_line['options'] = groups["options"].split(',')
|
||||
output.append(output_line)
|
||||
|
||||
return output
|
||||
|
||||
def _aix_parse(data):
|
||||
|
Reference in New Issue
Block a user