Skip to content
Browse files

Implemented two functions

Strip out package-name and version from a given full atom name
  • Loading branch information...
1 parent 8d14205 commit 77b78db924758a88110f5fa2ace2c7247a9dd12a @elbryan committed Feb 20, 2010
Showing with 24 additions and 2 deletions.
  1. +20 −0 libs/eutils.py
  2. +4 −2 unmaskit
View
20 libs/eutils.py
@@ -37,3 +37,23 @@ def expand_package_name(pname):
return matches[len(matches)-1]
else:
raise portage.exception.InvalidAtom
+
+def get_version_from_atom(aname):
+ """
+ Returns the version of the given atom
+ Example:
+ dev-util/ktigcc-completion-data-0.96_beta7 => 0.96_beta7
+ """
+ import re
+ regstr = "^([a-zA-Z0-9\-_\/\+]*)-([0-9\._]+[a-zA-Z0-9]+)"
+ return re.search(regstr, aname).group(2)
+
+def get_package_name_from_atom(aname):
+ """
+ Returns the package name of the given atom
+ Example:
+ dev-util/ktigcc-completion-data-0.96_beta7 => dev-util/ktigcc-completion-data
+ """
+ import re
+ regstr = "^([a-zA-Z0-9\-_\/\+]*)-([0-9\._]+[a-zA-Z0-9]+)"
+ return re.search(regstr, aname).group(1)
View
6 unmaskit
@@ -103,12 +103,14 @@ def main():
# x = commands.getoutput('emerge -pe %s' % config['package_to_unmask'])
try:
- pname_full = eutils.expand_package_name(pname)
+ aname = eutils.expand_package_name(pname)
except:
print >> warn, "Invalid package name '%s'" % pname
sys.exit(1)
- print pname_full
+ print aname
+ print eutils.get_version_from_atom(aname)
+ print eutils.get_package_name_from_atom(aname)
if __name__ == '__main__':
sys.exit(main())

0 comments on commit 77b78db

Please sign in to comment.
Something went wrong with that request. Please try again.