Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pym/gentoolkit/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def operator(self):
op = super().operator
return "" if op is None else op

@property
def version(self):
# New portage's version property includes the revision; ours doesn't.
if self._bare_version is None:
self._set_cpv_chunks()
return self._bare_version

def __init__(self, atom):
self.atom = atom

Expand All @@ -64,15 +71,14 @@ def __init__(self, atom):
except portage.exception.InvalidAtom:
raise errors.GentoolkitInvalidAtom(atom)

# cpv is already managed by portage.dep.Atom; initialize CPV's
# private attrs directly to avoid writing to portage's read-only
# cpv property (new portage) or redundantly overwriting __dict__
# (old portage).
# Seed _cp only if portage didn't already set it (old portage never
# sets it; new portage's __slots__ value must not be clobbered).
if not hasattr(self, "_cp"):
self._cp = None
self._category = None
self._name = None
self._version = None
self._bare_version = None
self._revision = None
self._cp = None
self._fullversion = None
self.validate = False

Expand Down
8 changes: 4 additions & 4 deletions pym/gentoolkit/cpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, cpv, validate=False):
self.cpv = cpv
self._category = None
self._name = None
self._version = None
self._bare_version = None
self._revision = None
self._cp = None
self._fullversion = None
Expand All @@ -79,9 +79,9 @@ def name(self):

@property
def version(self):
if self._version is None:
if self._bare_version is None:
self._set_cpv_chunks()
return self._version
return self._bare_version

@property
def revision(self):
Expand All @@ -107,7 +107,7 @@ def _set_cpv_chunks(self):
chunks = split_cpv(self.cpv, validate=self.validate)
self._category = chunks[0]
self._name = chunks[1]
self._version = chunks[2]
self._bare_version = chunks[2]
self._revision = chunks[3]

def __eq__(self, other):
Expand Down
Loading