mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
84 lines
1.7 KiB
Markdown
84 lines
1.7 KiB
Markdown
![]() |
[Home](https://kellyjonbrazil.github.io/jc/)
|
||
|
<a id="jc.parsers.resolve_conf"></a>
|
||
|
|
||
|
# jc.parsers.resolve\_conf
|
||
|
|
||
|
jc - JSON Convert `/etc/resolve.conf` file parser
|
||
|
|
||
|
This parser may be more forgiving than the system parser. For example, if
|
||
|
multiple `search` lists are defined, this parser will append all entries to
|
||
|
the `search` field, while the system parser may only use the list from the
|
||
|
last defined instance.
|
||
|
|
||
|
Usage (cli):
|
||
|
|
||
|
$ cat /etc/resolve.conf | jc --resolve-conf
|
||
|
|
||
|
Usage (module):
|
||
|
|
||
|
import jc
|
||
|
result = jc.parse('resolve_conf', resolve_conf_output)
|
||
|
|
||
|
Schema:
|
||
|
|
||
|
{
|
||
|
"domain": string,
|
||
|
"search": [
|
||
|
string
|
||
|
],
|
||
|
"nameservers": [
|
||
|
string
|
||
|
],
|
||
|
"options": [
|
||
|
string
|
||
|
],
|
||
|
"sortlist": [
|
||
|
string
|
||
|
]
|
||
|
}
|
||
|
|
||
|
|
||
|
Examples:
|
||
|
|
||
|
$ cat /etc/resolve.conf | jc --resolve-conf -p
|
||
|
{
|
||
|
"search": [
|
||
|
"eng.myprime.com",
|
||
|
"dev.eng.myprime.com",
|
||
|
"labs.myprime.com",
|
||
|
"qa.myprime.com"
|
||
|
],
|
||
|
"nameservers": [
|
||
|
"10.136.17.15"
|
||
|
],
|
||
|
"options": [
|
||
|
"rotate",
|
||
|
"ndots:1"
|
||
|
]
|
||
|
}
|
||
|
|
||
|
<a id="jc.parsers.resolve_conf.parse"></a>
|
||
|
|
||
|
### parse
|
||
|
|
||
|
```python
|
||
|
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
|
||
|
```
|
||
|
|
||
|
Main text parsing function
|
||
|
|
||
|
Parameters:
|
||
|
|
||
|
data: (string) text data to parse
|
||
|
raw: (boolean) unprocessed output if True
|
||
|
quiet: (boolean) suppress warning messages if True
|
||
|
|
||
|
Returns:
|
||
|
|
||
|
Dictionary. Raw or processed structured data.
|
||
|
|
||
|
### Parser Information
|
||
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||
|
|
||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|