Skip to content

Commit

Permalink
kernelci/api: helper for version fields translation
Browse files Browse the repository at this point in the history
Implement `KernelVersion.translate_version_fields` method to
translate version string fields to integers.

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
  • Loading branch information
Jeny Sadadia committed Feb 19, 2024
1 parent 92f57ef commit 4b64a17
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kernelci/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ class KernelVersion(BaseModel):
description="Version name e.g. People's Front for v4.19"
)

_STRICT_INT_FIELDS = ['version', 'patchlevel', 'sublevel']

@classmethod
def translate_version_fields(cls, params):
"""Translate `StrictInt` field values into `int`"""
for key, value in params.items():
if key in cls._STRICT_INT_FIELDS:
params[key] = int(value)
return params


class Revision(BaseModel):
"""Linux kernel Git revision model"""
Expand Down

0 comments on commit 4b64a17

Please sign in to comment.