jpcli 0.4.0__py3-none-any.whl → 1.0.0__py3-none-any.whl

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/__init__.py CHANGED
File without changes
jpcli/main.py CHANGED
@@ -2,7 +2,7 @@
2
2
  import argparse
3
3
  import subprocess
4
4
  import sys
5
- from .parsers import lsmem_parser, free_parser, df_parser, lshw_parser, lscpu_parser, cpuinfo_parser, uname_parser, ifconfig_parser, cmdline_parser, os_release_parser, dmesg_parser, journalctl_parser, mcelog_parser
5
+ from .parsers import lsmem_parser, free_parser, df_parser, lshw_parser, lscpu_parser, cpuinfo_parser, uname_parser, ifconfig_parser, cmdline_parser, os_release_parser, dmesg_parser, journalctl_parser, mcelog_parser, lsusb_parser, lsblk_parser
6
6
 
7
7
 
8
8
  def run_command(command):
@@ -29,6 +29,8 @@ def parse_command_output(command_output, parser_name):
29
29
  'dmesg': dmesg_parser.parse,
30
30
  'journalctl': journalctl_parser.parse,
31
31
  'mcelog': mcelog_parser.parse,
32
+ 'lsusb': lsusb_parser.parse,
33
+ 'lsblk': lsblk_parser.parse,
32
34
  }
33
35
  if parser_name in parsers:
34
36
  return parsers[parser_name](command_output)
jpcli/parsers/__init__.py CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,21 +2,22 @@ import json
2
2
 
3
3
 
4
4
  def parse(command_output):
5
- lines = command_output.strip().split('\n')
5
+ lines = command_output.strip().split("\n")
6
6
  headers = lines[0].split()
7
7
  memory_data = []
8
8
 
9
9
  for line in lines[1:]:
10
10
  values = line.split()
11
- # Ensure that the length of headers and values are the same
11
+ category = values[0].strip(":") # Extract "Mem" or "Swap"
12
+ values = values[1:] # Remove category from values
13
+
14
+ # Ensure proper key-value matching
12
15
  if len(values) == len(headers):
13
16
  entry = {headers[i]: values[i] for i in range(len(headers))}
14
17
  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]
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
20
21
  memory_data.append(entry)
21
22
 
22
23
  return json.dumps(memory_data, indent=2)
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ import json
2
+
3
+
4
+ def parse(command_output):
5
+ lines = command_output.strip().split("\n")
6
+ if not lines:
7
+ return json.dumps([], indent=2)
8
+
9
+ headers = lines[0].split()
10
+ block_devices = []
11
+
12
+ for line in lines[1:]:
13
+ values = line.split(None, len(headers) - 1) # Split only into len(headers) parts
14
+ entry = {headers[i]: values[i] if i < len(values) else "N/A" for i in range(len(headers))}
15
+ block_devices.append(entry)
16
+
17
+ return json.dumps(block_devices, indent=2)
File without changes
@@ -6,7 +6,7 @@ def parse(command_output, indent_level=0):
6
6
  Recursively parse sections of command output based on indentation level.
