1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00
Files
.github
docs
parsers
acpi.md
airport.md
airport_s.md
arp.md
asciitable.md
asciitable_m.md
blkid.md
cksum.md
crontab.md
crontab_u.md
csv.md
csv_s.md
date.md
df.md
dig.md
dir.md
dmidecode.md
dpkg_l.md
du.md
env.md
file.md
finger.md
free.md
fstab.md
git_log.md
git_log_s.md
group.md
gshadow.md
hash.md
hashsum.md
hciconfig.md
history.md
hosts.md
id.md
ifconfig.md
ini.md
iostat.md
iostat_s.md
iptables.md
iw_scan.md
jar_manifest.md
jobs.md
kv.md
last.md
ls.md
ls_s.md
lsblk.md
lsmod.md
lsof.md
lsusb.md
mount.md
mpstat.md
mpstat_s.md
netstat.md
nmcli.md
ntpq.md
passwd.md
pidstat.md
pidstat_s.md
ping.md
ping_s.md
pip_list.md
pip_show.md
ps.md
route.md
rpm_qi.md
rsync.md
rsync_s.md
sfdisk.md
shadow.md
ss.md
stat.md
stat_s.md
sysctl.md
systemctl.md
systemctl_lj.md
systemctl_ls.md
systemctl_luf.md
systeminfo.md
time.md
timedatectl.md
tracepath.md
traceroute.md
ufw.md
ufw_appinfo.md
uname.md
universal.md
update_alt_gs.md
update_alt_q.md
upower.md
uptime.md
vmstat.md
vmstat_s.md
w.md
wc.md
who.md
xml.md
xrandr.md
yaml.md
zipinfo.md
lib.md
readme.md
streaming.md
utils.md
jc
man
templates
tests
.gitignore
CHANGELOG
CONTRIBUTING.md
EXAMPLES.md
LICENSE.md
MANIFEST.in
README.md
_config.yml
build-package.sh
docgen.sh
install.sh
mangen.py
pypi-upload.sh
readmegen.py
requirements.txt
runtests.sh
setup.cfg
setup.py
updatedocs.sh
jc/docs/parsers/env.md

100 lines
1.8 KiB
Markdown
Raw Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.env"></a>
2020-07-30 16:20:24 -07:00
2019-11-11 18:30:46 -08:00
# jc.parsers.env
2022-01-25 17:07:47 -08:00
2022-03-04 13:27:39 -08:00
jc - JSON Convert `env` and `printenv` command output parser
2019-11-11 18:30:46 -08:00
2022-01-19 17:30:14 -08:00
This parser will output a list of dictionaries each containing `name` and
`value` keys. If you would like a simple dictionary output, then use the
`-r` command-line option or the `raw=True` argument in the `parse()`
function.
2020-08-06 07:48:08 -07:00
2020-08-05 13:32:59 -07:00
Usage (cli):
2019-12-12 09:47:14 -08:00
2022-01-25 18:03:34 -08:00
$ env | jc --env
2020-08-05 16:51:58 -07:00
2022-01-25 18:03:34 -08:00
or
2020-08-05 16:51:58 -07:00
2022-01-25 18:03:34 -08:00
$ jc env
2019-11-11 18:30:46 -08:00
2020-08-05 13:32:59 -07:00
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('env', env_command_output)
2022-01-18 15:38:03 -08:00
2021-04-08 12:42:01 -07:00
Schema:
2022-01-25 18:03:34 -08:00
[
{
"name": string,
"value": string
}
]
Examples:
$ env | jc --env -p
[
{
"name": "XDG_SESSION_ID",
"value": "1"
},
{
"name": "HOSTNAME",
"value": "localhost.localdomain"
},
{
"name": "TERM",
"value": "vt220"
},
{
"name": "SHELL",
"value": "/bin/bash"
},
{
"name": "HISTSIZE",
"value": "1000"
},
...
]
$ env | jc --env -p -r
{
"TERM": "xterm-256color",
"SHELL": "/bin/bash",
"USER": "root",
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
"PWD": "/root",
"LANG": "en_US.UTF-8",
"HOME": "/root",
"LOGNAME": "root",
"_": "/usr/bin/env"
}
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.env.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
2019-11-11 18:30:46 -08:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2019-11-11 18:30:46 -08:00
```
2019-11-12 11:18:00 -08:00
Main text parsing function
2019-11-11 18:30:46 -08:00
2022-01-25 18:03:34 -08:00
Parameters:
2019-11-11 18:30:46 -08:00
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2019-11-12 11:18:00 -08:00
2022-01-25 18:03:34 -08:00
Returns:
2019-11-12 11:18:00 -08:00
2022-01-25 18:03:34 -08:00
Dictionary of raw structured data or
List of Dictionaries of processed structured data
2019-11-11 18:30:46 -08:00
2022-01-25 19:18:54 -08:00
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
2021-12-01 16:12:51 -08:00
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)