-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 20 Feb 2014 17:12:19 +0800
Mathieu Bridon <bochecha(a)fedoraproject.org> wrote:
---
I have an internal app based on pyrpkg which requires knowing the
epoch of packages, and this is a straight-forward way of having it,
in the same way we already get the version and release.
This patch only adds it as a property of the class, though, it doesn't
modify the output of "rpkg verrel". At the time I had made this patch
Jesse preferred not changing the CLI output.
Having it on the class is way enough for my needs, though, as I use it
directly.
src/pyrpkg/__init__.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/pyrpkg/__init__.py b/src/pyrpkg/__init__.py
index 9086716..c5b4ae4 100644
--- a/src/pyrpkg/__init__.py
+++ b/src/pyrpkg/__init__.py
@@ -103,6 +103,8 @@ class Commands(object):
self._distval = None
# The distvar rpm value
self._distvar = None
+ # The rpm epoch of the cloned module
+ self._epoch = None
# An authenticated buildsys session
self._kojisession = None
# A web url of the buildsys server
@@ -305,6 +307,14 @@ class Commands(object):
return self._distvar
@property
+ def epoch(self):
+ """This property ensures the epoch attribute"""
+
+ if not self._epoch:
+ self.load_nameverrel()
+ return self._epoch
+
+ @property
def kojisession(self):
"""This property ensures the kojisession
attribute"""
@@ -388,7 +398,7 @@ class Commands(object):
# We make sure there is a space at the end of our query so
that # we can split it later. When there are subpackages, we get a
# listing for each subpackage. We only care about the first.
- cmd.extend(['-q', '--qf', '"%{NAME} %{VERSION}
%{RELEASE}??"',
+ cmd.extend(['-q', '--qf', '"%{NAME} %{EPOCH}
%{VERSION}
%{RELEASE}??"', '--specfile', os.path.join(self.path, self.spec)])
try:
output, err = subprocess.Popen(' '.join(cmd), shell=True,
@@ -404,9 +414,15 @@ class Commands(object):
# Get just the output, then split it by ??, grab the first
and split # again to get ver and rel
(self._module_name,
+ self._epoch,
self._ver,
self._rel) = output.split('??')[0].split()
+ # Most packages don't include a "Epoch: 0" line, in which
case RPM
+ # returns '(none)'
+ if self._epoch == "(none)":
+ self._epoch = "0"
+
@property
def repo(self):
"""This property ensures the repo attribute"""
applied thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJTBdCfAAoJEH7ltONmPFDRSGMP/1QNx7mjyXyqY6plCsogxF+9
4ha5DOnVAUpHEvozj/NZNDC8OA+WcU2a/R/0KyjH+IX+R+k4ebeA4h6n4j+p1adT
08havzIe6Lt5k/E94LL1Sif4q5nv+cpSIwpBX3YyLt18nkLJtECLOJGSz255rrrn
nBzRRreIZdIx9lu116yO2QvaOR9ghdvYkfxN4JPbMY/2qa6NUZ26IRclroPuRdrS
u7PdSbJkBALAK4v8ZhAaa8SP53vK6uY+TIkHRB2ZDraWaf/slr4YA81nhXrKHZQM
XJTOfb7Qk//RH5YBAsmbJ3xhHr6Ca62hwYVmb2FTXNCG0Aj19+f1iUEKt3wC62LT
OLapzzV/iuenPFAmOC2TCkZJJjeDbDNrNfZ/YiPTsnJ/s/zHa84GAnLuj0bG9tx6
uyK5OJthHaPlpoFzc50FBF9N6FgVJWVWruG6eQhOD0J9laWIvnHhHaK0w4++wEvT
T90/vtdiFNT+aqjMCrW0kAIHc7571osstsBxVeI/7a8QqTh+c+UT9jU6rlk3U86w
qWdYMBSfllzBh6Cxm8m1RJ1CzfCc54N5S8ZDPYxnCGz92DP7nF/BAR4KuMHIfyNr
UVJ1uZ1mi8PiU+CWmZ6X83Cla6AZefRpSEPFobNfm7QiUgx/S/0WhgJGhVPQ7j7s
Py9NxWgVChCpypj3mbh7
=fL5X
-----END PGP SIGNATURE-----