7
7
  """
8
8
  def parse_section(lines, indent_level):
9
- data = {}
9
+
10
10
  current_section = {} # Initialize as empty dictionary
11
11
  while lines:
12
12
  line = lines.pop(0)
File without changes
@@ -0,0 +1,24 @@
1
+ import json
2
+ import re
3
+
4
+
5
+ def parse(command_output):
6
+ lines = command_output.strip().split("\n")
7
+ usb_data = []
8
+
9
+ for line in lines:
10
+ # Regex to capture bus, device, ID, and description
11
+ match = re.match(r"Bus (\d+) Device (\d+): ID ([0-9a-fA-F]{4}:[0-9a-fA-F]{4}) (.+)", line)
12
+ if match:
13
+ entry = {
14
+ "bus": match.group(1),
15
+ "device": match.group(2),
16
+ "id": match.group(3),
17
+ "description": match.group(4)
18
+ }
19
+ usb_data.append(entry)
20
+ else:
21
+ # If line doesn't match, keep it raw
22
+ usb_data.append({"raw": line})
23
+
24
+ return json.dumps(usb_data, indent=2)
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jpcli
3
- Version: 0.4.0
3
+ Version: 1.0.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
@@ -12,6 +12,7 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.6
14
14
  Description-Content-Type: text/markdown
15
+ License-File: LICENCE
15
16
 
16
17
  # jpcli
17
18
 
@@ -1,25 +1,27 @@
1
1
  jpcli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- jpcli/main.py,sha256=yBIyZLm16x3sEI3iBw3uUHjFnJLzUd7evS1qN85M1HU,2610
2
+ jpcli/main.py,sha256=XuBzcHR4d8OWjmncXEZFbCdPEjFmozXD3vl5bvzfb6E,2712
3
3
  jpcli/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  jpcli/parsers/cmdline_parser.py,sha256=S8PZjDTkxyz2IAY3hBvHDekWRGCkj9MHiLi2haupUZM,562
5
5
  jpcli/parsers/cpuinfo_parser.py,sha256=aL6NZ-_O_wmGRdZSzm7SttCngWoW7eqWckubxPWFpJk,973
6
6
  jpcli/parsers/df_parser.py,sha256=E2s8c6i60iKrS4IcCv_L_Fu5vDE_xnOTklAk_PFM5T4,549
7
7
  jpcli/parsers/dmesg_parser.py,sha256=v4i7inWGRKycyDIvjTyGaSBIYQZf7tNTJ4lxKKvKSN4,397
8
- jpcli/parsers/free_parser.py,sha256=GJuJKCT4cIN4O5D-rHjalx-6FzDT6-lpUurmh9PnUKE,721
8
+ jpcli/parsers/free_parser.py,sha256=fPKU3h_i420vOqefNtNpmBa5so3JCSdiauz6mF4Ra9c,748
9
9
  jpcli/parsers/ifconfig_parser.py,sha256=zEfTi8zdYnpQ4QNgZh1I31Z-mY9F1uAXGV9f6knJeJ0,1353
10
10
  jpcli/parsers/journalctl_parser.py,sha256=z9_6_8Gu798pQekosMCfoieCDGxbNcxOGcbteg4fzQk,949
11
+ jpcli/parsers/lsblk_parser.py,sha256=eHHU9jpmL-wR1LVGx-nbtyV_vAi3D04Me0qy9m_DvEU,502
11
12
  jpcli/parsers/lscpu_parser.py,sha256=b_OzMysCshP2lXY2Vmc-MJlxlYXocNTOvr7DHUeWkvQ,661
12
- jpcli/parsers/lshw_parser.py,sha256=0zoSIvYax2Ut_cNxQ8krPMPmiUyaV9n4sOIkXjtMrCA,1623
13
+ jpcli/parsers/lshw_parser.py,sha256=q3xw1IjIMQ2ubczcRYo_H-LxllfUO07CpKIhJaJ4K_k,1606
13
14
  jpcli/parsers/lsmem_parser.py,sha256=czWYUx6gwy2Z0nrLM5rJxBDz2HFQC9HSew2cenC-1vA,985
15
+ jpcli/parsers/lsusb_parser.py,sha256=sbiv8pDMva2bNdxjkXRFrxrdVUS6EixrOOpTjIeyO9g,702
14
16
  jpcli/parsers/mcelog_parser.py,sha256=GLZlj_Yl1KAzuTFotosudWPBAi_VhkBGdeKUbjNFhuk,412
15
17
  jpcli/parsers/os_release_parser.py,sha256=XQetNqNxmjMMdQPgqKS9XLQIoa5T7DMAcOTJJ0gmhCo,352
16
18
  jpcli/parsers/uname_parser.py,sha256=Yx59k9JzzfNgKZ9pt3hhfSwk0o9Ow1kqQdQNWUF6asc,1040
17
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
20
  tests/test_lsmem_parser.py,sha256=mRlHTmU2ZmcxPGgcqAv_LNGs56yrwDBiw2-aHKrpuEo,793
19
21
  tests/test_other_command_parser.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- jpcli-0.4.0.dist-info/LICENCE,sha256=-unHZSaIlcrVEVD56Ss5dlOvdgK682a2xitz35UlKt4,1069
21
- jpcli-0.4.0.dist-info/METADATA,sha256=3KfCVsK1e1wxOccgV0JAOhSVhXQqIL2CirEhh5JyIB0,603
22
- jpcli-0.4.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
23
- jpcli-0.4.0.dist-info/entry_points.txt,sha256=6wCYs9scOVGFsZE-b2r2geNzy4uST0GgWyHmveiPSxE,43
24
- jpcli-0.4.0.dist-info/top_level.txt,sha256=djdbp8mEzCmAEbrMOVEHNW4LIabBwnpLURp2dX_ZQbA,12
25
- jpcli-0.4.0.dist-info/RECORD,,
22
+ jpcli-1.0.0.dist-info/LICENCE,sha256=-unHZSaIlcrVEVD56Ss5dlOvdgK682a2xitz35UlKt4,1069
23
+ jpcli-1.0.0.dist-info/METADATA,sha256=zkJNjA2mvvCrDX_QAVFAEclvEyrFq0jOnNuQ_BcZLZQ,625
24
+ jpcli-1.0.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
25
+ jpcli-1.0.0.dist-info/entry_points.txt,sha256=6wCYs9scOVGFsZE-b2r2geNzy4uST0GgWyHmveiPSxE,43
26
+ jpcli-1.0.0.dist-info/top_level.txt,sha256=djdbp8mEzCmAEbrMOVEHNW4LIabBwnpLURp2dX_ZQbA,12
27
+ jpcli-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: bdist_wheel (0.37.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
tests/__init__.py CHANGED
File without changes
File without changes
File without changes