How to use the jc.parsers function in jc

To help you get started, we’ve selected a few jc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kellyjonbrazil / jc / tests / test_lsblk.py View on Github external
def test_lsblk_centos_7_7(self):
        """
        Test 'lsblk' on Centos 7.7
        """
        self.assertEqual(jc.parsers.lsblk.parse(self.centos_7_7_lsblk)[4], {'name': 'centos-swap',
                                                                            'maj_min': '253:1',
                                                                            'rm': '0',
                                                                            'size': '2G',
                                                                            'ro': '0',
                                                                            'type': 'lvm',
                                                                            'mountpoint': '[SWAP]'})
github kellyjonbrazil / jc / jc / parsers / crontab.py View on Github external
# Pop any shortcut lines
    shortcut_list = []
    for i, line in reversed(list(enumerate(cleandata))):
        if line.strip().startswith('@'):
            shortcut_line = cleandata.pop(i)
            occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
            cmd = shortcut_line.split(maxsplit=1)[1].strip()
            shortcut_list.append({'occurrence': occurrence,
                                  'command': cmd})

    # Add header row for parsing
    cleandata[0] = 'minute hour day_of_month month day_of_week command'

    if len(cleandata) > 1:
        cron_list = jc.parsers.universal.simple_table_parse(cleandata)

    raw_output['schedule'] = cron_list

    # Add shortcut entries back in
    for item in shortcut_list:
        raw_output['schedule'].append(item)

    if raw:
        return raw_output
    else:
        return process(raw_output)
github kellyjonbrazil / jc / jc / jc.py View on Github external
result = jc.parsers.ifconfig.parse(data, raw=raw, quiet=quiet)

    elif '--iptables' in sys.argv:
        result = jc.parsers.iptables.parse(data, raw=raw, quiet=quiet)

    elif '--jobs' in sys.argv:
        result = jc.parsers.jobs.parse(data, raw=raw, quiet=quiet)

    elif '--ls' in sys.argv:
        result = jc.parsers.ls.parse(data, raw=raw, quiet=quiet)

    elif '--lsblk' in sys.argv:
        result = jc.parsers.lsblk.parse(data, raw=raw, quiet=quiet)

    elif '--lsmod' in sys.argv:
        result = jc.parsers.lsmod.parse(data, raw=raw, quiet=quiet)

    elif '--lsof' in sys.argv:
        result = jc.parsers.lsof.parse(data, raw=raw, quiet=quiet)

    elif '--mount' in sys.argv:
        result = jc.parsers.mount.parse(data, raw=raw, quiet=quiet)

    elif '--netstat' in sys.argv:
        result = jc.parsers.netstat.parse(data, raw=raw, quiet=quiet)

    elif '--ps' in sys.argv:
        result = jc.parsers.ps.parse(data, raw=raw, quiet=quiet)

    elif '--route' in sys.argv:
        result = jc.parsers.route.parse(data, raw=raw, quiet=quiet)