From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/pkgcorepm/, gentoopm/paludispm/, gentoopm/basepm/
Date: Mon, 15 Aug 2011 08:48:28 +0000 (UTC) [thread overview]
Message-ID: <b7bd88fc0a3fab28b28bea0cb30a030139d5538b.mgorny@gentoo> (raw)
commit: b7bd88fc0a3fab28b28bea0cb30a030139d5538b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 08:45:57 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 08:45:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=b7bd88fc
Migrate PMUseFlag to new StringCompat.
---
gentoopm/basepm/pkg.py | 13 +++++--------
gentoopm/paludispm/pkg.py | 10 ++++------
gentoopm/pkgcorepm/pkg.py | 7 ++++---
gentoopm/portagepm/pkg.py | 7 ++++---
4 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index c379802..3ad2774 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -6,7 +6,7 @@
import os.path
from abc import abstractmethod, abstractproperty
-from ..util import ABCObject, FillMissingComparisons, StringCompat2, \
+from ..util import ABCObject, FillMissingComparisons, StringCompat, \
EnumTuple, FillMissingNotEqual
from .atom import PMAtom, PMPackageKey
@@ -61,19 +61,19 @@ class PMPackageDescription(ABCObject):
"""
pass
-class PMUseFlag(ABCObject, StringCompat2):
+class PMUseFlag(ABCObject, StringCompat):
"""
A base class for a USE flag supported by a package.
"""
- def __init__(self, usestr):
+ def __new__(self, usestr):
"""
Instantiate from an IUSE atom.
@param usestr: the IUSE atom (C{[+-]?flag})
@type usestr: string
"""
- self._name = usestr.lstrip('+-')
+ return StringCompat.__new__(self, usestr.lstrip('+-'))
@property
def name(self):
@@ -82,7 +82,7 @@ class PMUseFlag(ABCObject, StringCompat2):
@type: string
"""
- return self._name
+ return str(self)
@abstractproperty
def enabled(self):
@@ -93,9 +93,6 @@ class PMUseFlag(ABCObject, StringCompat2):
"""
pass
- def __str__(self):
- return self.name
-
class PMPackage(PMAtom, FillMissingComparisons):
"""
An abstract class representing a single, uniquely-identified package
diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py
index 18b2d17..9ccfed1 100644
--- a/gentoopm/paludispm/pkg.py
+++ b/gentoopm/paludispm/pkg.py
@@ -41,12 +41,10 @@ class PaludisPackageDescription(PMPackageDescription):
return k.parse_value() if k is not None else None
class PaludisChoice(PMUseFlag):
- def __init__(self, choice):
- self._c = choice
-
- @property
- def name(self):
- return str(self._c.name_with_prefix)
+ def __new__(self, choice):
+ uf = PMUseFlag.__new__(self, str(choice.name_with_prefix))
+ uf._c = choice
+ return uf
@property
def enabled(self):
diff --git a/gentoopm/pkgcorepm/pkg.py b/gentoopm/pkgcorepm/pkg.py
index 8a1fcbf..d2ca767 100644
--- a/gentoopm/pkgcorepm/pkg.py
+++ b/gentoopm/pkgcorepm/pkg.py
@@ -46,9 +46,10 @@ class PkgCorePackageDescription(PMPackageDescription):
return None
class PkgCoreUseFlag(PMUseFlag):
- def __init__(self, s, enabled_use):
- PMUseFlag.__init__(self, s)
- self._enabled = self.name in enabled_use
+ def __new__(self, s, enabled_use):
+ uf = PMUseFlag.__new__(self, s)
+ uf._enabled = self.name in enabled_use
+ return uf
@property
def enabled(self):
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 2a3d64e..5ad9cb3 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -58,9 +58,10 @@ class PortagePackageDescription(PMPackageDescription):
return None # XXX
class PortageUseFlag(PMUseFlag):
- def __init__(self, s, enabled_use):
- PMUseFlag.__init__(self, s)
- self._enabled = self.name in enabled_use
+ def __new__(self, s, enabled_use):
+ uf = PMUseFlag.__new__(self, s)
+ uf._enabled = self.name in enabled_use
+ return uf
@property
def enabled(self):
next reply other threads:[~2011-08-15 8:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 8:48 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-09-16 7:39 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/pkgcorepm/, gentoopm/paludispm/, gentoopm/basepm/ Michał Górny
2011-08-15 9:01 Michał Górny
2011-08-15 7:57 Michał Górny
2011-08-14 14:22 Michał Górny
2011-08-12 8:24 Michał Górny
2011-08-01 17:14 Michał Górny
2011-07-30 18:39 Michał Górny
2011-07-30 8:13 Michał Górny
2011-07-28 19:54 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-27 21:32 Michał Górny
2011-07-27 16:24 Michał Górny
2011-07-27 16:24 Michał Górny
2011-07-23 9:27 Michał Górny
2011-07-21 8:47 Michał Górny
2011-07-20 18:02 Michał Górny
2011-07-20 9:41 Michał Górny
2011-07-19 11:53 Michał Górny
2011-07-18 17:54 Michał Górny
2011-07-18 14:40 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 12:19 Michał Górny
2011-07-13 16:09 Michał Górny
2011-07-13 16:09 Michał Górny
2011-07-12 8:31 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
2011-07-06 16:03 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7bd88fc0a3fab28b28bea0cb30a030139d5538b.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox