jpcli 0.4.0__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jpcli-0.5.0/LICENCE +21 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/MANIFEST.in +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/PKG-INFO +14 -11
- {jpcli-0.4.0 → jpcli-0.5.0}/README.md +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/__init__.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/main.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/__init__.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/cmdline_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/cpuinfo_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/df_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/dmesg_parser.py +0 -0
- jpcli-0.5.0/jpcli/parsers/free_parser.py +23 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/ifconfig_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/journalctl_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/lscpu_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/lshw_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/lsmem_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/mcelog_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/os_release_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli/parsers/uname_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli.egg-info/PKG-INFO +14 -11
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli.egg-info/SOURCES.txt +1 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli.egg-info/dependency_links.txt +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli.egg-info/entry_points.txt +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/jpcli.egg-info/top_level.txt +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/setup.cfg +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/setup.py +1 -1
- {jpcli-0.4.0 → jpcli-0.5.0}/tests/__init__.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/tests/test_lsmem_parser.py +0 -0
- {jpcli-0.4.0 → jpcli-0.5.0}/tests/test_other_command_parser.py +0 -0
- jpcli-0.4.0/jpcli/parsers/free_parser.py +0 -22
jpcli-0.5.0/LICENCE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Jaime Cuevas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
File without changes
|
@@ -1,24 +1,27 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jpcli
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.0
|
4
4
|
Summary: A library to convert Linux command output to JSON
|
5
5
|
Home-page: https://github.com/JaimeAdanCuevas/jpcli
|
6
6
|
Author: Jaime Cuevas
|
7
7
|
Author-email: adancuevas@outlook.com
|
8
8
|
License: UNKNOWN
|
9
|
-
Description: # jpcli
|
10
|
-
|
11
|
-
jpcli is a library that converts the output of various Linux commands to JSON format.
|
12
|
-
|
13
|
-
## Installation
|
14
|
-
|
15
|
-
```sh
|
16
|
-
pip install jpcli
|
17
|
-
|
18
|
-
|
19
9
|
Platform: UNKNOWN
|
20
10
|
Classifier: Programming Language :: Python :: 3
|
21
11
|
Classifier: License :: OSI Approved :: MIT License
|
22
12
|
Classifier: Operating System :: OS Independent
|
23
13
|
Requires-Python: >=3.6
|
24
14
|
Description-Content-Type: text/markdown
|
15
|
+
License-File: LICENCE
|
16
|
+
|
17
|
+
# jpcli
|
18
|
+
|
19
|
+
jpcli is a library that converts the output of various Linux commands to JSON format.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
```sh
|
24
|
+
pip install jpcli
|
25
|
+
|
26
|
+
|
27
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
|
4
|
+
def parse(command_output):
|
5
|
+
lines = command_output.strip().split("\n")
|
6
|
+
headers = lines[0].split()
|
7
|
+
memory_data = []
|
8
|
+
|
9
|
+
for line in lines[1:]:
|
10
|
+
values = line.split()
|
11
|
+
category = values[0].strip(":") # Extract "Mem" or "Swap"
|
12
|
+
values = values[1:] # Remove category from values
|
13
|
+
|
14
|
+
# Ensure proper key-value matching
|
15
|
+
if len(values) == len(headers):
|
16
|
+
entry = {headers[i]: values[i] for i in range(len(headers))}
|
17
|
+
else:
|
18
|
+
entry = {headers[i]: values[i] if i < len(values) else "N/A" for i in range(len(headers))}
|
19
|
+
|
20
|
+
entry["category"] = category # Add category name separately
|
21
|
+
memory_data.append(entry)
|
22
|
+
|
23
|
+
return json.dumps(memory_data, indent=2)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,24 +1,27 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jpcli
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.0
|
4
4
|
Summary: A library to convert Linux command output to JSON
|
5
5
|
Home-page: https://github.com/JaimeAdanCuevas/jpcli
|
6
6
|
Author: Jaime Cuevas
|
7
7
|
Author-email: adancuevas@outlook.com
|
8
8
|
License: UNKNOWN
|
9
|
-
Description: # jpcli
|
10
|
-
|
11
|
-
jpcli is a library that converts the output of various Linux commands to JSON format.
|
12
|
-
|
13
|
-
## Installation
|
14
|
-
|
15
|
-
```sh
|
16
|
-
pip install jpcli
|
17
|
-
|
18
|
-
|
19
9
|
Platform: UNKNOWN
|
20
10
|
Classifier: Programming Language :: Python :: 3
|
21
11
|
Classifier: License :: OSI Approved :: MIT License
|
22
12
|
Classifier: Operating System :: OS Independent
|
23
13
|
Requires-Python: >=3.6
|
24
14
|
Description-Content-Type: text/markdown
|
15
|
+
License-File: LICENCE
|
16
|
+
|
17
|
+
# jpcli
|
18
|
+
|
19
|
+
jpcli is a library that converts the output of various Linux commands to JSON format.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
```sh
|
24
|
+
pip install jpcli
|
25
|
+
|
26
|
+
|
27
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
|
3
|
-
|
4
|
-
def parse(command_output):
|
5
|
-
lines = command_output.strip().split('\n')
|
6
|
-
headers = lines[0].split()
|
7
|
-
memory_data = []
|
8
|
-
|
9
|
-
for line in lines[1:]:
|
10
|
-
values = line.split()
|
11
|
-
# Ensure that the length of headers and values are the same
|
12
|
-
if len(values) == len(headers):
|
13
|
-
entry = {headers[i]: values[i] for i in range(len(headers))}
|
14
|
-
else:
|
15
|
-
# Handle cases where the line might not match header length
|
16
|
-
entry = {}
|
17
|
-
for i in range(len(values)):
|
18
|
-
key = headers[i] if i < len(headers) else f'unknown_{i}'
|
19
|
-
entry[key] = values[i]
|
20
|
-
memory_data.append(entry)
|
21
|
-
|
22
|
-
return json.dumps(memory_data, indent=2)
|