summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2017-12-16 15:31:23 +0100
committerkensington <kensington@gentoo.org>2017-12-21 20:10:26 +1100
commit7e392f1d1d5b35d1d88b90e760c01f17493f187a (patch)
tree98dbbfd912748cfacd34fbcb298424ce60489364
parentuse portage.dep.dep_getcpv() to strip operators from package name (diff)
downloadtatt-7e392f1d1d5b35d1d88b90e760c01f17493f187a.tar.gz
tatt-7e392f1d1d5b35d1d88b90e760c01f17493f187a.tar.bz2
tatt-7e392f1d1d5b35d1d88b90e760c01f17493f187a.zip
use portage API to split package atoms
-rw-r--r--tatt/gentooPackage.py29
1 files changed, 7 insertions, 22 deletions
diff --git a/tatt/gentooPackage.py b/tatt/gentooPackage.py
index 6df9264..6c7c74d 100644
--- a/tatt/gentooPackage.py
+++ b/tatt/gentooPackage.py
@@ -1,7 +1,7 @@
"""Module for easy access to portage's atom syntax """
import re
-from portage.dep import dep_getcpv
+from portage.dep import dep_getcpv, dep_getkey, isvalidatom
class gentooPackage(object):
"""A Gentoo package consists of:
@@ -12,28 +12,13 @@ class gentooPackage(object):
def __init__(self, st):
"""An atom is initialized from an atom string"""
- st = dep_getcpv(st)
- slashparts = st.split("/")
+ if not isvalidatom(st):
+ st = '=' + st
+ cp = dep_getkey(st)
+ self.ver = dep_getcpv(st)[len(cp) + 1:] # +1 to strip the leading '-'
+ slashparts = cp.split("/")
self.category = slashparts[0]
- minusparts = slashparts[1].split("-")
- self.ver = ""
- if len (minusparts) == 1:
- # No version given
- self.name=slashparts[1]
- else:
- # Parse the name-version part
- self.name=""
- while 1:
- p = minusparts.pop(0)
- # Try a number after a '-'
- if re.match('[0-9]+', p):
- # Version starts here:
- self.ver = "-".join([p] + minusparts)
- break
- else:
- # Append back to name
- if self.name=="": self.name = p
- else : self.name = "-".join([self.name, p])
+ self.name = slashparts[1]
def packageName(self):
"""Returns the package name without category"""