diff --git a/changelog.txt b/changelog.txt index 6686d308..4da7e577 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,9 +5,7 @@ jc changelog - Add OSX support for the arp parser - Add OSX support for the df parser - Add OSX support for the mount parser -- Add tests for ls on OSX -- Add tests for dig on OSX -- Add tests for ps on OSX +- Add tests for ls, dig, ps, w, uptime on OSX - Add universal parsers to refactor repetitive code - Updated ifconfig parser to output 'state' as an array diff --git a/jc/cli.py b/jc/cli.py index 71dc61d1..3373655c 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 """jc - JSON CLI output utility - JC cli module """ import sys @@ -37,52 +36,76 @@ import jc.parsers.uname import jc.parsers.uptime import jc.parsers.w +parser_map = { + '--arp': jc.parsers.arp, + '--df': jc.parsers.df, + '--dig': jc.parsers.dig, + '--env': jc.parsers.env, + '--free': jc.parsers.free, + '--fstab': jc.parsers.fstab, + '--history': jc.parsers.history, + '--hosts': jc.parsers.hosts, + '--ifconfig': jc.parsers.ifconfig, + '--iptables': jc.parsers.iptables, + '--jobs': jc.parsers.jobs, + '--ls': jc.parsers.ls, + '--lsblk': jc.parsers.lsblk, + '--lsmod': jc.parsers.lsmod, + '--lsof': jc.parsers.lsof, + '--mount': jc.parsers.mount, + '--netstat': jc.parsers.netstat, + '--ps': jc.parsers.ps, + '--route': jc.parsers.route, + '--ss': jc.parsers.ss, + '--stat': jc.parsers.stat, + '--systemctl': jc.parsers.systemctl, + '--systemctl-lj': jc.parsers.systemctl_lj, + '--systemctl-ls': jc.parsers.systemctl_ls, + '--systemctl-luf': jc.parsers.systemctl_luf, + '--uname': jc.parsers.uname, + '--uptime': jc.parsers.uptime, + '--w': jc.parsers.w +} + + +class info(): + version = '1.6.1' + description = 'jc cli' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + def ctrlc(signum, frame): exit() +def parsers_text(): + ptext = '' + for key in parser_map: + if hasattr(parser_map[key], 'info'): + padding = 16 - len(key) + padding_char = ' ' + padding_text = padding_char * padding + ptext += ' ' + key + padding_text + parser_map[key].info.description + '\n' + + return ptext + + def helptext(message): + parsers_string = parsers_text() + helptext_string = f''' jc: {message} Usage: jc PARSER [OPTIONS] Parsers: - --arp arp parser - --df df parser - --dig dig parser - --env env parser - --free free parser - --fstab /etc/fstab file parser - --history history parser - --hosts /etc/hosts file parser - --ifconfig iconfig parser - --iptables iptables parser - --jobs jobs parser - --ls ls parser - --lsblk lsblk parser - --lsmod lsmod parser - --lsof lsof parser - --mount mount parser - --netstat netstat parser - --ps ps parser - --route route parser - --ss ss parser - --stat stat parser - --systemctl systemctl parser - --systemctl-lj systemctl list-jobs parser - --systemctl-ls systemctl list-sockets parser - --systemctl-luf systemctl list-unit-files parser - --uname uname -a parser - --uptime uptime parser - --w w parser - +{parsers_string} Options: - -d debug - show trace messages - -p pretty print output - -q quiet - suppress warnings - -r raw JSON output + -d debug - show trace messages + -p pretty print output + -q quiet - suppress warnings + -r raw JSON output Example: ls -al | jc --ls -p @@ -116,51 +139,19 @@ def main(): if '-r' in sys.argv: raw = True - # parsers - parser_map = { - '--arp': jc.parsers.arp.parse, - '--df': jc.parsers.df.parse, - '--dig': jc.parsers.dig.parse, - '--env': jc.parsers.env.parse, - '--free': jc.parsers.free.parse, - '--fstab': jc.parsers.fstab.parse, - '--history': jc.parsers.history.parse, - '--hosts': jc.parsers.hosts.parse, - '--ifconfig': jc.parsers.ifconfig.parse, - '--iptables': jc.parsers.iptables.parse, - '--jobs': jc.parsers.jobs.parse, - '--ls': jc.parsers.ls.parse, - '--lsblk': jc.parsers.lsblk.parse, - '--lsmod': jc.parsers.lsmod.parse, - '--lsof': jc.parsers.lsof.parse, - '--mount': jc.parsers.mount.parse, - '--netstat': jc.parsers.netstat.parse, - '--ps': jc.parsers.ps.parse, - '--route': jc.parsers.route.parse, - '--ss': jc.parsers.ss.parse, - '--stat': jc.parsers.stat.parse, - '--systemctl': jc.parsers.systemctl.parse, - '--systemctl-lj': jc.parsers.systemctl_lj.parse, - '--systemctl-ls': jc.parsers.systemctl_ls.parse, - '--systemctl-luf': jc.parsers.systemctl_luf.parse, - '--uname': jc.parsers.uname.parse, - '--uptime': jc.parsers.uptime.parse, - '--w': jc.parsers.w.parse - } - found = False if debug: for arg in sys.argv: if arg in parser_map: - result = parser_map[arg](data, raw=raw, quiet=quiet) + result = parser_map[arg].parse(data, raw=raw, quiet=quiet) found = True break else: for arg in sys.argv: if arg in parser_map: try: - result = parser_map[arg](data, raw=raw, quiet=quiet) + result = parser_map[arg].parse(data, raw=raw, quiet=quiet) found = True break except: diff --git a/jc/parsers/arp.py b/jc/parsers/arp.py index df9eb31e..b8320758 100644 --- a/jc/parsers/arp.py +++ b/jc/parsers/arp.py @@ -2,7 +2,11 @@ Usage: - specify --arp as the first argument if the piped input is coming from arp + specify --arp as the first argument if the piped input is coming from: + + arp + or + arp -a Compatibility: @@ -86,6 +90,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.1' + description = 'arp parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'aix', 'freebsd', 'darwin'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -132,15 +146,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'aix', 'freebsd', 'darwin'] - if not quiet: - jc.utils.compatibility(__name__, compatible) - - # code adapted from Conor Heine at: - # https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501 + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() diff --git a/jc/parsers/df.py b/jc/parsers/df.py index f0b21b6e..e6a0e32d 100644 --- a/jc/parsers/df.py +++ b/jc/parsers/df.py @@ -72,6 +72,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.1' + description = 'df parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -166,11 +176,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() diff --git a/jc/parsers/dig.py b/jc/parsers/dig.py index 38850ea5..4bd1c528 100644 --- a/jc/parsers/dig.py +++ b/jc/parsers/dig.py @@ -323,6 +323,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'dig parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'aix', 'freebsd', 'darwin'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -509,11 +519,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] cleandata = data.splitlines() diff --git a/jc/parsers/env.py b/jc/parsers/env.py index f09e2ae3..421acdd4 100644 --- a/jc/parsers/env.py +++ b/jc/parsers/env.py @@ -51,6 +51,16 @@ Examples: import jc.utils +class info(): + version = '1.1' + description = 'env parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -96,12 +106,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = {} diff --git a/jc/parsers/foo.py b/jc/parsers/foo.py index e27cff4b..a0e44b84 100644 --- a/jc/parsers/foo.py +++ b/jc/parsers/foo.py @@ -19,6 +19,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'foo parser' + author = 'John Doe' + author_email = 'johndoe@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -58,12 +68,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] cleandata = data.splitlines() diff --git a/jc/parsers/free.py b/jc/parsers/free.py index 7585663f..c29a96b1 100644 --- a/jc/parsers/free.py +++ b/jc/parsers/free.py @@ -52,6 +52,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.0' + description = 'free parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -104,12 +114,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() cleandata[0] = cleandata[0].lower() diff --git a/jc/parsers/fstab.py b/jc/parsers/fstab.py index 647f3fe7..d8936e81 100644 --- a/jc/parsers/fstab.py +++ b/jc/parsers/fstab.py @@ -69,6 +69,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = '/etc/fstab file parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -119,12 +129,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] cleandata = data.splitlines() diff --git a/jc/parsers/history.py b/jc/parsers/history.py index bc8bf87e..b5aea12b 100644 --- a/jc/parsers/history.py +++ b/jc/parsers/history.py @@ -43,6 +43,16 @@ Examples: import jc +class info(): + version = '1.1' + description = 'history parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -88,12 +98,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = {} diff --git a/jc/parsers/hosts.py b/jc/parsers/hosts.py index 98abe658..3e5bc093 100644 --- a/jc/parsers/hosts.py +++ b/jc/parsers/hosts.py @@ -60,6 +60,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = '/etc/hosts file parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -100,12 +110,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] cleandata = data.splitlines() diff --git a/jc/parsers/ifconfig.py b/jc/parsers/ifconfig.py index f033dba7..720bd363 100644 --- a/jc/parsers/ifconfig.py +++ b/jc/parsers/ifconfig.py @@ -145,6 +145,17 @@ import jc.utils from ifconfigparser import IfconfigParser +class info(): + version = '1.5' + description = 'ifconfig parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + details = 'Using ifconfig-parser package from https://github.com/KnightWhoSayNi/ifconfig-parser' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'aix', 'freebsd', 'darwin'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -238,12 +249,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'aix', 'freebsd', 'darwin'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] diff --git a/jc/parsers/iptables.py b/jc/parsers/iptables.py index 8875861f..96e70a52 100644 --- a/jc/parsers/iptables.py +++ b/jc/parsers/iptables.py @@ -133,6 +133,16 @@ Examples: import jc.utils +class info(): + version = '1.1' + description = 'iptables parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -222,12 +232,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] chain = {} diff --git a/jc/parsers/jobs.py b/jc/parsers/jobs.py index 5b1b5a17..2d16f777 100644 --- a/jc/parsers/jobs.py +++ b/jc/parsers/jobs.py @@ -76,6 +76,16 @@ import string import jc.utils +class info(): + version = '1.0' + description = 'jobs parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -124,12 +134,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] diff --git a/jc/parsers/ls.py b/jc/parsers/ls.py index 34d0dda6..4190ce71 100644 --- a/jc/parsers/ls.py +++ b/jc/parsers/ls.py @@ -143,6 +143,16 @@ import re import jc.utils +class info(): + version = '1.0' + description = 'ls parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -195,12 +205,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] diff --git a/jc/parsers/lsblk.py b/jc/parsers/lsblk.py index 850f360c..17be124d 100644 --- a/jc/parsers/lsblk.py +++ b/jc/parsers/lsblk.py @@ -211,11 +211,20 @@ Examples: ... ] """ -import string import jc.utils import jc.parsers.universal +class info(): + version = '1.3' + description = 'lsblk parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -311,12 +320,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() # Clear any blank lines diff --git a/jc/parsers/lsmod.py b/jc/parsers/lsmod.py index 118109af..58340cde 100644 --- a/jc/parsers/lsmod.py +++ b/jc/parsers/lsmod.py @@ -106,6 +106,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.1' + description = 'lsmod parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -157,12 +167,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() cleandata[0] = cleandata[0].lower() diff --git a/jc/parsers/lsof.py b/jc/parsers/lsof.py index 76e799c1..223a3a65 100644 --- a/jc/parsers/lsof.py +++ b/jc/parsers/lsof.py @@ -96,6 +96,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.0' + description = 'lsof parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -150,12 +160,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] diff --git a/jc/parsers/mount.py b/jc/parsers/mount.py index 06949e27..d85675a0 100644 --- a/jc/parsers/mount.py +++ b/jc/parsers/mount.py @@ -55,6 +55,16 @@ Example: import jc.utils +class info(): + version = '1.1' + description = 'mount parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -141,12 +151,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() diff --git a/jc/parsers/netstat.py b/jc/parsers/netstat.py index 77c8bd18..b3f0e3b6 100644 --- a/jc/parsers/netstat.py +++ b/jc/parsers/netstat.py @@ -312,6 +312,16 @@ import string import jc.utils +class info(): + version = '1.0' + description = 'netstat parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -513,12 +523,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() cleandata = list(filter(None, cleandata)) diff --git a/jc/parsers/ps.py b/jc/parsers/ps.py index 82f31326..87f385ac 100644 --- a/jc/parsers/ps.py +++ b/jc/parsers/ps.py @@ -176,6 +176,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.1' + description = 'ps parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -264,12 +274,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines() cleandata[0] = cleandata[0].lower() diff --git a/jc/parsers/route.py b/jc/parsers/route.py index bd319c81..a5c9ca82 100644 --- a/jc/parsers/route.py +++ b/jc/parsers/route.py @@ -100,6 +100,16 @@ import jc.utils import jc.parsers.universal +class info(): + version = '1.0' + description = 'route parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -155,12 +165,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines()[1:] cleandata[0] = cleandata[0].lower() diff --git a/jc/parsers/ss.py b/jc/parsers/ss.py index cee708c5..e3259959 100644 --- a/jc/parsers/ss.py +++ b/jc/parsers/ss.py @@ -250,6 +250,16 @@ import string import jc.utils +class info(): + version = '1.0' + description = 'ss parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -323,12 +333,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6'] raw_output = [] diff --git a/jc/parsers/stat.py b/jc/parsers/stat.py index a12ffd86..929bb187 100644 --- a/jc/parsers/stat.py +++ b/jc/parsers/stat.py @@ -102,6 +102,15 @@ Examples: """ import jc.utils +class info(): + version = '1.0' + description = 'stat parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + def process(proc_data): """ @@ -174,12 +183,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = [] cleandata = data.splitlines() diff --git a/jc/parsers/systemctl.py b/jc/parsers/systemctl.py index 01f47efb..6e147c4e 100644 --- a/jc/parsers/systemctl.py +++ b/jc/parsers/systemctl.py @@ -39,6 +39,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'systemctl parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -79,12 +89,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() # Clear any blank lines diff --git a/jc/parsers/systemctl_lj.py b/jc/parsers/systemctl_lj.py index f9e1ea54..d0239b0d 100644 --- a/jc/parsers/systemctl_lj.py +++ b/jc/parsers/systemctl_lj.py @@ -58,6 +58,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'systemctl list-jobs parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -105,12 +115,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() # Clear any blank lines diff --git a/jc/parsers/systemctl_ls.py b/jc/parsers/systemctl_ls.py index 5ae7df41..bdcf3d7a 100644 --- a/jc/parsers/systemctl_ls.py +++ b/jc/parsers/systemctl_ls.py @@ -33,6 +33,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'systemctl list-sockets parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -71,12 +81,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() # Clear any blank lines diff --git a/jc/parsers/systemctl_luf.py b/jc/parsers/systemctl_luf.py index 33c66f55..3b9b2da6 100644 --- a/jc/parsers/systemctl_luf.py +++ b/jc/parsers/systemctl_luf.py @@ -30,6 +30,16 @@ Examples: import jc.utils +class info(): + version = '1.0' + description = 'systemctl list-unit-files parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -67,12 +77,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) linedata = data.splitlines() # Clear any blank lines diff --git a/jc/parsers/uname.py b/jc/parsers/uname.py index 5f2bca93..1132da08 100644 --- a/jc/parsers/uname.py +++ b/jc/parsers/uname.py @@ -29,6 +29,16 @@ Example: import jc.utils +class info(): + version = '1.0' + description = 'uname -a parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -70,12 +80,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = {} parsed_line = data.split(maxsplit=3) diff --git a/jc/parsers/uptime.py b/jc/parsers/uptime.py index eaa79300..331c1fc3 100644 --- a/jc/parsers/uptime.py +++ b/jc/parsers/uptime.py @@ -33,6 +33,16 @@ Example: import jc.utils +class info(): + version = '1.0' + description = 'uptime parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -89,12 +99,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) raw_output = {} diff --git a/jc/parsers/w.py b/jc/parsers/w.py index 86a2fd5b..47933319 100644 --- a/jc/parsers/w.py +++ b/jc/parsers/w.py @@ -82,6 +82,16 @@ import string import jc.utils +class info(): + version = '1.0' + description = 'w parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + def process(proc_data): """ Final processing to conform to the schema. @@ -131,12 +141,8 @@ def parse(data, raw=False, quiet=False): dictionary raw or processed structured data """ - - # compatible options: linux, darwin, cygwin, win32, aix, freebsd - compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - if not quiet: - jc.utils.compatibility(__name__, compatible) + jc.utils.compatibility(__name__, info.compatible) cleandata = data.splitlines()[1:] header_text = cleandata[0].lower()