Skip to content

Commit 84a7f11

Browse files
authored
Controller: make query action format agnostic (#55)
Handle RPM format specifics at PackageRPM level, remove Spec handling from the Controller.
1 parent b1d7733 commit 84a7f11

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

lib/rift/Controller.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,27 +1035,27 @@ def action_query(args, config):
10351035
logging.debug('Loading package %s', pkg.name)
10361036
try:
10371037
pkg.load()
1038-
spec = Spec(config=config)
1039-
if args.spec:
1040-
spec.filepath = pkg.buildfile
1041-
spec.load()
10421038
except RiftError as exp:
10431039
logging.error("%s: %s", pkg.name, str(exp))
10441040
continue
10451041

1046-
date = str(time.strftime("%Y-%m-%d", time.localtime(spec.changelog_time)))
1042+
# Represent changelog time if defined on package.
1043+
if pkg.changelog_time:
1044+
date = str(time.strftime("%Y-%m-%d", time.localtime(pkg.changelog_time)))
1045+
else:
1046+
date = None
10471047
modulemanager = staff.get(modules.get(pkg.module).get('manager')[0])
10481048
tbl.append({'name': pkg.name,
10491049
'module': pkg.module,
10501050
'origin': pkg.origin,
10511051
'reason': pkg.reason,
10521052
'tests': str(len(list(pkg.tests()))),
1053-
'version': spec.version,
1054-
'arch': spec.arch,
1055-
'release': spec.release,
1056-
'changelogname': spec.changelog_name,
1053+
'version': pkg.version,
1054+
'arch': pkg.arch,
1055+
'release': pkg.release,
1056+
'changelogname': pkg.changelog_name,
10571057
'changelogtime': date,
1058-
'buildrequires': spec.buildrequires,
1058+
'buildrequires': pkg.buildrequires,
10591059
'modulemanager': modulemanager['email'],
10601060
'maintainers': ', '.join(pkg.maintainers)})
10611061
print(tbl)

lib/rift/package/_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ def __init__(self, name, config, staff, modules, _format, buildfile):
9393

9494
self.sources = set()
9595

96+
# Optionally set in load() by concrete children classes.
97+
self.version = None
98+
self.release = None
99+
self.arch = None
100+
self.changelog_name = None
101+
self.changelog_time = None
102+
self.buildrequires = None
103+
96104
def check(self):
97105
"""Load package and check info."""
98106
message('Validate package info...')

lib/rift/package/rpm.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,17 @@ def _deserialize_specific_metadata(self, data):
8383
self.ignore_rpms = data.get('ignore_rpms', [])
8484

8585
def load(self, infopath=None):
86-
"""Load package metadata, check its content and load RPM spec file."""
86+
"""Load package metadata, check its content and load RPM spec file with
87+
its main attributes."""
8788
# load infos.yaml with parent class
8889
super().load(infopath)
8990
self.spec = Spec(self.buildfile, config=self._config)
91+
self.version = self.spec.version
92+
self.release = self.spec.release
93+
self.arch = self.spec.arch
94+
self.changelog_name = self.spec.changelog_name
95+
self.changelog_time = self.spec.changelog_time
96+
self.buildrequires = self.spec.buildrequires
9097

9198
def check(self):
9299
# Check generic package metadata

0 commit comments

Comments
 (0)