1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/update_alt_q.md

160 lines
3.5 KiB
Markdown
Raw Normal View History

2022-04-22 15:23:11 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.update_alt_q"></a>
2024-03-14 22:46:52 -07:00
# jc.parsers.update_alt_q
2022-04-22 15:23:11 -07:00
jc - JSON Convert `update-alternatives --query` command output parser
Usage (cli):
$ update-alternatives --query | jc --update-alt-q
2022-08-15 13:51:48 -07:00
or
2022-04-22 15:23:11 -07:00
$ jc update-alternatives --query
Usage (module):
import jc
result = jc.parse('update_alt_q',
update_alternatives_query_command_output)
Schema:
{
"name": string,
"link": string,
"slaves": [
{
"name": string,
"path": string
}
],
"status": string,
"best": string,
"value": string, # (null if 'none')
"alternatives": [
{
2022-04-25 08:39:33 -07:00
"alternative": string,
2022-04-22 15:23:11 -07:00
"priority": integer,
"slaves": [
{
"name": string,
"path": string
}
]
}
]
}
Examples:
$ update-alternatives --query editor | jc --update-alt-q -p
{
"name": "editor",
"link": "/usr/bin/editor",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/editor.1.gz"
},
{
"name": "editor.da.1.gz",
"path": "/usr/share/man/da/man1/editor.1.gz"
}
],
"status": "auto",
"best": "/bin/nano",
"value": "/bin/nano",
"alternatives": [
{
2022-04-25 08:39:33 -07:00
"alternative": "/bin/ed",
2022-04-22 15:23:11 -07:00
"priority": -100,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/ed.1.gz"
}
]
},
{
2022-04-25 08:39:33 -07:00
"alternative": "/bin/nano",
2022-04-22 15:23:11 -07:00
"priority": 40,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/nano.1.gz"
}
]
}
]
}
$ update-alternatives --query | jc --update-alt-q -p -r
{
"name": "editor",
"link": "/usr/bin/editor",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/editor.1.gz"
},
{
"name": "editor.da.1.gz",
"path": "/usr/share/man/da/man1/editor.1.gz"
}
],
"status": "auto",
"best": "/bin/nano",
"value": "/bin/nano",
"alternatives": [
{
2022-04-25 08:39:33 -07:00
"alternative": "/bin/ed",
2022-04-22 15:23:11 -07:00
"priority": "-100",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/ed.1.gz"
}
]
},
{
2022-04-25 08:39:33 -07:00
"alternative": "/bin/nano",
2022-04-22 15:23:11 -07:00
"priority": "40",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/nano.1.gz"
}
]
}
]
}
<a id="jc.parsers.update_alt_q.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
```
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
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/update_alt_q.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/update_alt_q.py)
2022-07-16 20:52:19 -07:00
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)