* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-06 20:54 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-06 20:54 UTC (permalink / raw
To: gentoo-commits
commit: 88cfa5eca002820e97c37bf095e92307a3873106
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 6 20:32:44 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 6 20:32:44 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=88cfa5ec
Add a __repr__ for PMRepo*.
---
gentoopm/basepm/repo.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index 5b1bac0..87d0825 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -45,6 +45,10 @@ class PMRepositoryDict(ABCObject):
"""
pass
+ def __repr__(self):
+ return '%s([\n%s])' % (self.__class__.__name__,
+ ',\n'.join(['\t%s' % repr(x) for x in self]))
+
class PMRepository(PMPackageSet):
"""
Base abstract class for a single repository.
@@ -69,3 +73,6 @@ class PMEbuildRepository(PMRepository):
Return the canonical path to the ebuild repository.
"""
pass
+
+ def __repr__(self):
+ return '%s(%s)' % (self.__class__.__name__, repr(self.name))
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-07 9:51 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-07 9:51 UTC (permalink / raw
To: gentoo-commits
commit: 5ef78b31ae1493ed1ccffb2cb6a6640f8d051bbf
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 7 08:43:02 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 7 08:43:02 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=5ef78b31
Update filtering description/API.
---
gentoopm/basepm/pkg.py | 43 +++++++++++++++++++++----------------------
1 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 4c71c62..8f94833 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -17,21 +17,19 @@ class PMPackageSet(ABCObject):
def filter(self, *args, **kwargs):
"""
- Filter the packages based on keys passed as arguments. Positional
- arguments refer to keys by their level (with first arg being the
- top-level key), None means match-all. Keyword arguments refer to keys
- by their names.
+ Filter the packages based on arguments. Return a PMFilteredPackageSet
+ evaluating to a number of PMPackages.
- If an argument doesn't match any key (i.e. too many args are passed),
- a KeyError or IndexError will be raised. If the same key is referred
- through positional and keyword arguments, a TypeError will be raised.
+ The positional arguments can provide a number of PMPackageMatchers (see
+ gentoopm.basepm.filter) and/or an atom string. The keyword arguments
+ match metadata keys using '==' comparison with passed values (objects).
- The filtering will result in an iterable of PMKeyedPackageDicts
- or PMPackages, depending on whether the filtering criteria are able
- to uniquely identify packages.
+ Multiple filters will be AND-ed together. Same applies for .filter()
+ called multiple times. You should, however, avoid passing multiple
+ atoms as it is not supported by all PMs.
- The '==' operator is used to match packages. To extend matching, you
- can provide a class with __eq__() redefined as an argument.
+ This function can raise KeyError when a keyword argument does reference
+ an incorrect metadata key.
"""
return PMFilteredPackageSet(iter(self), args, kwargs)
@@ -70,8 +68,8 @@ class PMFilteredPackageSet(PMPackageSet):
def __iter__(self):
for el in self._iter:
- for x in el.filter(*self._args, **self._kwargs):
- yield x
+ if el._matches(*self._args, **self._kwargs):
+ yield el
class PMPackage(ABCObject):
"""
@@ -79,16 +77,17 @@ class PMPackage(ABCObject):
in the package tree.
"""
- def filter(self, **kwargs):
+ def _matches(self, *args, **kwargs):
"""
- Filter packages on metadata. This is mostly to extend superclass
- .filter() method.
+ Check whether the package matches passed filters. Please note that this
+ method may not be called at all if PM is capable of a more efficient
+ filtering.
- If args are non-empty, raises an IndexError (unused args). If kwargs
- contains keys not matching metadata, raises a KeyError. Otherwise,
- returns an iterator -- either over the package itself or an empty one.
+ If kwargs reference incorrect metadata keys, a KeyError will be raised.
"""
+ # XXX: apply filters
+
for k, m in kwargs.items():
try:
v = self.metadata[k]
@@ -96,9 +95,9 @@ class PMPackage(ABCObject):
raise KeyError('Unmatched keyword argument: %s' % k)
else:
if not m == v:
- return
+ return False
- yield self
+ return True
@abstractproperty
def id(self):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-07 12:52 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-07 12:52 UTC (permalink / raw
To: gentoo-commits
commit: 0c6a91e0c47221086b4a58462cf8b97c5217c923
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 7 11:45:53 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 7 11:46:07 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=0c6a91e0
Introduce an abstract API for filters.
---
gentoopm/basepm/filter.py | 35 +++++++++++++++++++++++++++++++++++
gentoopm/basepm/pkg.py | 3 ++-
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
new file mode 100644
index 0000000..26d9e37
--- /dev/null
+++ b/gentoopm/basepm/filter.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from abc import abstractmethod
+
+from gentoopm.util import ABCObject
+
+class PMPackageMatcher(ABCObject):
+ """
+ Base class for a package matcher.
+ """
+
+ @abstractmethod
+ def __call__(self, pkg):
+ """
+ Check whether a package matches the condition specified in the matcher.
+ Return True if it does, False otherwise.
+ """
+ pass
+
+class PMKeywordMatcher(ABCObject):
+ """
+ Base class for a keyword matcher (one passed as a keyword argument
+ instead of a plain string).
+ """
+
+ @abstractmethod
+ def __eq__(self, val):
+ """
+ Check whether the value of a metadata key matches the condition
+ specified in the matcher. Return True if it does, False otherwise.
+ """
+ pass
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 9365465..1bb2447 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -22,7 +22,8 @@ class PMPackageSet(ABCObject):
The positional arguments can provide a number of PMPackageMatchers (see
gentoopm.basepm.filter) and/or an atom string. The keyword arguments
- match metadata keys using '==' comparison with passed values (objects).
+ match metadata keys using '==' comparison with passed string
+ (or PMKeywordMatchers).
Multiple filters will be AND-ed together. Same applies for .filter()
called multiple times. You should, however, avoid passing multiple
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-07 12:52 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-07 12:52 UTC (permalink / raw
To: gentoo-commits
commit: 079c751f832711fe8fd10e82ecf2cc5d6c9a6ab0
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 7 12:50:41 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 7 12:52:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=079c751f
Support applying the filters.
---
gentoopm/basepm/pkg.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 1bb2447..f7e534a 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -5,6 +5,7 @@
from abc import abstractmethod, abstractproperty
+from gentoopm.basepm.atom import PMAtom
from gentoopm.util import ABCObject
class PMPackageSet(ABCObject):
@@ -21,7 +22,7 @@ class PMPackageSet(ABCObject):
evaluating to a number of PMPackages.
The positional arguments can provide a number of PMPackageMatchers (see
- gentoopm.basepm.filter) and/or an atom string. The keyword arguments
+ gentoopm.basepm.filter) and/or a PMAtom instance. The keyword arguments
match metadata keys using '==' comparison with passed string
(or PMKeywordMatchers).
@@ -92,7 +93,15 @@ class PMPackage(ABCObject):
If kwargs reference incorrect metadata keys, a KeyError will be raised.
"""
- # XXX: apply filters
+ for f in args:
+ if callable(f): # a matcher
+ if not f(self):
+ return False
+ elif isinstance(f, PMAtom): # an atom
+ if not self in f:
+ return False
+ else:
+ raise ValueError('Incorrect positional argument: %s' % f)
for k, m in kwargs.items():
try:
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-07 12:52 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-07 12:52 UTC (permalink / raw
To: gentoo-commits
commit: f0b3cc512ca404ebfdb7d7a366b295c168a90d69
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 7 12:52:25 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 7 12:52:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f0b3cc51
Add some abstraction to the Atom API.
---
gentoopm/basepm/atom.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 9fa1c41..45674fe 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -11,4 +11,18 @@ class PMAtom(ABCObject):
"""
A base class for PM-specific atom (dependency specification).
"""
- pass
+
+ @abstractmethod
+ def __init__(self, s):
+ """
+ Create a new atom from string.
+ """
+ pass
+
+ @abstractmethod
+ def __contains__(self, pkg):
+ """
+ Check whether a package matches the atom (is contained in the set
+ of packages matched by atom).
+ """
+ pass
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-08 12:49 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-08 12:49 UTC (permalink / raw
To: gentoo-commits
commit: 899ca1cc125a7732571589df84dee9aad72b3fda
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 8 12:29:56 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 8 12:29:56 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=899ca1cc
Pass complete package source instead of iter when filtering.
---
gentoopm/basepm/pkg.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 2e801e0..736f544 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -34,7 +34,7 @@ class PMPackageSet(ABCObject):
an incorrect metadata key.
"""
- return PMFilteredPackageSet(iter(self), args, kwargs)
+ return PMFilteredPackageSet(self, args, kwargs)
@property
def best(self):
@@ -81,13 +81,13 @@ class PMPackageSet(ABCObject):
return True
class PMFilteredPackageSet(PMPackageSet):
- def __init__(self, it, args, kwargs):
- self._iter = it
+ def __init__(self, src, args, kwargs):
+ self._src = src
self._args = args
self._kwargs = kwargs
def __iter__(self):
- for el in self._iter:
+ for el in self._src:
if el._matches(*self._args, **self._kwargs):
yield el
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-08 12:49 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-08 12:49 UTC (permalink / raw
To: gentoo-commits
commit: 25813dc8591800487d99ab89e76ec483e1e1eee8
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 8 12:49:31 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 8 12:49:31 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=25813dc8
Support getting packages through pkgset[].
---
gentoopm/basepm/pkg.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 736f544..5efa45e 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -67,6 +67,31 @@ class PMPackageSet(ABCObject):
except KeyError:
raise ValueError('Ambiguous filter (matches more than a single package name).')
+ def __getitem__(self, filt):
+ """
+ Select a single package matching an atom (or filter). Unlike .select(),
+ this one doesn't choose the best match but requires the filter to match
+ exactly one package.
+
+ Raises KeyError when no package matches. Raises ValueError if more than
+ a single package matches.
+ """
+
+ it = iter(self.filter(filt))
+
+ try:
+ ret = next(it)
+ except StopIteration:
+ raise KeyError('No packages match the filter.')
+ try:
+ next(it)
+ except StopIteration:
+ pass
+ else:
+ raise ValueError('Filter matches more than one package.')
+
+ return ret
+
def __contains__(self, arg):
"""
Check whether the package set contains at least a single package
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-10 12:34 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-10 12:34 UTC (permalink / raw
To: gentoo-commits
commit: 0450187a63419b20fc8d7e5218974d2cdd8dc17e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 12:35:08 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 12:35:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=0450187a
Doc the base PM classes.
---
gentoopm/basepm/__init__.py | 22 +++++++---
gentoopm/basepm/atom.py | 6 +++
gentoopm/basepm/filter.py | 19 +++++++--
gentoopm/basepm/metadata.py | 23 +++++++++--
gentoopm/basepm/pkg.py | 88 +++++++++++++++++++++++++++++++++----------
gentoopm/basepm/repo.py | 13 ++++++
gentoopm/basepm/stack.py | 4 ++
7 files changed, 139 insertions(+), 36 deletions(-)
diff --git a/gentoopm/basepm/__init__.py b/gentoopm/basepm/__init__.py
index 9b33f1b..10a727c 100644
--- a/gentoopm/basepm/__init__.py
+++ b/gentoopm/basepm/__init__.py
@@ -18,6 +18,8 @@ class PackageManager(ABCObject):
"""
Return the canonical name of the PM. The value should be static
and unique.
+
+ @type: string
"""
pass
@@ -27,7 +29,7 @@ class PackageManager(ABCObject):
(Re-)load the configuration of a particular package manager. Set up
internal variables.
- Called by default __init__().
+ Called by default L{__init__()}.
"""
pass
@@ -37,15 +39,18 @@ class PackageManager(ABCObject):
@abstractproperty
def repositories(self):
"""
- Return an PMRepositoryDict (gentoopm.basepm.repo.PMRepositoryDict)
- subclass referring to the currently enabled ebuild repositories.
+ Currently enabled ebuild repositories.
+
+ @type: L{PMRepositoryDict}
"""
pass
@abstractproperty
def installed(self):
"""
- Return a PMRepository for installed packages (vardb).
+ Repository with installed packages (vardb).
+
+ @type: L{PMRepository}
"""
pass
@@ -53,14 +58,17 @@ class PackageManager(ABCObject):
def stack(self):
"""
Return a PMRepository providing access to the stacked packages in all
- ebuild repositories. It returns packages from all the repos, with
- the repo being the lowest-level key.
+ ebuild repositories. It returns packages from all the repos.
+
+ @type: L{PMRepoStackWrapper}
"""
return PMRepoStackWrapper(self.repositories)
@abstractproperty
def Atom(self):
"""
- Return the PM-specific atom class.
+ The PM-specific atom class.
+
+ @type: L{PMAtom}
"""
pass
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 45674fe..bd631f8 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -16,6 +16,9 @@ class PMAtom(ABCObject):
def __init__(self, s):
"""
Create a new atom from string.
+
+ @param s: atom-formatted string
+ @type s: string
"""
pass
@@ -24,5 +27,8 @@ class PMAtom(ABCObject):
"""
Check whether a package matches the atom (is contained in the set
of packages matched by atom).
+
+ @param pkg: a package to match
+ @type pkg: L{PMPackage}
"""
pass
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
index 26d9e37..4347893 100644
--- a/gentoopm/basepm/filter.py
+++ b/gentoopm/basepm/filter.py
@@ -10,26 +10,37 @@ from gentoopm.util import ABCObject
class PMPackageMatcher(ABCObject):
"""
Base class for a package matcher.
+
+ Package matcher is basically a function (or function class wrapper) which
+ checks the package for match.
"""
@abstractmethod
def __call__(self, pkg):
"""
Check whether a package matches the condition specified in the matcher.
- Return True if it does, False otherwise.
+
+ @return: True if the package matches
+ @rtype: bool
"""
pass
class PMKeywordMatcher(ABCObject):
"""
- Base class for a keyword matcher (one passed as a keyword argument
- instead of a plain string).
+ Base class for a keyword matcher.
+
+ A keyword matcher is a condition passed as an keyword argument
+ to the L{pkg.PMPackageSet.filter()} function. It's basically an object which will
+ be compared against metadata value using C{==} operator.
"""
@abstractmethod
def __eq__(self, val):
"""
Check whether the value of a metadata key matches the condition
- specified in the matcher. Return True if it does, False otherwise.
+ specified in the matcher.
+
+ @return: True if metadata value matches
+ @rtype: bool
"""
pass
diff --git a/gentoopm/basepm/metadata.py b/gentoopm/basepm/metadata.py
index 73c0961..f2f6bc8 100644
--- a/gentoopm/basepm/metadata.py
+++ b/gentoopm/basepm/metadata.py
@@ -26,6 +26,7 @@ metadata_keys = (
'CATEGORY', 'PN', 'PV', 'PR',
'P', 'PVR', 'PF'
)
+""" A common supported metadata key list. """
class PMPackageMetadata(ABCObject):
"""
@@ -34,8 +35,13 @@ class PMPackageMetadata(ABCObject):
def __getitem__(self, key):
"""
- Get the value of a metadata key. Return it as a string, or an empty
- string when unset.
+ Get the value of a metadata key.
+
+ @param key: the metadata key to catch
+ @type key: string
+ @return: the value of a metadata key, or C{''} when unset
+ @rtype: string
+ @raise KeyError: when invalid metadata key referred
"""
try:
return getattr(self, key)
@@ -48,15 +54,22 @@ class PMPackageMetadata(ABCObject):
@abstractmethod
def __getattr__(self, key):
"""
- Get the value of a metadata key through an attribute. Return it
- as a string, or an empty string when unset. Should raise
- an AttributeError if the key is not in self.
+ Get the value of a metadata key through an attribute.
+
+ @param key: the metadata key to catch
+ @type key: string
+ @return: the value of a metadata key, or C{''} when unset
+ @rtype: string
+ @raise AttributeError: when invalid metadata key referred
"""
pass
def __iter__(self):
"""
Iterate over possible metadata keys.
+
+ @return: available metadata keys
+ @rtype: iter(string)
"""
return iter(metadata_keys)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index b1f8e7d..b1192b1 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -10,29 +10,37 @@ from gentoopm.exceptions import EmptyPackageSetError, AmbiguousPackageSetError
from gentoopm.util import ABCObject
class PMPackageSet(ABCObject):
+ """ A set of packages. """
+
@abstractmethod
def __iter__(self):
"""
Iterate over the packages (or sets) in a set.
+
+ @return: packages in the set
+ @rtype: iter(L{PMPackage})
"""
pass
def filter(self, *args, **kwargs):
"""
- Filter the packages based on arguments. Return a PMFilteredPackageSet
- evaluating to a number of PMPackages.
+ Filter the packages based on arguments. Return a filtered package set.
- The positional arguments can provide a number of PMPackageMatchers (see
- gentoopm.basepm.filter) and/or a PMAtom instance. The keyword arguments
- match metadata keys using '==' comparison with passed string
- (or PMKeywordMatchers).
+ The positional arguments can provide a number of L{PMPackageMatcher}s
+ and/or a L{PMAtom} instance. The keyword arguments match metadata keys
+ using '==' comparison with passed string (or L{PMKeywordMatcher}s).
Multiple filters will be AND-ed together. Same applies for .filter()
called multiple times. You should, however, avoid passing multiple
atoms as it is not supported by all PMs.
- This function can raise KeyError when a keyword argument does reference
- an incorrect metadata key.
+ @param args: list of package matchers
+ @type args: list(L{PMPackageMatcher},L{PMAtom})
+ @param kwargs: dict of keyword matchers
+ @type kwargs: dict(string -> L{PMKeywordMatcher})
+ @return: filtered package set
+ @rtype: L{PMFilteredPackageSet}
+ @raise KeyError: when invalid metadata key is referenced in kwargs
"""
return PMFilteredPackageSet(self, args, kwargs)
@@ -40,8 +48,12 @@ class PMPackageSet(ABCObject):
@property
def best(self):
"""
- Return the best-matching package in the set (i.e. flatten it, sort
- the results and return the first one).
+ Return the best-matching package in the set (the newest one).
+
+ @type: L{PMPackage}
+ @raise EmptyPackageSetError: when no packages match the condition
+ @raise AmbiguousPackageSetError: when packages with different keys
+ match the condition
"""
l = sorted(self, reverse = True)
@@ -58,8 +70,19 @@ class PMPackageSet(ABCObject):
def select(self, *args, **kwargs):
"""
Select a single package matching keys in positional and keyword
- arguments. This is a convenience wrapper for filter(*args,
- **kwargs).best.
+ arguments. This is a convenience wrapper for C{filter(*args,
+ **kwargs).best}.
+
+ @param args: list of package matchers
+ @type args: list(L{PMPackageMatcher},L{PMAtom})
+ @param kwargs: dict of keyword matchers
+ @type kwargs: dict(string -> L{PMKeywordMatcher})
+ @return: filtered package set
+ @rtype: L{PMFilteredPackageSet}
+ @raise KeyError: when invalid metadata key is referenced in kwargs
+ @raise EmptyPackageSetError: when no packages match the condition
+ @raise AmbiguousPackageSetError: when packages with different keys
+ match the condition
"""
try:
return self.filter(*args, **kwargs).best
@@ -70,12 +93,17 @@ class PMPackageSet(ABCObject):
def __getitem__(self, filt):
"""
- Select a single package matching an atom (or filter). Unlike .select(),
+ Select a single package matching an atom (or filter). Unlike L{select()},
this one doesn't choose the best match but requires the filter to match
exactly one package.
- Raises KeyError when no package matches. Raises ValueError if more than
- a single package matches.
+ @param filt: a package matcher or an atom
+ @type filt: L{PMPackageMatcher}/L{PMAtom}
+ @return: matching package
+ @rtype: L{PMPackage}
+ @raise EmptyPackageSetError: when no packages match the condition
+ @raise AmbiguousPackageSetError: when packages with different keys
+ match the condition
"""
it = iter(self.filter(filt))
@@ -97,6 +125,11 @@ class PMPackageSet(ABCObject):
"""
Check whether the package set contains at least a single package
matching the filter or package atom passed as an argument.
+
+ @param arg: a package matcher or an atom
+ @type arg: L{PMPackageMatcher}/L{PMAtom}
+ @return: True if at least a single package matched
+ @rtype: bool
"""
i = iter(self.filter(arg))
@@ -119,7 +152,7 @@ class PMFilteredPackageSet(PMPackageSet):
class PMPackage(ABCObject):
"""
- An abstract class representing a single, uniquely-keyed package
+ An abstract class representing a single, uniquely-identified package
in the package tree.
"""
@@ -129,7 +162,13 @@ class PMPackage(ABCObject):
method may not be called at all if PM is capable of a more efficient
filtering.
- If kwargs reference incorrect metadata keys, a KeyError will be raised.
+ @param args: list of package matchers
+ @type args: list(L{PMPackageMatcher},L{PMAtom})
+ @param kwargs: dict of keyword matchers
+ @type kwargs: dict(string -> L{PMKeywordMatcher})
+ @return: True if package matches
+ @rtype: bool
+ @raise KeyError: when invalid metadata key is referenced in kwargs
"""
for f in args:
@@ -156,8 +195,11 @@ class PMPackage(ABCObject):
@abstractproperty
def key(self):
"""
- Return the key identifying the package. This is used by .best, to check
- whether the set doesn't reference more than one package.
+ Return the key identifying the package. This is used by
+ L{PMPackageSet.best}, to check whether the set doesn't reference more
+ than one package.
+
+ @type: string
"""
pass
@@ -165,6 +207,8 @@ class PMPackage(ABCObject):
def id(self):
"""
Return an unique identifier for the package.
+
+ @type: string
"""
pass
@@ -173,13 +217,17 @@ class PMPackage(ABCObject):
"""
Return path to the ebuild file (or vardb entry) if appropriate.
If not available, just return None.
+
+ @type: string/None
"""
pass
@abstractproperty
def metadata(self):
"""
- Return PMPackageMetadata object for the package.
+ Return the metadata accessor object for the package.
+
+ @type: L{PMPackageMetadata}
"""
pass
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index 87d0825..87b9c3d 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -25,6 +25,12 @@ class PMRepositoryDict(ABCObject):
By default, iterates over the repository list. Can be replaced with
something more optimal.
+
+ @param key: repository name or path
+ @type key: string
+ @return: matching repository
+ @rtype: L{PMEbuildRepository}
+ @raise KeyError: when no repository matches the key
"""
bypath = os.path.isabs(key)
@@ -42,6 +48,9 @@ class PMRepositoryDict(ABCObject):
def __iter__(self):
"""
Iterate over the repository list.
+
+ @return: iterator over repositories
+ @rtype: iter(L{PMEbuildRepository})
"""
pass
@@ -64,6 +73,8 @@ class PMEbuildRepository(PMRepository):
"""
Return the repository name (either from the repo_name file or PM
fallback name).
+
+ @type: string
"""
pass
@@ -71,6 +82,8 @@ class PMEbuildRepository(PMRepository):
def path(self):
"""
Return the canonical path to the ebuild repository.
+
+ @type: string
"""
pass
diff --git a/gentoopm/basepm/stack.py b/gentoopm/basepm/stack.py
index ab13dd3..be79749 100644
--- a/gentoopm/basepm/stack.py
+++ b/gentoopm/basepm/stack.py
@@ -6,6 +6,10 @@
from gentoopm.basepm.repo import PMRepository
class PMRepoStackWrapper(PMRepository):
+ """
+ A wrapper class providing access to all packages in all repositories.
+ """
+
def __init__(self, repos):
self._repos = repos
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-11 9:39 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-11 9:39 UTC (permalink / raw
To: gentoo-commits
commit: a15d5b2ad120d17a92df2da61300f1da6faa7e6b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 09:40:06 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 11 09:40:06 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a15d5b2a
Support forking a BashParser out of PMPackageEnvironment.
---
gentoopm/basepm/environ.py | 64 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/gentoopm/basepm/environ.py b/gentoopm/basepm/environ.py
index 86ee5f5..8e1c469 100644
--- a/gentoopm/basepm/environ.py
+++ b/gentoopm/basepm/environ.py
@@ -7,6 +7,21 @@ import bz2
from gentoopm.bash import get_any_bashparser
+def _load_bp(bp, path, open_func):
+ """
+ Load a file onto a bash parser.
+
+ @param bp: the bash parser instance
+ @type bp: L{BashParser}
+ @param path: path to the environment file
+ @type path: string
+ @param open_func: open function for the file
+ @type open_func: func(path, mode)
+ """
+ f = open_func(path)
+ bp.load_file(f)
+ f.close()
+
class LazyBashParser(object):
"""
Lazily-initialized, shared bash parser wrapper.
@@ -15,14 +30,21 @@ class LazyBashParser(object):
_parser = None
def set_file(self, path, open_func):
+ """
+ Switch the currently used environment file, if necessary.
+
+ @param path: path to the new environment file
+ @type path: string
+ @param open_func: open functions for the new file
+ @type open_func: func(path, mode)
+ """
+
if self._curr_path == path:
return
self._curr_path = path
- f = open_func(path)
if self._parser is None:
self._parser = get_any_bashparser()
- self._parser.load_file(f)
- f.close()
+ _load_bp(self._parser, path, open_func)
def __getitem__(self, k):
return self._parser[k]
@@ -41,13 +63,49 @@ class PMPackageEnvironment(object):
"""
def __init__(self, path, bzipped2 = False):
+ """
+ Instantiate L{PMPackageEnvironment} accessor.
+
+ @param path: path to the environment file
+ @type path: string
+ @param bzipped2: whether to bunzip2 the file
+ @type bzipped2: bool
+ """
self._path = path
self._open_func = bz2.BZ2File if bzipped2 else open
def __getitem__(self, k):
+ """
+ Get the value of an environment key by name.
+
+ @param k: the key to access
+ @type k: string
+ @return: the environment variable value
+ @rtype: string
+ """
_bp.set_file(self._path, self._open_func)
return _bp[k]
def copy(self, *keys):
+ """
+ Get a number of environment keys as a dict.
+
+ @param keys: keys to access
+ @type keys: strings
+ @return: a dict of copied environment keys
+ @rtype: dict(string -> string)
+ """
_bp.set_file(self._path, self._open_func)
return _bp.copy(*keys)
+
+ def fork(self):
+ """
+ Fork the bash parser. In other words, return a completely separate
+ instance with the environment file loaded.
+
+ @return: forked L{BashParser} instance
+ @rtype: L{BashParser}
+ """
+ bp = get_any_bashparser()
+ _load_bp(bp, self._path, self._open_func)
+ return bp
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-11 9:39 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-11 9:39 UTC (permalink / raw
To: gentoo-commits
commit: 3fbe66e1b53dce7a52d32c4aaccf870383a3dc23
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 08:47:48 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 11 08:47:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3fbe66e1
Introduce a dummy environment accessor for packages.
---
gentoopm/basepm/pkg.py | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index b1192b1..4293f4d 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -3,6 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import bz2, os.path
from abc import abstractmethod, abstractproperty
from gentoopm.basepm.atom import PMAtom
@@ -231,5 +232,26 @@ class PMPackage(ABCObject):
"""
pass
+ @property
+ def environ(self):
+ """
+ Return the environment accessor object for the package.
+
+ @type: L{PMPackageEnvironment}
+ """
+ p = self.path
+ bz2 = False
+ if os.path.isdir(p):
+ # XXX: look for .bz2 and plain, take the newer one
+ p = os.path.join(p, 'environment.bz2')
+ bz2 = True
+ return PMPackageEnvironment(p, bzipped2 = bz2)
+
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, repr(self.id))
+
+class PMPackageEnvironment(object):
+ def __init__(self, f, bzipped2 = False):
+ self._f = f
+ self._open_func = bz2.BZ2File if bzipped2 else open
+ print (self._f, self._open_func)
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-13 16:09 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-13 16:09 UTC (permalink / raw
To: gentoo-commits
commit: 40fff81728aa1f3d71d0114513221d2ee468323e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 13 15:27:58 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 13 15:27:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=40fff817
Add a note not to call userpriv_?id when disabled.
---
gentoopm/basepm/config.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/config.py b/gentoopm/basepm/config.py
index d011001..b8aeccf 100644
--- a/gentoopm/basepm/config.py
+++ b/gentoopm/basepm/config.py
@@ -22,6 +22,9 @@ class PMConfig(ABCObject):
"""
The UID used for userpriv.
+ If userpriv is disabled, the result of calling this method is
+ undefined. It can result in an exception.
+
@type: string/numeric
"""
pass
@@ -31,6 +34,9 @@ class PMConfig(ABCObject):
"""
The GID used for userpriv.
+ If userpriv is disabled, the result of calling this method is
+ undefined. It can result in an exception.
+
@type: string/numeric
"""
pass
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-13 16:30 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-13 16:30 UTC (permalink / raw
To: gentoo-commits
commit: 480a31e6bd5be4b37d32004c662568e12e386500
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 13 16:30:54 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 13 16:30:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=480a31e6
Drop problematic __del__().
---
gentoopm/basepm/environ.py | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/gentoopm/basepm/environ.py b/gentoopm/basepm/environ.py
index 8e1c469..3e27148 100644
--- a/gentoopm/basepm/environ.py
+++ b/gentoopm/basepm/environ.py
@@ -52,9 +52,6 @@ class LazyBashParser(object):
def copy(self, *v):
return self._parser.copy(*v)
- def __del__(self):
- del self._parser
-
_bp = LazyBashParser()
class PMPackageEnvironment(object):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-14 13:31 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-14 13:31 UTC (permalink / raw
To: gentoo-commits
commit: a58d6a405df88326436840652ff585a96b4d34fe
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 13:00:53 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 13:00:53 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a58d6a40
Support getting an associated package from PMAtom.
---
gentoopm/basepm/atom.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 772b098..729bc4b 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -66,3 +66,17 @@ class PMAtom(ABCObject):
@type: bool
"""
pass
+
+ def get_associated(self, repo):
+ """
+ Return an atom associated with a matching package in the repository.
+
+ @param repo: Repository to find a match in.
+ @type repo: L{PMRepository}
+ @return: An associated atom.
+ @rtype: L{PMAtom}
+ @raise EmptyPackageSetError: when no packages match the atom
+ @raise AmbiguousPackageSetError: when packages with different keys
+ match the atom
+ """
+ return repo.select(self).atom
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-14 13:31 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-14 13:31 UTC (permalink / raw
To: gentoo-commits
commit: 100d666ebf5c300f0f440ed3ec3aec9442cb2552
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 13:32:26 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 13:32:26 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=100d666e
Optimize filtering stacked packages.
---
gentoopm/basepm/stack.py | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/stack.py b/gentoopm/basepm/stack.py
index be79749..2d6d453 100644
--- a/gentoopm/basepm/stack.py
+++ b/gentoopm/basepm/stack.py
@@ -4,6 +4,7 @@
# Released under the terms of the 2-clause BSD license.
from gentoopm.basepm.repo import PMRepository
+from gentoopm.basepm.pkg import PMPackageSet
class PMRepoStackWrapper(PMRepository):
"""
@@ -17,3 +18,32 @@ class PMRepoStackWrapper(PMRepository):
for r in self._repos:
for p in r:
yield p
+
+ def filter(self, *args, **kwargs):
+ return PMFilteredStackPackageSet(self._repos, args, kwargs)
+
+class PMFilteredStackPackageSet(PMPackageSet):
+ """
+ A wrapper class providing access to filtering packages in all repositories.
+ Thanks to it, per-repo filter optimizations can be performed.
+ """
+
+ def __init__(self, repos, args, kwargs, addkwargs = []):
+ self._repos = repos
+ self._args = args
+ self._kwargs = kwargs
+ # keywords may overlap, so only optimize the first set
+ self._addkwargs = addkwargs
+
+ def __iter__(self):
+ for r in self._repos:
+ for p in r.filter(*self._args, **self._kwargs):
+ for kw in self._addkwargs:
+ if not p._matches(**kw):
+ break
+ else:
+ yield p
+
+ def filter(self, *args, **kwargs):
+ return PMFilteredStackPackageSet(self._repos, self._args + args,
+ self._kwargs, self._addkwargs + [kwargs])
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-14 13:31 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-14 13:31 UTC (permalink / raw
To: gentoo-commits
commit: b7e392c4439b34229ecf06e590190c7b02856e96
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 13:06:33 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 13:06:33 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=b7e392c4
Add PMAtom.__repr__().
---
gentoopm/basepm/atom.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 729bc4b..d9689c2 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -43,6 +43,13 @@ class PMAtom(ABCObject):
"""
pass
+ def __repr__(self):
+ if self.complete:
+ s = repr(self.__str__())
+ else:
+ s = '<incomplete>'
+ return '%s(%s)' % (self.__class__.__name__, s)
+
@abstractproperty
def complete(self):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-14 22:51 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-14 22:51 UTC (permalink / raw
To: gentoo-commits
commit: b25fe432d0e869988e1af02004fcf518e06f7d3d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 21:11:17 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 21:11:17 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=b25fe432
Fix doc references.
---
gentoopm/basepm/atom.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 3090e3e..040563a 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -56,7 +56,7 @@ class PMAtom(ABCObject):
Whether the atom is complete, i.e. whether the category is specified.
If an atom is incomplete, it is impossible to stringify it. Using such
- an atom with L{PMPackageSet.select()} may result
+ an atom with L{pkg.PMPackageSet.select()} may result
in an L{AmbiguousPackageSetError}.
@type: bool
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 9:52 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 9:52 UTC (permalink / raw
To: gentoo-commits
commit: e5b7f5d96ba1fccee89144118bea092572111a0f
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 09:06:12 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 09:06:12 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e5b7f5d9
Support checking repo existence using 'in'.
---
gentoopm/basepm/repo.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index 87b9c3d..721804d 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -44,6 +44,14 @@ class PMRepositoryDict(ABCObject):
return r
raise KeyError('No repository matched key %s' % key)
+ def __contains__(self, k):
+ try:
+ self[k]
+ except KeyError:
+ return False
+ else:
+ return True
+
@abstractmethod
def __iter__(self):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 9:52 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 9:52 UTC (permalink / raw
To: gentoo-commits
commit: 03b5890a0ef8a714cff2c0a0c6aaf661eba69552
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 09:41:05 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 09:41:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=03b5890a
PackageSet: support checking for non-empty (__nonzero__()).
---
gentoopm/basepm/pkg.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index dc0364b..77532aa 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -141,6 +141,19 @@ class PMPackageSet(ABCObject):
return False
return True
+ def __nonzero__(self):
+ """
+ Check whether the package set is non-empty.
+
+ @return: True if package set matches at least one package.
+ @rtype: bool
+ """
+ try:
+ next(iter(self))
+ except StopIteration:
+ return False
+ return True
+
class PMFilteredPackageSet(PMPackageSet):
def __init__(self, src, args, kwargs):
self._src = src
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 12:34 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 12:34 UTC (permalink / raw
To: gentoo-commits
commit: 98cf5cb2658512546b4d025017abf3433da49089
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 11:35:57 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 11:35:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=98cf5cb2
Fix raising KeyError with invalid metadata keys.
---
gentoopm/basepm/metadata.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/metadata.py b/gentoopm/basepm/metadata.py
index 526c58e..f5f3ffc 100644
--- a/gentoopm/basepm/metadata.py
+++ b/gentoopm/basepm/metadata.py
@@ -44,7 +44,7 @@ class PMPackageMetadata(ABCObject):
"""
try:
return getattr(self, key)
- except NameError:
+ except AttributeError:
raise KeyError('No metadata key named %s' % key)
def __contains__(self, key):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 12:34 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 12:34 UTC (permalink / raw
To: gentoo-commits
commit: da03c9031a30677edd7e4232b108d81303aee4d9
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 12:28:44 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 12:28:44 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=da03c903
Don't make CATEGORY an abstractproperty.
The category can be provided through __getattr__().
---
gentoopm/basepm/metadata.py | 11 -----------
1 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/gentoopm/basepm/metadata.py b/gentoopm/basepm/metadata.py
index 77c1df5..81fd91f 100644
--- a/gentoopm/basepm/metadata.py
+++ b/gentoopm/basepm/metadata.py
@@ -69,14 +69,3 @@ class PMPackageMetadata(ABCObject):
@rtype: iter(string)
"""
return iter(metadata_keys)
-
- # Other useful ebuild vars.
-
- @abstractproperty
- def CATEGORY(self):
- """
- Package category.
-
- @type: string
- """
- pass
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 12:34 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 12:34 UTC (permalink / raw
To: gentoo-commits
commit: e00162c8b0341bd2b0a5108a7d206065717d0a35
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 12:28:18 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 12:28:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e00162c8
Drop PROVIDE from allowed metadata vars.
---
gentoopm/basepm/metadata.py | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/metadata.py b/gentoopm/basepm/metadata.py
index f5f3ffc..77c1df5 100644
--- a/gentoopm/basepm/metadata.py
+++ b/gentoopm/basepm/metadata.py
@@ -17,8 +17,6 @@ metadata_keys = (
'DEPEND', 'RDEPEND', 'PDEPEND',
'RESTRICT', 'PROPERTIES',
'REQUIRED_USE',
- # deprecated ebuild-defined vars (not in PMS anymore)
- 'PROVIDE',
# magic ebuild-defined vars (PMS 7.4)
'INHERITED', 'DEFINED_PHASES',
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 13:32 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 13:32 UTC (permalink / raw
To: gentoo-commits
commit: e4fde2fcba55f039ea136a630e69e4633daaff52
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 13:15:22 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 13:15:56 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e4fde2fc
Predefine simple '==' operators.
---
gentoopm/basepm/pkg.py | 5 +++++
gentoopm/basepm/repo.py | 5 +++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index ccdd5ce..ad3e1f1 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -273,5 +273,10 @@ class PMPackage(ABCObject):
bz2 = True
return PMPackageEnvironment(p, bzipped2 = bz2)
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return False
+ return self.id == other.id
+
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, repr(self.id))
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index 721804d..b4ce8ce 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -95,5 +95,10 @@ class PMEbuildRepository(PMRepository):
"""
pass
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return False
+ return self.name == other.name and self.path == other.path
+
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, repr(self.name))
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 22:24 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 22:24 UTC (permalink / raw
To: gentoo-commits
commit: 57df866612ecdce17fef00f304da795f5a3b5fbd
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 22:19:05 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 22:19:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=57df8666
PMAtom: support hashing, '==' and '!='.
---
gentoopm/basepm/atom.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 040563a..11ec313 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -43,6 +43,19 @@ class PMAtom(ABCObject):
"""
pass
+ def __eq__(self, other):
+ if not self.complete:
+ raise NotImplementedError('Unable to compare incomplete atoms')
+ return str(self) == str(other)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __hash__(self):
+ if not self.complete:
+ raise NotImplementedError('Unable to hash incomplete atoms')
+ return hash(str(self))
+
def __repr__(self):
if self.complete:
s = repr(self.__str__())
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 22:24 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 22:24 UTC (permalink / raw
To: gentoo-commits
commit: ea0909d0ae5dd7142b1d899c5b7655248ac0dafb
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 22:22:21 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 22:22:21 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=ea0909d0
PMRepository: support '!=' and hashing.
---
gentoopm/basepm/repo.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index 7f517ad..ba41c38 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -100,5 +100,11 @@ class PMEbuildRepository(PMRepository):
return False
return self.name == other.name and self.path == other.path
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __hash__(self):
+ return hash((self.name, self.path))
+
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, repr(self.name))
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 22:24 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 22:24 UTC (permalink / raw
To: gentoo-commits
commit: 494089c8eb2cc6f28d130b5d43d758b3f67f7111
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 22:20:50 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 22:20:50 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=494089c8
PMPackage: support '!=' and hashing.
---
gentoopm/basepm/pkg.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 02b1f5e..3a4a8b2 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -120,5 +120,11 @@ class PMPackage(ABCObject):
return False
return self.id == other.id
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __hash__(self):
+ return hash(self.id)
+
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, repr(self.id))
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 23:56 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 23:56 UTC (permalink / raw
To: gentoo-commits
commit: a3d87f6de7e5286eb58361794c0faaa5122d1322
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 23:54:42 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 23:54:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a3d87f6d
Use the atom key part as package key.
---
gentoopm/basepm/pkg.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 4f22421..b2def74 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -61,7 +61,7 @@ class PMPackage(ABCObject):
@type: any
"""
- return self.atom.unversioned
+ return self.atom.key
@property
def id(self):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-15 23:56 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-15 23:56 UTC (permalink / raw
To: gentoo-commits
commit: 1a8f8578c9957e2093511a8cfb086fd3c20d0474
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 23:52:59 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 23:52:59 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=1a8f8578
Fix references in docs.
---
gentoopm/basepm/atom.py | 2 +-
gentoopm/basepm/filter.py | 4 ++--
gentoopm/basepm/pkg.py | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index 8347773..e5589be 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -169,7 +169,7 @@ class PMAtom(ABCObject):
Whether the atom is complete, i.e. whether the category is specified.
If an atom is incomplete, it is impossible to stringify it. Using such
- an atom with L{pkg.PMPackageSet.select()} may result
+ an atom with L{pkgset.PMPackageSet.select()} may result
in an L{AmbiguousPackageSetError}.
@type: bool
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
index 4347893..e20487e 100644
--- a/gentoopm/basepm/filter.py
+++ b/gentoopm/basepm/filter.py
@@ -30,8 +30,8 @@ class PMKeywordMatcher(ABCObject):
Base class for a keyword matcher.
A keyword matcher is a condition passed as an keyword argument
- to the L{pkg.PMPackageSet.filter()} function. It's basically an object which will
- be compared against metadata value using C{==} operator.
+ to the L{pkgset.PMPackageSet.filter()} function. It's basically an object
+ which will be compared against metadata value using C{==} operator.
"""
@abstractmethod
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 6a8b24a..4f22421 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -56,8 +56,8 @@ class PMPackage(ABCObject):
def key(self):
"""
Return the key identifying the package. This is used by
- L{PMPackageSet.best}, to check whether the set doesn't reference more
- than one package.
+ L{pkgset.PMPackageSet.best}, to check whether the set doesn't reference
+ more than one package.
@type: any
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-17 9:09 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-17 9:09 UTC (permalink / raw
To: gentoo-commits
commit: 82e0576e1338a2a9889b8894f1612b6928cf60df
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 17 09:10:33 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 09:10:33 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=82e0576e
Clarify PMPackage docs a bit.
---
gentoopm/basepm/pkg.py | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index b2def74..067808f 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -55,20 +55,19 @@ class PMPackage(ABCObject):
@property
def key(self):
"""
- Return the key identifying the package. This is used by
- L{pkgset.PMPackageSet.best}, to check whether the set doesn't reference
- more than one package.
+ The key identifying the package. This is used to group packages, e.g.
+ when choosing the best package in a set.
- @type: any
+ @type: hashable
"""
return self.atom.key
@property
def id(self):
"""
- Return an unique identifier for the package.
+ An unique identifier for the package.
- @type: any
+ @type: hashable
"""
return self.atom
@@ -84,17 +83,19 @@ class PMPackage(ABCObject):
@abstractproperty
def path(self):
"""
- Return path to the ebuild file (or vardb entry) if appropriate.
- If not available, just return None.
+ Path to the ebuild file (or vardb entry) if appropriate.
- @type: string/None
+ This function may return C{None} if that information is not available
+ or the particular repository doesn't operate on local filesystem.
+
+ @type: string/C{None}
"""
pass
@abstractproperty
def metadata(self):
"""
- Return the metadata accessor object for the package.
+ The metadata accessor object for the package.
@type: L{PMPackageMetadata}
"""
@@ -103,7 +104,7 @@ class PMPackage(ABCObject):
@property
def environ(self):
"""
- Return the environment accessor object for the package.
+ The environment accessor object for the package.
@type: L{PMPackageEnvironment}
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-17 22:10 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-17 22:10 UTC (permalink / raw
To: gentoo-commits
commit: f37b0cad6628be0b0c48001036e2aa042333d193
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 17 21:46:43 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 21:46:43 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f37b0cad
Autodetect bzip2 when loading an environment file.
---
gentoopm/basepm/environ.py | 36 +++++++++++++++++++-----------------
gentoopm/basepm/pkg.py | 4 +---
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/gentoopm/basepm/environ.py b/gentoopm/basepm/environ.py
index 3e27148..7ba5450 100644
--- a/gentoopm/basepm/environ.py
+++ b/gentoopm/basepm/environ.py
@@ -7,7 +7,7 @@ import bz2
from gentoopm.bash import get_any_bashparser
-def _load_bp(bp, path, open_func):
+def _load_bp(bp, path):
"""
Load a file onto a bash parser.
@@ -15,12 +15,19 @@ def _load_bp(bp, path, open_func):
@type bp: L{BashParser}
@param path: path to the environment file
@type path: string
- @param open_func: open function for the file
- @type open_func: func(path, mode)
"""
- f = open_func(path)
- bp.load_file(f)
- f.close()
+
+ def _try_file(t):
+ f = t(path, 'r')
+ try:
+ bp.load_file(f)
+ finally:
+ f.close()
+
+ try:
+ _try_file(bz2.BZ2File)
+ except IOError:
+ _try_file(open)
class LazyBashParser(object):
"""
@@ -29,14 +36,12 @@ class LazyBashParser(object):
_curr_path = None
_parser = None
- def set_file(self, path, open_func):
+ def set_file(self, path):
"""
Switch the currently used environment file, if necessary.
@param path: path to the new environment file
@type path: string
- @param open_func: open functions for the new file
- @type open_func: func(path, mode)
"""
if self._curr_path == path:
@@ -44,7 +49,7 @@ class LazyBashParser(object):
self._curr_path = path
if self._parser is None:
self._parser = get_any_bashparser()
- _load_bp(self._parser, path, open_func)
+ _load_bp(self._parser, path)
def __getitem__(self, k):
return self._parser[k]
@@ -59,17 +64,14 @@ class PMPackageEnvironment(object):
Package environment accessor class.
"""
- def __init__(self, path, bzipped2 = False):
+ def __init__(self, path):
"""
Instantiate L{PMPackageEnvironment} accessor.
@param path: path to the environment file
@type path: string
- @param bzipped2: whether to bunzip2 the file
- @type bzipped2: bool
"""
self._path = path
- self._open_func = bz2.BZ2File if bzipped2 else open
def __getitem__(self, k):
"""
@@ -80,7 +82,7 @@ class PMPackageEnvironment(object):
@return: the environment variable value
@rtype: string
"""
- _bp.set_file(self._path, self._open_func)
+ _bp.set_file(self._path)
return _bp[k]
def copy(self, *keys):
@@ -92,7 +94,7 @@ class PMPackageEnvironment(object):
@return: a dict of copied environment keys
@rtype: dict(string -> string)
"""
- _bp.set_file(self._path, self._open_func)
+ _bp.set_file(self._path)
return _bp.copy(*keys)
def fork(self):
@@ -104,5 +106,5 @@ class PMPackageEnvironment(object):
@rtype: L{BashParser}
"""
bp = get_any_bashparser()
- _load_bp(bp, self._path, self._open_func)
+ _load_bp(bp, self._path)
return bp
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 067808f..853cad1 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -109,12 +109,10 @@ class PMPackage(ABCObject):
@type: L{PMPackageEnvironment}
"""
p = self.path
- bz2 = False
if os.path.isdir(p):
# XXX: look for .bz2 and plain, take the newer one
p = os.path.join(p, 'environment.bz2')
- bz2 = True
- return PMPackageEnvironment(p, bzipped2 = bz2)
+ return PMPackageEnvironment(p)
def __eq__(self, other):
if not isinstance(other, self.__class__):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-17 22:10 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-17 22:10 UTC (permalink / raw
To: gentoo-commits
commit: 0c7660db796e64194c7a4f14eb5a83d4b27990e9
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 17 22:08:35 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 22:08:35 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=0c7660db
PMPackage: make .environ check if path does exist.
---
gentoopm/basepm/pkg.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 853cad1..c2a27ec 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -106,12 +106,22 @@ class PMPackage(ABCObject):
"""
The environment accessor object for the package.
- @type: L{PMPackageEnvironment}
+ Please note that this function may return C{None} if environment is
+ inaccessible (path is unavailable or file does not exist).
+
+ @type: L{PMPackageEnvironment}/C{None}
"""
+
p = self.path
+ if p is None:
+ return None
+
if os.path.isdir(p):
# XXX: look for .bz2 and plain, take the newer one
p = os.path.join(p, 'environment.bz2')
+
+ if not os.path.exists(p):
+ return None
return PMPackageEnvironment(p)
def __eq__(self, other):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-17 22:10 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-17 22:10 UTC (permalink / raw
To: gentoo-commits
commit: e112f11651f529b466a46cddf481fb1a28c226ec
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 17 22:09:51 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 22:09:51 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e112f116
PMPackage: make .environ try both .bz2 and plain environment.
Now PMPackage.environ looks for both environment.bz2 and plain
environment files. It checks which of them is newer, and uses that one.
---
gentoopm/basepm/pkg.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index c2a27ec..91b0264 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -117,8 +117,16 @@ class PMPackage(ABCObject):
return None
if os.path.isdir(p):
- # XXX: look for .bz2 and plain, take the newer one
- p = os.path.join(p, 'environment.bz2')
+ def _mtime_if_exists(path):
+ try:
+ return os.path.getmtime(path)
+ except OSError:
+ return None
+
+ files = ('environment.bz2', 'environment')
+ # Take the newer one.
+ fn = sorted(files, key=_mtime_if_exists, reverse=True)[0]
+ p = os.path.join(p, fn)
if not os.path.exists(p):
return None
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-17 22:39 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-17 22:39 UTC (permalink / raw
To: gentoo-commits
commit: f86fe3eb05f9bd81e1315e88e08b94f348a2d060
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 17 22:40:11 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 22:40:11 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f86fe3eb
Py3: fix using None as a sort key.
---
gentoopm/basepm/pkg.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 91b0264..23790ab 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -121,7 +121,7 @@ class PMPackage(ABCObject):
try:
return os.path.getmtime(path)
except OSError:
- return None
+ return -1
files = ('environment.bz2', 'environment')
# Take the newer one.
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-20 9:41 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-20 9:41 UTC (permalink / raw
To: gentoo-commits
commit: 7fa5f72b0a95812e696f89ed4d85318c2973795b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 20 09:41:33 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 20 09:41:33 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=7fa5f72b
Fix stringifying PMPackageDescription.
---
gentoopm/basepm/pkg.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 14cf36c..1a2b0cb 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -41,7 +41,7 @@ class PMPackageDescription(ABCObject):
@returns: best package description
@rtype: string
"""
- return self.long or self.short
+ return str(self.long or self.short)
class PMPackage(PMAtom, FillMissingComparisons):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-21 8:47 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-21 8:47 UTC (permalink / raw
To: gentoo-commits
commit: 3647703a30b68a2330ed6a65f3ac3811ef2fc55d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 07:05:08 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 07:05:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3647703a
Add an abstract subclass for installed packages.
---
gentoopm/basepm/pkg.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index b633799..b5ec780 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -228,3 +228,9 @@ class PMPackage(PMAtom, FillMissingComparisons):
@property
def associated(self):
return True
+
+class PMInstalledPackage(PMPackage):
+ """
+ An abstract class for a installed package.
+ """
+ pass
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-23 9:27 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-23 9:27 UTC (permalink / raw
To: gentoo-commits
commit: c8215544b599af6015c0a8f92345492b3288a5d6
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 23 08:34:10 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 23 08:34:10 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=c8215544
PMPackageSet: introduce .sorted property.
---
gentoopm/basepm/pkgset.py | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/gentoopm/basepm/pkgset.py b/gentoopm/basepm/pkgset.py
index be8b9b2..b301968 100644
--- a/gentoopm/basepm/pkgset.py
+++ b/gentoopm/basepm/pkgset.py
@@ -55,15 +55,15 @@ class PMPackageSet(ABCObject, BoolCompat):
match the condition
"""
- l = sorted(self, reverse = True)
- try:
- best = l[0]
- except IndexError:
+ best = None
+ for p in self.sorted:
+ if best is not None and p.key != best.key:
+ raise AmbiguousPackageSetError('.best called on a set of differently-named packages')
+ best = p
+
+ if best is None:
raise EmptyPackageSetError('.best called on an empty set')
- for p in l:
- if p.key != best.key:
- raise AmbiguousPackageSetError('.best called on a set of differently-named packages')
return best
def select(self, *args, **kwargs):
@@ -90,6 +90,19 @@ class PMPackageSet(ABCObject, BoolCompat):
except AmbiguousPackageSetError:
raise AmbiguousPackageSetError('Ambiguous filter (matches more than a single package name).')
+ @property
+ def sorted(self):
+ """
+ Return a sorted variant of the package set. The packages will be sorted
+ in a standard PM manner, with better packages coming later. The key
+ ordering is undefined, although usually they will come sorted
+ lexically.
+
+ @return: sorted package set
+ @rtype: L{PMSortedPackageSet}
+ """
+ return PMSortedPackageSet(self)
+
def __getitem__(self, filt):
"""
Select a single package matching an atom (or filter). Unlike L{select()},
@@ -161,3 +174,10 @@ class PMFilteredPackageSet(PMPackageSet):
for el in self._src:
if el._matches(*self._args, **self._kwargs):
yield el
+
+class PMSortedPackageSet(PMPackageSet):
+ def __init__(self, src):
+ self._src = src
+
+ def __iter__(self):
+ return iter(sorted(self._src))
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-23 9:27 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-23 9:27 UTC (permalink / raw
To: gentoo-commits
commit: 888abb76c3079002b4f84519933c629913bba96b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 23 08:57:26 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 23 08:59:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=888abb76
Support comparing (sorting) package keys.
---
gentoopm/basepm/atom.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index bc63325..b37b46f 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -5,9 +5,10 @@
from abc import abstractmethod, abstractproperty
-from gentoopm.util import ABCObject, StringCompat, StringifiedComparisons
+from gentoopm.util import ABCObject, StringCompat, StringifiedComparisons, \
+ FillMissingComparisons
-class PMPackageKey(ABCObject, StringCompat):
+class PMPackageKey(ABCObject, StringCompat, FillMissingComparisons):
"""
A base class for a package key (CP/qualified package name).
"""
@@ -40,6 +41,9 @@ class PMPackageKey(ABCObject, StringCompat):
"""
pass
+ def __lt__(self, other):
+ return str(self) < str(other)
+
class PMIncompletePackageKey(PMPackageKey):
"""
An incomplete package key (without a category).
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-24 20:05 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-24 20:05 UTC (permalink / raw
To: gentoo-commits
commit: 029ea8d67ed8ab476533338f53c934acf1406749
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 24 20:05:45 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 24 20:05:45 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=029ea8d6
Py3: replace callable() with hasattr(..., '__call__').
---
gentoopm/basepm/pkg.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 06b3fee..caa639e 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -92,12 +92,12 @@ class PMPackage(PMAtom, FillMissingComparisons):
"""
for f in args:
- if callable(f): # a matcher
- if not f(self):
- return False
- elif isinstance(f, PMAtom): # an atom
+ if isinstance(f, PMAtom): # an atom
if not self in f:
return False
+ elif hasattr(f, '__call__'):
+ if not f(self):
+ return False
else:
raise ValueError('Incorrect positional argument: %s' % f)
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-25 17:06 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-25 17:06 UTC (permalink / raw
To: gentoo-commits
commit: 2739e2fb39ba2b3b138241c21b1fa1dbfab79ea6
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 16:58:07 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 17:06:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=2739e2fb
PMPackageContents: introduce fallback __contains__().
---
gentoopm/basepm/contents.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/contents.py b/gentoopm/basepm/contents.py
index b173ebf..b904408 100644
--- a/gentoopm/basepm/contents.py
+++ b/gentoopm/basepm/contents.py
@@ -27,7 +27,6 @@ class PMPackageContents(ABCObject):
"""
pass
- @abstractmethod
def __contains__(self, path):
"""
Check whether the path given is installed by the package.
@@ -37,4 +36,9 @@ class PMPackageContents(ABCObject):
@return: whether the path exists in package contents
@rtype: bool
"""
- pass
+
+ path = os.path.normpath(path)
+ for f in self:
+ if str(f) == path:
+ return True
+ return False
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-25 17:33 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-25 17:33 UTC (permalink / raw
To: gentoo-commits
commit: 7e36f1b6ab94ac5b066a8ffe6aa9c2fbb3c138f5
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 17:33:27 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 17:33:27 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=7e36f1b6
PMInstallablePackage: make .contents obligatory.
---
gentoopm/basepm/pkg.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index caa639e..ec89179 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -266,4 +266,12 @@ class PMInstalledPackage(PMPackage):
"""
An abstract class for a installed package.
"""
- pass
+
+ @abstractproperty
+ def contents(self):
+ """
+ Return package contents list accessor.
+
+ @type: L{PMPackageContents}
+ """
+ pass
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-25 17:33 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-25 17:33 UTC (permalink / raw
To: gentoo-commits
commit: 39f7257a5719867a9a9bc41dc094e2e5fc04a5ce
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 17:34:28 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 17:34:28 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=39f7257a
PMPackageSet: fix .sorted doc.
---
gentoopm/basepm/pkgset.py | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/pkgset.py b/gentoopm/basepm/pkgset.py
index b301968..9340ad9 100644
--- a/gentoopm/basepm/pkgset.py
+++ b/gentoopm/basepm/pkgset.py
@@ -98,8 +98,7 @@ class PMPackageSet(ABCObject, BoolCompat):
ordering is undefined, although usually they will come sorted
lexically.
- @return: sorted package set
- @rtype: L{PMSortedPackageSet}
+ @type: L{PMSortedPackageSet}
"""
return PMSortedPackageSet(self)
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-26 7:24 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-26 7:24 UTC (permalink / raw
To: gentoo-commits
commit: e21be5ccba638ae1588d181db23f0e8380a5836d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 07:12:30 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 07:12:30 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e21be5cc
Support removing conditionals from depsets.
---
gentoopm/basepm/depend.py | 49 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/depend.py b/gentoopm/basepm/depend.py
index 78e5c02..e504594 100644
--- a/gentoopm/basepm/depend.py
+++ b/gentoopm/basepm/depend.py
@@ -21,11 +21,46 @@ class PMBaseDep(ABCObject):
"""
pass
+ @abstractproperty
+ def without_conditionals(self):
+ """
+ Return the depspec with all conditionals resolved.
+
+ @type: L{PMUncondDep}
+ """
+ pass
+
+class PMUncondDep(PMBaseDep):
+ def __init__(self, parent):
+ self._parent = parent
+
+ @property
+ def without_conditionals(self):
+ return self
+
+ def _iter_deps(self, deps):
+ for d in deps:
+ if isinstance(d, PMConditionalDep):
+ if d.enabled:
+ for d in self._iter_deps(d):
+ yield d
+ elif isinstance(d, PMOneOfDep):
+ yield PMUncondOneOfDep(d)
+ else:
+ yield d
+
+ def __iter__(self):
+ return self._iter_deps(self._parent)
+
class PMConditionalDep(PMBaseDep):
"""
A conditional dependency set (enabled by a condition of some kind).
"""
+ @property
+ def without_conditionals(self):
+ return PMUncondDep((self,))
+
@abstractproperty
def enabled(self):
"""
@@ -36,10 +71,22 @@ class PMConditionalDep(PMBaseDep):
pass
class PMOneOfDep(PMBaseDep):
+ """
+ A one-of dependency set (C{|| ( ... )}).
+ """
+
+ @property
+ def without_conditionals(self):
+ return PMUncondOneOfDep(self)
+
+class PMUncondOneOfDep(PMOneOfDep, PMUncondDep):
pass
class PMPackageDepSet(PMBaseDep):
"""
A base class representing a depset of a single package.
"""
- pass
+
+ @property
+ def without_conditionals(self):
+ return PMUncondDep(self)
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-26 16:36 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-26 16:36 UTC (permalink / raw
To: gentoo-commits
commit: da059384996e9657d166673a3edeabcdde9199d2
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 16:36:51 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 16:36:51 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=da059384
Support __repr__ on depspecs.
---
gentoopm/basepm/depend.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/depend.py b/gentoopm/basepm/depend.py
index 8d7005d..262a010 100644
--- a/gentoopm/basepm/depend.py
+++ b/gentoopm/basepm/depend.py
@@ -30,6 +30,12 @@ class PMBaseDep(ABCObject):
"""
pass
+ def __repr__(self):
+ l = ['\n'.join(['\t%s' % x for x in repr(d).splitlines()])
+ for d in self]
+ return '%s(\n%s)' % (self.__class__.__name__,
+ ',\n'.join(l))
+
class PMUncondBaseDep(PMBaseDep):
def __init__(self, parent):
self._parent = parent
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-26 20:10 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-26 20:10 UTC (permalink / raw
To: gentoo-commits
commit: 763280601768fdbea58a4824d5d6d35b1b66888a
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 19:37:20 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 19:41:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=76328060
Introduce an abstract API for getting IUSE.
---
gentoopm/basepm/pkg.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index d4f421f..b92a9cc 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -70,6 +70,45 @@ class PMPackageDescription(ABCObject, StringCompat):
"""
return str(self.long or self.short)
+class PMUseFlag(ABCObject, StringCompat):
+ """
+ A base class for a USE flag supported by a package.
+ """
+
+ def __init__(self, usestr):
+ """
+ Instantiate from an IUSE atom.
+
+ @param usestr: the IUSE atom (C{[+-]?flag})
+ @type usestr: string
+ """
+ self._default = None
+ if usestr[0] in ('-', '+'):
+ self._default = (usestr[0] == '+')
+ usestr = usestr[1:]
+ self._name = usestr
+
+ @property
+ def default(self):
+ """
+ The default state, if provided by the ebuild.
+
+ @type: bool/C{None}
+ """
+ return self._default
+
+ @property
+ def name(self):
+ """
+ The flag name.
+
+ @type: string
+ """
+ return self._name
+
+ def __str__(self):
+ return self.name
+
class PMPackage(PMAtom, FillMissingComparisons):
"""
An abstract class representing a single, uniquely-identified package
@@ -240,6 +279,15 @@ class PMPackage(PMAtom, FillMissingComparisons):
"""
pass
+ @property
+ def use(self):
+ """
+ Get the list of USE flags declared in the ebuild (C{IUSE}).
+
+ @type: L{SpaceSepTuple}(L{PMUseFlag})
+ """
+ pass
+
@abstractproperty
def slotted(self):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-26 20:10 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-26 20:10 UTC (permalink / raw
To: gentoo-commits
commit: 59ca15b6f034f514b302e6331e3c9213a95be765
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 19:50:48 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 19:50:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=59ca15b6
Make *DEPEND & IUSE support obligatory.
---
gentoopm/basepm/pkg.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index b92a9cc..d1fa92d 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -252,7 +252,7 @@ class PMPackage(PMAtom, FillMissingComparisons):
return None
return PMPackageEnvironment(p)
- @property
+ @abstractproperty
def build_dependencies(self):
"""
Get the package build dependencies (C{DEPEND}).
@@ -261,7 +261,7 @@ class PMPackage(PMAtom, FillMissingComparisons):
"""
pass
- @property
+ @abstractproperty
def run_dependencies(self):
"""
Get the package runtime dependencies (C{RDEPEND}).
@@ -270,7 +270,7 @@ class PMPackage(PMAtom, FillMissingComparisons):
"""
pass
- @property
+ @abstractproperty
def post_dependencies(self):
"""
Get the package post-installed dependencies (C{PDEPEND}).
@@ -279,7 +279,7 @@ class PMPackage(PMAtom, FillMissingComparisons):
"""
pass
- @property
+ @abstractproperty
def use(self):
"""
Get the list of USE flags declared in the ebuild (C{IUSE}).
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-07-28 16:24 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-07-28 16:24 UTC (permalink / raw
To: gentoo-commits
commit: 9f786534a3828be4f3d7030d773e7a82a542d7f5
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 14:46:53 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 28 14:46:53 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=9f786534
Introduce an abstract exactly-one-of dep.
---
gentoopm/basepm/depend.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/depend.py b/gentoopm/basepm/depend.py
index ca6d2c5..923cdbf 100644
--- a/gentoopm/basepm/depend.py
+++ b/gentoopm/basepm/depend.py
@@ -100,6 +100,18 @@ class PMAnyOfDep(PMBaseDep):
class PMUncondAnyOfDep(PMAnyOfDep, PMUncondBaseDep):
pass
+class PMExactlyOneOfDep(PMBaseDep):
+ """
+ An exactly-one-of (xor) dependency set (C{^^ ( ... )}).
+ """
+
+ @property
+ def without_conditionals(self):
+ return PMUncondExactlyOneOfDep(self)
+
+class PMUncondExactlyOneOfDep(PMExactlyOneOfDep, PMUncondBaseDep):
+ pass
+
class PMPackageDepSet(PMAllOfDep):
"""
A base class representing a depset (or depset-like variable) of a single
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-12 17:43 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-12 17:43 UTC (permalink / raw
To: gentoo-commits
commit: 38eb52756a6c4c31d5a47a572d523a84025d1774
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 17:40:57 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 17:40:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=38eb5275
Re-introduce keyword matching.
---
gentoopm/basepm/filter.py | 56 +++++++++++++++++++++++++++++++++++++++++++++
gentoopm/basepm/pkg.py | 11 +--------
gentoopm/basepm/pkgset.py | 16 +++++++++----
3 files changed, 68 insertions(+), 15 deletions(-)
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
index abcc44d..9c66b6c 100644
--- a/gentoopm/basepm/filter.py
+++ b/gentoopm/basepm/filter.py
@@ -4,6 +4,8 @@
# Released under the terms of the 2-clause BSD license.
from abc import abstractmethod
+from operator import attrgetter
+import itertools
from ..util import ABCObject, FillMissingNotEqual
@@ -44,3 +46,57 @@ class PMKeywordMatcher(ABCObject, FillMissingNotEqual):
@rtype: bool
"""
pass
+
+class SmartAttrGetter(object):
+ """
+ A wrapper on attrgetter, supporting dots replaced by underscores. Uses the
+ first package matched to distinguish between real underscores and dots.
+ """
+
+ def __init__(self, key):
+ self._k = key
+ self._getter = None
+
+ def __call__(self, obj):
+ if self._getter is not None:
+ return self._getter(obj)
+
+ def get_variants(args):
+ prev = None
+ for a in args:
+ if prev is not None:
+ yield ('%s_' % prev, '%s.' % prev)
+ prev = a
+ else:
+ yield (prev,)
+
+ variants = itertools.product(*get_variants(self._k.split('_')))
+ for v in variants:
+ self._getter = attrgetter(''.join(v))
+ try:
+ return self._getter(obj)
+ except AttributeError:
+ pass
+ else:
+ raise KeyError('Invalid keyword argument: %s' % self._k)
+
+class PMTransformedKeywordFilter(PMPackageMatcher):
+ def __init__(self, key, val):
+ self._getter = SmartAttrGetter(key)
+ self._val = val
+
+ def __call__(self, pkg):
+ return self._val == self._getter(pkg)
+
+def transform_keyword_filters(kwargs):
+ """
+ Transform a number of keyword filters into positional args.
+
+ @param kwargs: keyword arguments, as passed to L{PMPackageSet.filter()}
+ @type kwargs: dict
+ @return: positional arguments representing the keyword filters
+ @rtype: tuple
+ """
+
+ return tuple([PMTransformedKeywordFilter(k, v)
+ for k, v in kwargs.items()])
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index cfa4735..4a17335 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -111,7 +111,7 @@ class PMPackage(PMAtom, FillMissingComparisons):
in the package tree.
"""
- def _matches(self, *args, **kwargs):
+ def _matches(self, *args):
"""
Check whether the package matches passed filters. Please note that this
method may not be called at all if PM is capable of a more efficient
@@ -136,15 +136,6 @@ class PMPackage(PMAtom, FillMissingComparisons):
else:
raise ValueError('Incorrect positional argument: %s' % f)
- for k, m in kwargs.items():
- try:
- v = self.metadata[k]
- except KeyError:
- raise KeyError('Unmatched keyword argument: %s' % k)
- else:
- if not m == v:
- return False
-
return True
@property
diff --git a/gentoopm/basepm/pkgset.py b/gentoopm/basepm/pkgset.py
index c534281..bf8c66a 100644
--- a/gentoopm/basepm/pkgset.py
+++ b/gentoopm/basepm/pkgset.py
@@ -5,6 +5,8 @@
from abc import abstractmethod
+from .filter import transform_keyword_filters
+
from ..exceptions import EmptyPackageSetError, AmbiguousPackageSetError
from ..util import ABCObject, BoolCompat
@@ -26,8 +28,13 @@ class PMPackageSet(ABCObject, BoolCompat):
Filter the packages based on arguments. Return a filtered package set.
The positional arguments can provide a number of L{PMPackageMatcher}s
- and/or a L{PMAtom} instance. The keyword arguments match metadata keys
- using '==' comparison with passed string (or L{PMKeywordMatcher}s).
+ (which are basically lambdas with a L{PMPackage} instance argument)
+ and/or a L{PMAtom} instance.
+
+ The keyword arguments match metadata keys using C{==} comparison with
+ the passed string (or L{PMKeywordMatcher}s). Keys are supposed to be
+ L{PMPackage} property names in Python; dots can be replaced by
+ underscores (e.g. C{description_short}) or passed using C{**} operator.
Multiple filters will be AND-ed together. Same applies for .filter()
called multiple times. You should, however, avoid passing multiple
@@ -166,12 +173,11 @@ class PMPackageSet(ABCObject, BoolCompat):
class PMFilteredPackageSet(PMPackageSet):
def __init__(self, src, args, kwargs):
self._src = src
- self._args = args
- self._kwargs = kwargs
+ self._args = args + transform_keyword_filters(kwargs)
def __iter__(self):
for el in self._src:
- if el._matches(*self._args, **self._kwargs):
+ if el._matches(*self._args):
yield el
class PMSortedPackageSet(PMPackageSet):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-12 20:38 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-12 20:38 UTC (permalink / raw
To: gentoo-commits
commit: d3cc5230a4a8b3bf4a5cbf05630cdea1de50fecc
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 20:39:27 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 20:39:27 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=d3cc5230
Use hardcoded list to generate AttributeMatches from kwargs.
---
gentoopm/basepm/filter.py | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
index 0851d84..a43fad6 100644
--- a/gentoopm/basepm/filter.py
+++ b/gentoopm/basepm/filter.py
@@ -81,14 +81,19 @@ class SmartAttrGetter(object):
raise KeyError('Invalid keyword argument: %s' % self._k)
class PMTransformedKeywordFilter(PMPackageMatcher):
- # XXX: transform this to subclass of ..filters.AttributeMatch
- # hardcode 'foo_bar' -> 'foo.bar' mappings instead of doing magic
- def __init__(self, key, val):
- self._getter = SmartAttrGetter(key)
- self._val = val
-
- def __call__(self, pkg):
- return self._val == self._getter(pkg)
+ _map = {
+ 'key_category': 'key.category',
+ 'key_package': 'key.package',
+ 'key_state': 'key.state',
+ 'description_short': 'description.short',
+ 'description_long': 'description.long'
+ }
+
+ def __new__(self, key, val):
+ from ..filters import AttributeMatch
+ if key in self._map:
+ key = self._map[key]
+ return AttributeMatch(key, val)
def transform_keyword_filters(kwargs):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-13 9:17 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-13 9:17 UTC (permalink / raw
To: gentoo-commits
commit: 017172493ded87ad77cb197f3c65ec8d81db9485
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 13 09:07:27 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 13 09:18:06 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=01717249
Fix concatenating kwfilters, use itertools.
---
gentoopm/basepm/filter.py | 5 ++---
gentoopm/basepm/pkgset.py | 4 +++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/gentoopm/basepm/filter.py b/gentoopm/basepm/filter.py
index a43fad6..1d704b5 100644
--- a/gentoopm/basepm/filter.py
+++ b/gentoopm/basepm/filter.py
@@ -102,8 +102,7 @@ def transform_keyword_filters(kwargs):
@param kwargs: keyword arguments, as passed to L{PMPackageSet.filter()}
@type kwargs: dict
@return: positional arguments representing the keyword filters
- @rtype: tuple
+ @rtype: iter(L{AttributeMatch})
"""
- return tuple([PMTransformedKeywordFilter(k, v)
- for k, v in kwargs.items()])
+ return itertools.starmap(PMTransformedKeywordFilter, kwargs.items())
diff --git a/gentoopm/basepm/pkgset.py b/gentoopm/basepm/pkgset.py
index bf8c66a..390cde9 100644
--- a/gentoopm/basepm/pkgset.py
+++ b/gentoopm/basepm/pkgset.py
@@ -3,6 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import itertools
from abc import abstractmethod
from .filter import transform_keyword_filters
@@ -173,7 +174,8 @@ class PMPackageSet(ABCObject, BoolCompat):
class PMFilteredPackageSet(PMPackageSet):
def __init__(self, src, args, kwargs):
self._src = src
- self._args = args + transform_keyword_filters(kwargs)
+ self._args = tuple(itertools.chain(args,
+ transform_keyword_filters(kwargs)))
def __iter__(self):
for el in self._src:
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-15 7:57 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-15 7:57 UTC (permalink / raw
To: gentoo-commits
commit: 801aeb4554d9e78f0bcd1b63023eaa372d91377f
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 07:31:30 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 07:31:30 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=801aeb45
PMBoundPackageKey: fill missing '!=' comparison.
---
gentoopm/basepm/pkg.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 9f17ed9..c379802 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -6,7 +6,8 @@
import os.path
from abc import abstractmethod, abstractproperty
-from ..util import ABCObject, FillMissingComparisons, StringCompat2, EnumTuple
+from ..util import ABCObject, FillMissingComparisons, StringCompat2, \
+ EnumTuple, FillMissingNotEqual
from .atom import PMAtom, PMPackageKey
from .environ import PMPackageEnvironment
@@ -15,7 +16,7 @@ PMPackageState = EnumTuple('PMPackageState',
'installable',
'installed')
-class PMBoundPackageKey(PMPackageKey):
+class PMBoundPackageKey(FillMissingNotEqual, PMPackageKey):
"""
A package key bound to a specific package.
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-15 8:48 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-15 8:48 UTC (permalink / raw
To: gentoo-commits
commit: 0976812c73afe48639cac0671c602a9d35f08908
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 08:49:12 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 08:49:12 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=0976812c
Migrate PMRequiredUseAtom to new StringCompat.
---
gentoopm/basepm/depend.py | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/gentoopm/basepm/depend.py b/gentoopm/basepm/depend.py
index aad29ad..b765445 100644
--- a/gentoopm/basepm/depend.py
+++ b/gentoopm/basepm/depend.py
@@ -5,18 +5,20 @@
from abc import abstractmethod, abstractproperty
-from ..util import ABCObject, StringCompat2
+from ..util import ABCObject, StringCompat
-class PMRequiredUseAtom(StringCompat2):
+class PMRequiredUseAtom(StringCompat):
"""
An atom for C{REQUIRED_USE} specification.
"""
- def __init__(self, s):
- self._blocks = s.startswith('!')
- if self._blocks:
+ def __new__(self, s):
+ rua = StringCompat.__new__(self, s)
+ rua._blocks = s.startswith('!')
+ if rua._blocks:
s = s[1:]
- self._flag = s
+ rua._flag = s
+ return rua
@property
def name(self):
@@ -45,10 +47,6 @@ class PMRequiredUseAtom(StringCompat2):
"""
return not self._blocks
- def __str__(self):
- return '%s%s' % ('!' if self._blocks else '',
- self.name)
-
class PMBaseDep(ABCObject):
"""
Base class for a dependency list holder.
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-08-15 8:48 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-08-15 8:48 UTC (permalink / raw
To: gentoo-commits
commit: a80d8e7dfc32eaeb93f36cfbc7946ade3f4909f8
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 08:39:39 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 08:39:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a80d8e7d
Migrate PMContentObj to new StringCompat.
---
gentoopm/basepm/contents.py | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gentoopm/basepm/contents.py b/gentoopm/basepm/contents.py
index fc5ec66..be96e77 100644
--- a/gentoopm/basepm/contents.py
+++ b/gentoopm/basepm/contents.py
@@ -6,14 +6,11 @@
import os.path
from abc import abstractmethod, abstractproperty
-from ..util import ABCObject, StringCompat2
+from ..util import ABCObject, StringCompat
-class PMContentObj(StringCompat2):
- def __init__(self, path):
- self._path = os.path.normpath(path)
-
- def __str__(self):
- return self._path
+class PMContentObj(StringCompat):
+ def __new__(self, path):
+ return StringCompat.__new__(self, os.path.normpath(path))
class PMPackageContents(ABCObject):
"""
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-09-10 8:28 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-09-10 8:28 UTC (permalink / raw
To: gentoo-commits
commit: 1ee846c8dc76fda41f16a31e13f7ebae9b069247
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 10 08:30:00 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Sep 10 08:30:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=1ee846c8
Name herds explicitly.
---
gentoopm/basepm/pkg.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index c536a69..92069d1 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -158,7 +158,8 @@ class PMPackageHerd(PMPackageMaintainer):
@type name: string
"""
return PMPackageMaintainer.__new__(self,
- '%s@gentoo.org' % name)
+ '%s@gentoo.org' % name, # XXX
+ '%s herd' % name)
@property
def description(self):
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2011-12-24 9:18 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2011-12-24 9:18 UTC (permalink / raw
To: gentoo-commits
commit: 750eff068d0337159c0367c9a4d096ce8c98c900
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 24 09:18:52 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 09:18:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=750eff06
Portage: fix environment.* file sorting.
---
gentoopm/basepm/pkg.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index d63d5fc..cbc2362 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -287,10 +287,10 @@ class PMPackage(PMAtom, FillMissingComparisons):
except OSError:
return -1
- files = ('environment.bz2', 'environment')
+ files = [os.path.join(p, fn) for fn
+ in ('environment.bz2', 'environment')]
# Take the newer one.
- fn = sorted(files, key=_mtime_if_exists, reverse=True)[0]
- p = os.path.join(p, fn)
+ p = sorted(files, key=_mtime_if_exists, reverse=True)[0]
if not os.path.exists(p):
return None
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2013-08-05 16:04 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2013-08-05 16:04 UTC (permalink / raw
To: gentoo-commits
commit: 26cd74522454e6e41b9f9c313b193e09f0ea78be
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 5 16:04:49 2013 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 5 16:04:49 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=26cd7452
Open environment file in binary mode to match writing.
---
gentoopm/basepm/environ.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gentoopm/basepm/environ.py b/gentoopm/basepm/environ.py
index 178a13d..21802ed 100644
--- a/gentoopm/basepm/environ.py
+++ b/gentoopm/basepm/environ.py
@@ -18,7 +18,7 @@ def _load_bp(bp, path):
"""
def _try_file(t):
- f = t(path, 'r')
+ f = t(path, 'rb')
try:
bp.load_file(f)
finally:
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
@ 2015-08-07 9:18 Michał Górny
0 siblings, 0 replies; 55+ messages in thread
From: Michał Górny @ 2015-08-07 9:18 UTC (permalink / raw
To: gentoo-commits
commit: 4feab429fa01c0555b6d6b664a284fb8fac94e5e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 7 09:18:42 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 7 09:18:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/gentoopm.git/commit/?id=4feab429
Fix whitespace
gentoopm/basepm/environ.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gentoopm/basepm/environ.py b/gentoopm/basepm/environ.py
index 3d5aba6..c23226c 100644
--- a/gentoopm/basepm/environ.py
+++ b/gentoopm/basepm/environ.py
@@ -54,8 +54,8 @@ class LazyBashParser(object):
def __getitem__(self, k):
return self._parser[k]
- def __call__(self, code):
- return self._parser(code)
+ def __call__(self, code):
+ return self._parser(code)
def copy(self, *v):
return self._parser.copy(*v)
@@ -90,7 +90,7 @@ class PMPackageEnvironment(object):
def __call__(self, code):
"""
- Run the given bash code and return the exit code.
+ Run the given bash code and return the exit code.
@param code: bash code to run
@type code: string
^ permalink raw reply related [flat|nested] 55+ messages in thread
end of thread, other threads:[~2015-08-07 9:18 UTC | newest]
Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 16:36 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2015-08-07 9:18 Michał Górny
2013-08-05 16:04 Michał Górny
2011-12-24 9:18 Michał Górny
2011-09-10 8:28 Michał Górny
2011-08-15 8:48 Michał Górny
2011-08-15 8:48 Michał Górny
2011-08-15 7:57 Michał Górny
2011-08-13 9:17 Michał Górny
2011-08-12 20:38 Michał Górny
2011-08-12 17:43 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-26 20:10 Michał Górny
2011-07-26 20:10 Michał Górny
2011-07-26 7:24 Michał Górny
2011-07-25 17:33 Michał Górny
2011-07-25 17:33 Michał Górny
2011-07-25 17:06 Michał Górny
2011-07-24 20:05 Michał Górny
2011-07-23 9:27 Michał Górny
2011-07-23 9:27 Michał Górny
2011-07-21 8:47 Michał Górny
2011-07-20 9:41 Michał Górny
2011-07-17 22:39 Michał Górny
2011-07-17 22:10 Michał Górny
2011-07-17 22:10 Michał Górny
2011-07-17 22:10 Michał Górny
2011-07-17 9:09 Michał Górny
2011-07-15 23:56 Michał Górny
2011-07-15 23:56 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15 9:52 Michał Górny
2011-07-15 9:52 Michał Górny
2011-07-14 22:51 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-13 16:30 Michał Górny
2011-07-13 16:09 Michał Górny
2011-07-11 9:39 Michał Górny
2011-07-11 9:39 Michał Górny
2011-07-10 12:34 Michał Górny
2011-07-08 12:49 Michał Górny
2011-07-08 12:49 Michał Górny
2011-07-07 12:52 Michał Górny
2011-07-07 12:52 Michał Górny
2011-07-07 12:52 Michał Górny
2011-07-07 9:51 Michał Górny
2011-07-06 20:54 Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox