From 7346171bd2d1e490d4ee516ba25f6a53809afb9e Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 4 Mar 2022 13:16:57 +0100 Subject: [PATCH] dnf-json: staticify methods that don't need to be instance methods These two methods don't rely on the object instance at all so they should be static. The _timestamp_to_rfc() method can be a one-liner. --- dnf-json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dnf-json b/dnf-json index c3e1cc539..21269f852 100755 --- a/dnf-json +++ b/dnf-json @@ -131,7 +131,8 @@ class Solver(): self.base.repos.add(self._dnfrepo(repo, self.base.conf)) self.base.fill_sack(load_system_repo=False) - def _dnfrepo(self, desc, parent_conf=None): + @staticmethod + def _dnfrepo(desc, parent_conf=None): """Makes a dnf.repo.Repo out of a JSON repository description""" repo = dnf.repo.Repo(desc["id"], parent_conf) @@ -190,9 +191,9 @@ class Solver(): return checksums - def _timestamp_to_rfc3339(self, timestamp): - d = datetime.utcfromtimestamp(timestamp) - return d.strftime('%Y-%m-%dT%H:%M:%SZ') + @staticmethod + def _timestamp_to_rfc3339(timestamp): + return datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%dT%H:%M:%SZ') def dump(self): packages = []