Skip to content

Commit

Permalink
convert size fields and fix issue for optional_deps without a descrip…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
kellyjonbrazil committed Nov 25, 2024
1 parent 6ceaa77 commit 0be6528
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
17 changes: 13 additions & 4 deletions jc/parsers/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"replaces": [
string
],
"download_size": string,
"installed_size": string,
"download_size": integer, # in bytes
"installed_size": integer, # in bytes
"packager": string,
"build_date": string,
"validated_by": [
Expand Down Expand Up @@ -108,7 +108,7 @@
],
"conflicts_with": [],
"replaces": [],
"installed_size": "1527.00 KiB",
"installed_size": "1563648",
"packager": "Levente Polyak <[email protected]>",
"build_date": "Sat 11 May 2024 06:14:19 AM +08",
"install_date": "Fri 24 May 2024 09:50:31 AM +08",
Expand Down Expand Up @@ -205,6 +205,8 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:

name_description_fields = {'optional_deps'}

size_fields = {'download_size', 'installed_size'}

# initial split for field lists
for item in proc_data:
for key, val in item.items():
Expand All @@ -225,11 +227,18 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
if key in name_description_fields and isinstance(val, list):
new_list = []
for name_desc in val:
n, d = name_desc.split(': ')
n, *d = name_desc.split(': ')
if d == []:
d = ''
else:
d = d[0]
new_obj = {'name': n, 'description': d}
new_list.append(new_obj)
item[key] = new_list

if key in size_fields:
item[key] = jc.utils.convert_size_to_int(val)

return proc_data


Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/generic/pacman--packages.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions tests/fixtures/generic/pacman--packages.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Description : Access control list utilities, libraries and headers
Architecture : x86_64
URL : https://savannah.nongnu.org/projects/acl
Licenses : LGPL
Groups : None
Groups : kde-applications kde-sdk
Provides : xfsacl libacl.so=1-64
Depends On : glibc
Optional Deps : None
Optional Deps : testing: this is a test description
name-with-no-description
Required By : advcpmv bfs borg borg2 bup casync cdrtools clifm-git coreutils coreutils-hybrid-git cups emacs emacs-nativecomp emacs-nox emacs-wayland gettext incus incus-tools kio krusader lib32-acl libarchive libisofs logrotate lxd proftpd proxmox-backup-client rsync rsync-reflink sed shadow snapper spice-gtk systemd tar udisks2 udisks2-btrfs udisks2-lvm2 vim vis xfsdump
Optional For : diffoscope mkosi mkosi-git
Conflicts With : xfsacl
Expand Down Expand Up @@ -2007,4 +2008,4 @@ Build Date : Wed 24 Jul 2024 02:42:51 PM +08
MD5 Sum : None
SHA-256 Sum : 0a9df51cd89fe14b9d40e0b5bc1c13e505f38cbe65277311e6995f45a4f19b1a
Signatures : 6D42BDD116E0068F
Extended Data : None
Extended Data : None
2 changes: 1 addition & 1 deletion tests/fixtures/generic/pacman--qii-zstd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/fixtures/generic/pacman--si-graphicsmagick.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"repository":"extra","name":"graphicsmagick","version":"1.3.43-1","description":"Image processing system","architecture":"x86_64","url":"http://www.graphicsmagick.org/","licenses":["MIT"],"groups":[],"provides":["Magick.so","libGraphicsMagickWand.so=2-64","libGraphicsMagick.so=3-64","libGraphicsMagick++-Q16.so"],"depends_on":["bzip2","freetype2","lcms2","libltdl","libpng","libsm","libtiff","libwebp","libxext","xz"],"optional_deps":[{"name":"jasper","description":"jp2 module"},{"name":"libwmf","description":"wmf module"},{"name":"libxml2","description":"msl, svg, url modules"},{"name":"ghostscript","description":"pdf, ps modules"},{"name":"libheif","description":"heic module"},{"name":"libjxl","description":"jpeg-xl module"}],"conflicts_with":[],"replaces":[],"download_size":"2.58 MiB","installed_size":"13.97 MiB","packager":"Caleb Maclennan <[email protected]>","build_date":"Sat 23 Mar 2024 09:55:47 PM CET","validated_by":["MD5 Sum","SHA-256 Sum","Signature"]}]
[{"repository":"extra","name":"graphicsmagick","version":"1.3.43-1","description":"Image processing system","architecture":"x86_64","url":"http://www.graphicsmagick.org/","licenses":["MIT"],"groups":[],"provides":["Magick.so","libGraphicsMagickWand.so=2-64","libGraphicsMagick.so=3-64","libGraphicsMagick++-Q16.so"],"depends_on":["bzip2","freetype2","lcms2","libltdl","libpng","libsm","libtiff","libwebp","libxext","xz"],"optional_deps":[{"name":"jasper","description":"jp2 module"},{"name":"libwmf","description":"wmf module"},{"name":"libxml2","description":"msl, svg, url modules"},{"name":"ghostscript","description":"pdf, ps modules"},{"name":"libheif","description":"heic module"},{"name":"libjxl","description":"jpeg-xl module"}],"conflicts_with":[],"replaces":[],"download_size":2705326,"installed_size":14648606,"packager":"Caleb Maclennan <[email protected]>","build_date":"Sat 23 Mar 2024 09:55:47 PM CET","validated_by":["MD5 Sum","SHA-256 Sum","Signature"]}]
1 change: 1 addition & 0 deletions tests/test_pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# - `{parser_name}--{some_test_description}.json` for expected JSON after parsing.

class MyTests(unittest.TestCase):
maxDiff = None

def test_pacman_nodata(self):
"""
Expand Down

0 comments on commit 0be6528

Please sign in to comment.