diff options
author | 2005-07-13 05:51:35 +0000 | |
---|---|---|
committer | 2005-07-13 05:51:35 +0000 | |
commit | 68846ed4585403722eed9a77ab71431bab5b75cb (patch) | |
tree | 333c5f13273af5b20c337fbee303e3552941c75d | |
parent | bad language makes kittens cry (diff) | |
download | portage-cvs-68846ed4585403722eed9a77ab71431bab5b75cb.tar.gz portage-cvs-68846ed4585403722eed9a77ab71431bab5b75cb.tar.bz2 portage-cvs-68846ed4585403722eed9a77ab71431bab5b75cb.zip |
alright, y'all have permission to shoot me on this one. The short version is a massive amount of changes here and there, tweaks,
etc.
Problem? Well, I *was* using my own cvs repo for this, so the headers changed on *each* python file. so...
what has *actually* changed.
removed
package.cpv.Atom
added package.atom
fixed up restrictions.restriction and added StrGlobMatch
beyond that, fixes here and there, nothing to note.
53 files changed, 406 insertions, 372 deletions
diff --git a/portage/binpkg/repository.py b/portage/binpkg/repository.py index ca65cce..6e521e4 100644 --- a/portage/binpkg/repository.py +++ b/portage/binpkg/repository.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/binpkg/repository.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/binpkg/repository.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ #yoink when fixed diff --git a/portage/cache/__init__.py b/portage/cache/__init__.py index 8af161e..07478af 100644 --- a/portage/cache/__init__.py +++ b/portage/cache/__init__.py @@ -1,5 +1,5 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ diff --git a/portage/cache/anydbm.py b/portage/cache/anydbm.py index 5f3242e..c3ff03d 100644 --- a/portage/cache/anydbm.py +++ b/portage/cache/anydbm.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/anydbm.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/anydbm.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ anydbm_module = __import__("anydbm") import cPickle, os diff --git a/portage/cache/cache_errors.py b/portage/cache/cache_errors.py index 8a68e31..4f8976a 100644 --- a/portage/cache/cache_errors.py +++ b/portage/cache/cache_errors.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/cache_errors.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/cache_errors.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class CacheError(Exception): pass diff --git a/portage/cache/flat_list.py b/portage/cache/flat_list.py index 81549f8..d9b23a8 100644 --- a/portage/cache/flat_list.py +++ b/portage/cache/flat_list.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/flat_list.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/flat_list.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import fs_template import cache_errors diff --git a/portage/cache/fs_template.py b/portage/cache/fs_template.py index de0e01f..de2ac13 100644 --- a/portage/cache/fs_template.py +++ b/portage/cache/fs_template.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/fs_template.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/fs_template.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import os import template, cache_errors diff --git a/portage/cache/metadata.py b/portage/cache/metadata.py index d136bf3..dd376f6 100644 --- a/portage/cache/metadata.py +++ b/portage/cache/metadata.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/metadata.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/metadata.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import os, stat import fs_template diff --git a/portage/cache/multiplex.py b/portage/cache/multiplex.py index 826cf09..5f081fb 100644 --- a/portage/cache/multiplex.py +++ b/portage/cache/multiplex.py @@ -1,5 +1,5 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/multiplex.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/multiplex.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ diff --git a/portage/cache/sql_template.py b/portage/cache/sql_template.py index 1cb11bd..f91b398 100644 --- a/portage/cache/sql_template.py +++ b/portage/cache/sql_template.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/sql_template.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/sql_template.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import template, cache_errors diff --git a/portage/cache/sqlite.py b/portage/cache/sqlite.py index 925408f..a4448ab 100644 --- a/portage/cache/sqlite.py +++ b/portage/cache/sqlite.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/sqlite.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/sqlite.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ sqlite_module =__import__("sqlite") import os diff --git a/portage/cache/template.py b/portage/cache/template.py index 3215b4b..8b30e5f 100644 --- a/portage/cache/template.py +++ b/portage/cache/template.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/template.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/template.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import cache_errors, copy diff --git a/portage/cache/util.py b/portage/cache/util.py index 9aab6dd..5d1ffec 100644 --- a/portage/cache/util.py +++ b/portage/cache/util.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/util.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/util.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import cache_errors diff --git a/portage/chksum/__init__.py b/portage/chksum/__init__.py index ae15b6d..81bfff9 100644 --- a/portage/chksum/__init__.py +++ b/portage/chksum/__init__.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import os diff --git a/portage/chksum/md5hash.py b/portage/chksum/md5hash.py index 3b136a0..266eaa2 100644 --- a/portage/chksum/md5hash.py +++ b/portage/chksum/md5hash.py @@ -1,6 +1,6 @@ # Copyright: 2004-2005 Gentoo Foundation # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/md5hash.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/md5hash.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ # We _try_ to load this module. If it fails we do the slow fallback. diff --git a/portage/chksum/sha1hash.py b/portage/chksum/sha1hash.py index b0fbea4..0283edb 100644 --- a/portage/chksum/sha1hash.py +++ b/portage/chksum/sha1hash.py @@ -1,6 +1,6 @@ # Copyright: 2004-2005 Gentoo Foundation # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/sha1hash.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/chksum/sha1hash.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import sha diff --git a/portage/config/NewStyle.py b/portage/config/NewStyle.py index 24cbf5e..6f3f2ae 100644 --- a/portage/config/NewStyle.py +++ b/portage/config/NewStyle.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/Attic/NewStyle.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/Attic/NewStyle.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import logging import errors diff --git a/portage/config/__init__.py b/portage/config/__init__.py index ad7ad1d..5b31850 100644 --- a/portage/config/__init__.py +++ b/portage/config/__init__.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import ConfigParser import central, os diff --git a/portage/config/central.py b/portage/config/central.py index bd98df6..04677d9 100644 --- a/portage/config/central.py +++ b/portage/config/central.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/central.py,v 1.2 2005/07/12 02:22:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/central.py,v 1.3 2005/07/13 05:51:35 ferringb Exp $ import errors from portage.const import CONF_DEFAULTS @@ -16,7 +16,7 @@ class config: self._cparser = cparser self.type_handler = load_conf_definitions(conf_defaults) self.type_conversions = {} - # add auto exec stuff goes here + # add auto exec shit # weakref .instantiated? self.instantiated = {} for t in self.type_handler: diff --git a/portage/config/domain.py b/portage/config/domain.py index 0fa62d4..a1ef200 100644 --- a/portage/config/domain.py +++ b/portage/config/domain.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/domain.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/domain.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class domain: diff --git a/portage/config/errors.py b/portage/config/errors.py index caaec19..9ddc0bc 100644 --- a/portage/config/errors.py +++ b/portage/config/errors.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/errors.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/config/errors.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ # potentially use an intermediate base for user config errors, seperate base for instantiation? class BaseException(Exception): diff --git a/portage/ebuild/conditionals.py b/portage/ebuild/conditionals.py new file mode 100644 index 0000000..cd32d5e --- /dev/null +++ b/portage/ebuild/conditionals.py @@ -0,0 +1,70 @@ +# Copyright: 2005 Gentoo Foundation +# Author(s): Jason Stubbs (jstubbs@gentoo.org), Brian Harring (ferringb@gentoo.org) +# License: GPL2 +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/conditionals.py,v 1.1 2005/07/13 05:51:34 ferringb Exp $ + +# TODO: move exceptions elsewhere, bind them to a base exception for portage + +from portage.package.cpv import Atom +import logging + +class Conditional(object): + def __init__(self, node, payload): + self.node, self.payload = node, payload + + def __str__(self): return "%s? ( %s )" % (self.node, self.payload) + +class DepSet(object): + def __init__(self, dep_str, element_func, cleanse_string=True, collapse=True): + """dep_str is a dep style syntax, element_func is a callable returning the obj for each element, and + cleanse_string controls whether or translation of tabs/newlines is required""" + pos = 0 + if cleanse_string: + dep_str = ' '.join(dep_str.split()) + strlen = len(dep_str) + self.elements = [] + last_parsed = 0 + + while pos < strlen: + while pos < strlen and dep_str[pos].isspace(): + pos+=1 + next_pos = dep_str.find(" ", pos) +# import pdb;pdb.set_trace() + if next_pos < 0: + self.elements.append(element_func(dep_str[pos:])) + pos = strlen + elif dep_str[next_pos - 1] == '?': + # use conditional. + block_start = next_pos + while dep_str[block_start].isspace() and block_start < strlen: + block_start += 1 + if block_start == strlen or dep_str[block_start] != '(': + raise ParseError(dep_str) + # point of optimization. rather then reparsing every level, collapse it so single parsing. + levels=1 + block_end = block_start = block_start + 1 + while levels: + block_end += 1 + while block_end < strlen and dep_str[block_end] not in ('(',')'): + block_end += 1 + if block_end == strlen: + raise ParseError(dep_str) + elif dep_str[block_end] == '(': + levels += 1 + elif dep_str[block_end] == ')': + levels -= 1 + d = self.__class__(dep_str[block_start:block_end].strip(), element_func, cleanse_string=False) + self.elements.append(Conditional(dep_str[pos:next_pos - 1], d)) + pos = block_end + 1 + else: + # node/element. + self.elements.append(element_func(dep_str[pos:next_pos].strip())) + pos = next_pos + + + def __str__(self): return ' '.join(map(str,self.elements)) + + +class ParseError(Exception): + def __init__(self, s): self.dep_str = s + def __str__(self): return "%s is unparseable" % self.s diff --git a/portage/ebuild/ebuild_internal.py b/portage/ebuild/ebuild_internal.py index 7f86430..7a7e393 100644 --- a/portage/ebuild/ebuild_internal.py +++ b/portage/ebuild/ebuild_internal.py @@ -2,7 +2,7 @@ # ebuild.py; Ebuild classes/abstraction of phase processing, and communicating with a ebuild-daemon.sh instance # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_internal.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_internal.py,v 1.2 2005/07/13 05:51:34 ferringb Exp $ import os,sys,traceback diff --git a/portage/ebuild/ebuild_package.py b/portage/ebuild/ebuild_package.py index 1273533..afbec74 100644 --- a/portage/ebuild/ebuild_package.py +++ b/portage/ebuild/ebuild_package.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_package.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_package.py,v 1.2 2005/07/13 05:51:34 ferringb Exp $ import os from portage import package @@ -44,11 +44,11 @@ class ebuild_package(package.metadata.package): # ah hell. data = self._parent._update_metadata(self) - for k,v in data.items(): - self.__dict__[k] = v +# for k,v in data.items(): +# self.__dict__[k] = v - self.__dict__["_finalized"] = True - return +# self.__dict__["_finalized"] = True + return data class ebuild_factory(package.metadata.factory): diff --git a/portage/ebuild/ebuild_repository.py b/portage/ebuild/ebuild_repository.py index 130e9fb..ba4f864 100644 --- a/portage/ebuild/ebuild_repository.py +++ b/portage/ebuild/ebuild_repository.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_repository.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/ebuild_repository.py,v 1.2 2005/07/13 05:51:34 ferringb Exp $ import os, stat from portage.repository import prototype, errors @@ -26,7 +26,8 @@ class tree(prototype.tree): if eclass_cache == None: import eclass_cache eclass_cache = eclass_cache.cache(self.base) - self.metadata = ebuild_package.ebuild_factory(self, cache, eclass_cache) + self.package_class = ebuild_package.ebuild_factory(self, cache, eclass_cache).new_package + def _get_categories(self, *optionalCategory): # why the auto return? current porttrees don't allow/support categories deeper then one dir. @@ -40,6 +41,7 @@ class tree(prototype.tree): except (OSError, IOError), e: raise KeyError("failed fetching categories: %s" % str(e)) + def _get_packages(self, category): cpath = os.path.join(self.base,category.lstrip(os.path.sep)) @@ -50,6 +52,7 @@ class tree(prototype.tree): raise KeyError("failed fetching packages for category %s: %s" % \ (os.path.join(self.base,category.lstrip(os.path.sep)), str(e))) + def _get_versions(self, catpkg): pkg = catpkg.split("/")[-1] diff --git a/portage/ebuild/eclass_cache.py b/portage/ebuild/eclass_cache.py index c8efc1d..1aa821c 100644 --- a/portage/ebuild/eclass_cache.py +++ b/portage/ebuild/eclass_cache.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/eclass_cache.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/eclass_cache.py,v 1.2 2005/07/13 05:51:34 ferringb Exp $ from portage.util.fs import normpath import os, sys diff --git a/portage/ebuild/processor.py b/portage/ebuild/processor.py index 93c7517..0f1e29d 100644 --- a/portage/ebuild/processor.py +++ b/portage/ebuild/processor.py @@ -1,7 +1,7 @@ # Copyright: 2004-2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/processor.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/ebuild/processor.py,v 1.2 2005/07/13 05:51:34 ferringb Exp $ inactive_ebp_list = [] active_ebp_list = [] diff --git a/portage/package/__init__.py b/portage/package/__init__.py index bcd3699..93acf1c 100644 --- a/portage/package/__init__.py +++ b/portage/package/__init__.py @@ -1,6 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import metadata +from cpv import CPV as cpv diff --git a/portage/package/atom.py b/portage/package/atom.py new file mode 100644 index 0000000..b62c704 --- /dev/null +++ b/portage/package/atom.py @@ -0,0 +1,75 @@ +# Copyright: 2005 Gentoo Foundation +# Author(s): Jason Stubbs (jstubbs@gentoo.org), Brian Harring (ferringb@gentoo.org) +# License: GPL2 +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/atom.py,v 1.1 2005/07/13 05:51:35 ferringb Exp $ + +from portage.restrictions import restriction +from cpv import ver_cmp, CPV +from portage.restrictions.restrictionSet import AndRestrictionSet + +class VersionMatch(restriction.base): + __slots__ = tuple(["ver","rev", "vals"] + restriction.StrMatch.__slots__) + def __init__(self, operator, ver, rev=None, **kwd): + super(self.__class__, self).__init__(**kwd) + self.ver, self.rev = ver, rev + l=[] + if ">" in operator: l.append(1) + if "<" in operator: l.append(-1) + if "=" in operator: l.append(0) + self.vals = tuple(l) + + def match(self, pkginst): + return (ver_cmp(self.ver, self.rev, pkginst.version, pkginst.revision) in self.vals) ^ self.negate + + +class atom(AndRestrictionSet): + def __init__(self, atom, slot=None, use=[]): + + super(self.__class__, self).__init__() + + pos=0 + while atom[pos] in ("<",">","=","~","!"): + pos+=1 + if atom.startswith("!"): + self.blocks = True + self.op = atom[1:pos] + else: + self.blocks = False + self.op = atom[:pos] + if atom.endswith("*"): + self.glob = True + self.atom = atom[pos:-1] + else: + self.glob = False + self.atom = atom[pos:] + + self.cpv = CPV(self.atom) + self.use, self.slot = use, slot + # force jitting of it. + del self.restrictions + + def __getattr__(self, attr): + if attr in ("category", "package", "version", "revision", "cpvstr", "fullver", "key"): + g = getattr(self.cpv, attr) + self.__dict__[attr] = g + return g + + elif attr == "restrictions": + r = [] + try: + cat = self.category + r.append(restriction.PackageRestriction("category", restriction.StrExactMatch(cat))) + except AttributeError: + pass + r.append(restriction.PackageRestriction("package", restriction.StrExactMatch(self.package))) + if self.version: + if self.glob: + r.append(restriction.PackageRestriction("fullver", restriction.StrGlobMatch(self.fullver))) + else: + r.append(VersionMatch(self.op, self.version, self.revision)) + if self.use or self.slot: + raise Exception("yo. I don't support use or slot yet, fix me pls kthnx") + self.__dict__["restrictions"] = r + return r + + raise AttributeError(attr) diff --git a/portage/package/cpv.py b/portage/package/cpv.py index d417643..eac55a9 100644 --- a/portage/package/cpv.py +++ b/portage/package/cpv.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Jason Stubbs (jstubbs@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/cpv.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/cpv.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import re @@ -122,207 +122,84 @@ class CPV(object): if self.package and other.package and self.package != other.package: return cmp(self.package, other.package) - if self.version != other.version: - - if self.version is None: - raise ValueError(self) - - if other.version is None: - raise ValueError(other) - - match1 = ver_regexp.match(self.version) - match2 = ver_regexp.match(other.version) - - # shortcut for cvs ebuilds (new style) - if match1.group(1) and not match2.group(1): - return 1 - elif match2.group(1) and not match1.group(1): - return -1 - - # building lists of the version parts before the suffix - # first part is simple - list1 = [int(match1.group(2))] - list2 = [int(match2.group(2))] - - # this part would greatly benefit from a fixed-length version pattern - if len(match1.group(3)) or len(match2.group(3)): - vlist1 = match1.group(3)[1:].split(".") - vlist2 = match2.group(3)[1:].split(".") - for i in range(0, max(len(vlist1), len(vlist2))): - if len(vlist1) <= i or len(vlist1[i]) == 0: - list1.append(0) - list2.append(int(vlist2[i])) - elif len(vlist2) <= i or len(vlist2[i]) == 0: - list1.append(int(vlist1[i])) - list2.append(0) - # Let's make life easy and use integers unless we're forced to use floats - elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"): - list1.append(int(vlist1[i])) - list2.append(int(vlist2[i])) - # now we have to use floats so 1.02 compares correctly against 1.1 - else: - list1.append(float("0."+vlist1[i])) - list2.append(float("0."+vlist2[i])) - - # and now the final letter - if len(match1.group(5)): - list1.append(ord(match1.group(5))) - if len(match2.group(5)): - list2.append(ord(match2.group(5))) - - for i in range(0, max(len(list1), len(list2))): - if len(list1) <= i: - return -1 - elif len(list2) <= i: - return 1 - elif list1[i] != list2[i]: - return list1[i] - list2[i] - - # main version is equal, so now compare the _suffix part - list1 = match1.group(6).split("_")[1:] - list2 = match2.group(6).split("_")[1:] - - for i in range(0, max(len(list1), len(list2))): - if len(list1) <= i: - s1 = ("p","0") - else: - s1 = suffix_regexp.match(list1[i]).groups() - if len(list2) <= i: - s2 = ("p","0") - else: - s2 = suffix_regexp.match(list2[i]).groups() - if s1[0] != s2[0]: - return suffix_value[s1[0]] - suffix_value[s2[0]] - if s1[1] != s2[1]: - # it's possible that the s(1|2)[1] == '' - # in such a case, fudge it. - try: r1 = int(s1[1]) - except ValueError: r1 = 0 - try: r2 = int(s2[1]) - except ValueError: r2 = 0 - return r1 - r2 - - return cmp(self.revision, other.revision) + # note I chucked out valueerror, none checks on versions passed in. I suck, I know. + # ~harring + return ver_cmp(self.version, self.revision, other.version, other.revision) -class Atom(object): - - """ - Attributes - - bool blocks - str operator - bool glob_match - CPV cpv - - Methods - int __hash__() - str __repr__() - bool match(CPV) - """ - - def __init__(self, atomstr): - if not isinstance(atomstr, str): - raise ValueError(atomstr) - self.__dict__["atomstr"] = atomstr - self.__dict__["hash"] = hash(atomstr) - - def __hash__(self): - return self.hash - - def __repr__(self): - return self.atomstr - - def __setattr__(self, name, value): - raise Exception() - - def __getattr__(self, name): - - if not self.__dict__.has_key("category"): - - myatom = self.atomstr - - if myatom[0] == "!": - self.__dict__["blocks"] = True - myatom = myatom[1:] - else: - self.__dict__["blocks"] = False - - if myatom[0:2] in ["<=", ">="]: - self.__dict__["operator"] = myatom[0:2] - myatom = myatom[2:] - elif myatom[0] in ["<", ">", "=", "~"]: - self.__dict__["operator"] = myatom[0] - myatom = myatom[1:] - else: - self.__dict__["operator"] = None - - if myatom[-1] == "*": - self.__dict__["glob_match"] = True - myatom = myatom[:-1] - else: - self.__dict__["glob_match"] = False - - self.__dict__["cpv"] = CPV(myatom) - - if self.operator != "=" and self.glob_match: - raise ValueError(self.atomstr) - - if self.operator and not self.cpv.version: - raise ValueError(self.atomstr) - - if not self.operator and self.cpv.version: - raise ValueError(self.atomstr) - - if self.operator == "~" and self.cpv.revision: - raise ValueError(self.atomstr) - - if self.glob_match and self.cpv.revision: - raise ValueError(self.atomstr) - - if not self.__dict__.has_key(name): - raise AttributeError(name) - - return self.__dict__[name] - - def match(self, cpv): - - if self.cpv.category and cpv.category and self.cpv.category != cpv.category: - return False - - if self.cpv.package and cpv.package and self.cpv.package != cpv.package: - return False - - if not self.operator: - return True - - if self.operator == "=": - if self.glob_match and cpv.version.startswith(self.cpv.version): - return True - if self.cpv.version != cpv.version: - return False - if self.cpv.revision != cpv.revision: - return False - - if self.operator == "~" and self.cpv.version == cpv.version: - return True - - diff = cmp(self.cpv, cpv) - - if not diff: - if self.operator == "<=" or self.operator == ">=": - return True +def ver_cmp(ver1, rev1, ver2, rev2): + if ver1 == ver2: + return 0 + + match1 = ver_regexp.match(ver1) + match2 = ver_regexp.match(ver2) + + # shortcut for cvs ebuilds (new style) + if match1.group(1) and not match2.group(1): + return 1 + elif match2.group(1) and not match1.group(1): + return -1 + + # building lists of the version parts before the suffix + # first part is simple + list1 = [int(match1.group(2))] + list2 = [int(match2.group(2))] + + # this part would greatly benefit from a fixed-length version pattern + if len(match1.group(3)) or len(match2.group(3)): + vlist1 = match1.group(3)[1:].split(".") + vlist2 = match2.group(3)[1:].split(".") + for i in range(0, max(len(vlist1), len(vlist2))): + if len(vlist1) <= i or len(vlist1[i]) == 0: + list1.append(0) + list2.append(int(vlist2[i])) + elif len(vlist2) <= i or len(vlist2[i]) == 0: + list1.append(int(vlist1[i])) + list2.append(0) + # Let's make life easy and use integers unless we're forced to use floats + elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"): + list1.append(int(vlist1[i])) + list2.append(int(vlist2[i])) + # now we have to use floats so 1.02 compares correctly against 1.1 else: - return False - - if diff > 0: - if self.operator[0] == "<": - return True - else: - return False - - #if diff < 0: - if self.operator[0] == ">": - return True - #else: - return False + list1.append(float("0."+vlist1[i])) + list2.append(float("0."+vlist2[i])) + + # and now the final letter + if len(match1.group(5)): + list1.append(ord(match1.group(5))) + if len(match2.group(5)): + list2.append(ord(match2.group(5))) + + for i in range(0, max(len(list1), len(list2))): + if len(list1) <= i: + return -1 + elif len(list2) <= i: + return 1 + elif list1[i] != list2[i]: + return list1[i] - list2[i] + + # main version is equal, so now compare the _suffix part + list1 = match1.group(6).split("_")[1:] + list2 = match2.group(6).split("_")[1:] + + for i in range(0, max(len(list1), len(list2))): + if len(list1) <= i: + s1 = ("p","0") + else: + s1 = suffix_regexp.match(list1[i]).groups() + if len(list2) <= i: + s2 = ("p","0") + else: + s2 = suffix_regexp.match(list2[i]).groups() + if s1[0] != s2[0]: + return suffix_value[s1[0]] - suffix_value[s2[0]] + if s1[1] != s2[1]: + # it's possible that the s(1|2)[1] == '' + # in such a case, fudge it. + try: r1 = int(s1[1]) + except ValueError: r1 = 0 + try: r2 = int(s2[1]) + except ValueError: r2 = 0 + return r1 - r2 + return cmp(rev1, rev2) diff --git a/portage/package/metadata.py b/portage/package/metadata.py index e4d3ace..14fd4fd 100644 --- a/portage/package/metadata.py +++ b/portage/package/metadata.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/metadata.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/package/metadata.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import weakref from cpv import CPV @@ -10,20 +10,24 @@ class package(CPV): def __init__(self, cpv, parent_repository): super(package,self).__init__(cpv) self.__dict__["_cpv_finalized"] = False - self.__dict__["_finalized"] = False +# self.__dict__["_finalized"] = False self.__dict__["_parent"] = parent_repository + def __setattr__(self, *args, **kwargs): raise AttributeError + def __delattr__(self, *args, **kwargs): raise AttributeError + def __getitem__(self, key): try: return getattr(self,key) except AttributeError: raise KeyError(key) + def __getattr__(self, attr): if not self._cpv_finalized: try: return super(package,self).__getattr__(attr) @@ -31,15 +35,23 @@ class package(CPV): #enable this when CPV does it. #self.__cpv_finalized = True pass - if self._finalized: + + # assuming they're doing super, if it ain't data it's an error (no other jit attr) + if attr != "data": raise AttributeError, attr +# if self._finalized: +# raise AttributeError, attr # if we've made it here, then more is needed. - self._fetch_metadata() - self.__dict__["_finalized"] = True - if attr in self.__dict__: - return self.__dict__[attr] - raise AttributeError,attr + data = self._fetch_metadata() + self.__dict__["data"] = data + return data + +# self.__dict__["_finalized"] = True +# if attr in self.__dict__: +# return self.__dict__[attr] +# raise AttributeError,attr + def _fetch_metadata(self): raise NotImplementedError diff --git a/portage/repository/__init__.py b/portage/repository/__init__.py index 42e0d16..14e25c8 100644 --- a/portage/repository/__init__.py +++ b/portage/repository/__init__.py @@ -1,6 +1,6 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import prototype diff --git a/portage/repository/errors.py b/portage/repository/errors.py index 8a30b71..049095d 100644 --- a/portage/repository/errors.py +++ b/portage/repository/errors.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/errors.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/errors.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class TreeCorruption(Exception): def __init__(self, err): diff --git a/portage/repository/multiplex.py b/portage/repository/multiplex.py index b575ff5..b4c1480 100644 --- a/portage/repository/multiplex.py +++ b/portage/repository/multiplex.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/multiplex.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/multiplex.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import prototype, errors diff --git a/portage/repository/prototype.py b/portage/repository/prototype.py index 26da8c9..ee96483 100644 --- a/portage/repository/prototype.py +++ b/portage/repository/prototype.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/prototype.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/prototype.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ from portage.util.dicts import IndexableSequence from weakref import proxy @@ -11,6 +11,7 @@ def ix_cat_callable(*cat): class tree(object): package_class = None + def __init__(self, frozen=True): self.categories = IndexableSequence(self._get_categories, self._get_categories, returnIterFunc=ix_cat_callable, returnEmpty=True, modifiable=(not frozen)) @@ -21,54 +22,63 @@ class tree(object): self.raw_repo = proxy(self) self.frozen = frozen + def _get_categories(self, *arg): raise NotImplementedError + def _get_packages(self, category): raise NotImplementedError + def _get_versions(self, package): raise NotImplementedError + def __getitem__(self, cpv): - cpv_inst = self.metadata.new_package(cpv) + cpv_inst = self.package_class(cpv) if cpv_inst.fullver not in self.versions[cpv_inst.key]: del cpv_inst raise KeyError(cpv) return cpv_inst + def __setitem__(self, *values): raise AttributeError + def __delitem__(self, cpv): raise AttributeError + def __iter__(self): for cpv in self.versions: - yield self.metadata.new_package(cpv) + yield self.package_class(cpv) return + def match(self, atom): return list(self.itermatch(atom)) + def itermatch(self, atom): - if atom.cpv.category == None: + if atom.category == None: candidates = self.packages else: - if atom.cpv.package == None: - try: candidates = self.packages[atom.cpv.category] + if atom.package == None: + try: candidates = self.packages[atom.category] except KeyError: # just stop now. no category matches == no yielded cpvs. return else: try: - if atom.cpv.package not in self.packages[atom.cpv.category]: + if atom.package not in self.packages[atom.category]: # no matches possible return - candidates = [atom.cpv.key] + candidates = [atom.key] except KeyError: - # atom.cpv.category wasn't valid. no matches possible. + # atom.category wasn't valid. no matches possible. return #actual matching. @@ -84,13 +94,16 @@ class tree(object): raise AttributeError,"repo is frozen" return self._add_new_package(self, pkg) + def _add_new_package(self, pkg): raise NotImplementedError + def del_package(self, key): if self.frozen: raise AttributeError,"repo is frozen" return self._del_package(self,key) + def _del_package(self,pkg): raise NotImplementedError diff --git a/portage/repository/visibility.py b/portage/repository/visibility.py index a1fdc5f..ea4529c 100644 --- a/portage/repository/visibility.py +++ b/portage/repository/visibility.py @@ -1,19 +1,18 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/visibility.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/visibility.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ # icky. # ~harring import prototype, errors -class tree(prototype.tree): - - """wrap an existing repository filtering results based upon passed in restrictions""" +class filterTreee(prototype.tree): + """wrap an existing repository filtering results based upon passed in restrictions.""" def __init__(self, repo, restrictions): self.raw_repo = repo - if not isinstance(raw_repo, prototype.tree): - raise errors.InitializationError("%s is not a repository tree derivative" % str(raw_repo)) + if not isinstance(self.raw_repo, prototype.tree): + raise errors.InitializationError("%s is not a repository tree derivative" % str(self.raw_repo)) if not isinstance(restrictions, list): restrictions = [restrictions] self._restrictions = restrictions @@ -21,5 +20,5 @@ class tree(prototype.tree): def itermatch(self, atom): for cpv in self.raw_repo.itermatch(atom): for r in self._restrictions: - if r.match(cpv): + if not r.match(cpv): yield cpv diff --git a/portage/restrictions/__init__.py b/portage/restrictions/__init__.py index f2569d3..153c87b 100644 --- a/portage/restrictions/__init__.py +++ b/portage/restrictions/__init__.py @@ -1,5 +1,5 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ diff --git a/portage/restrictions/restriction.py b/portage/restrictions/restriction.py index 25ff2ef..7a08083 100644 --- a/portage/restrictions/restriction.py +++ b/portage/restrictions/restriction.py @@ -1,20 +1,19 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/restriction.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/restriction.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ -import re +import re, logging -class Restriction(object): - - def match(self, *arg, **kwargs): - raise NotImplementedError - - -class RestrictionClause(object): +class base(object): """base restriction matching object; overrides setattr to provide the usual write once trickery all derivatives *must* be __slot__ based""" + __slots__ = ["negate"] + + def __init__(self, negate=False): + self.negate = negate + def __setattr__(self, name, value): try: getattr(self, name) @@ -22,20 +21,27 @@ class RestrictionClause(object): object.__setattr__(self, name, value) else: raise AttributeError -class VersionRestriction(RestrictionClause): + def match(self, *arg, **kwargs): + raise NotImplementedError + + +class VersionRestriction(base): + """use this as base for version restrictions, gives a clue to what the restriction does""" pass -class StrMatch(RestrictionClause): +class StrMatch(base): """ Base string matching restriction. all derivatives must be __slot__ based classes""" + __slots__ = base.__slots__ pass class StrRegexMatch(StrMatch): #potentially redesign this to jit the compiled_re object - __slots__ = ("regex", "compiled_re", "flags") + __slots__ = tuple(["regex", "compiled_re", "flags"] + StrMatch.__slots__) - def __init__(self, regex, CaseSensitive=True): + def __init__(self, regex, CaseSensitive=True, **kwds): + super(StrRegexMatch, self).__init__(**kwds) self.regex = regex flags = 0 if not CaseSensitive: @@ -45,13 +51,14 @@ class StrRegexMatch(StrMatch): def match(self, value): - return self.compiled_re.match(str(value)) != None + return (self.compiled_re.match(str(value)) != None) ^ self.negate class StrExactMatch(StrMatch): - __slots__ = ("exact", "flags") + __slots__ = tuple(["exact", "flags"] + StrMatch.__slots__) - def __init__(self, exact, CaseSensitive=True): + def __init__(self, exact, CaseSensitive=True, **kwds): + super(StrExactMatch, self).__init__(**kwds) if not CaseSensitive: self.flags = re.I self.exact = str(exact).lower() @@ -61,57 +68,62 @@ class StrExactMatch(StrMatch): def match(self, value): - if self.flags & re.I: return self.exact == str(value).lower() - else: return self.exact == str(value) + if self.flags & re.I: return (self.exact == str(value).lower()) ^ self.negate + else: return (self.exact == str(value)) ^ self.negate class StrSubstringMatch(StrMatch): - __slots__ = ("substr") + __slots__ = tuple(["substr"] + StrMatch.__slots__) - def __init__(self, substr, CaseSensitive=True): + def __init__(self, substr, CaseSensitive=True, **kwds): + super(StrSubString, self).__init__(**kwds) if not CaseSensitive: self.flags = re.I - substr = str(substr).lower() + self.substr = str(substr).lower() else: self.flags = 0 - substr = str(substr) - self.substr = substr; + self.substr = str(substr) def match(self, value): if self.flags & re.I: value = str(value).lower() else: value = str(value) - return value.find(self.substr) != -1 - - -class PackageDataRestriction(Restriction): - __slots__ = ("metadata_key", "strmatch") - - def __init__(self, metadata_key, StrMatchInstance): - self.metadata_key = metadata_key - self.strmatch = StrMatchInstance - - - def pmatch(self, packageinstance): - try: return self.match(getattr(packageinstance.data, self.metadatakey)) - - except AttributeError: - return False + return (value.find(self.substr) != -1) ^ self.negate +class StrGlobMatch(StrMatch): + __slots__ = tuple(["glob"] + StrMatch.__slots__) + def __init__(self, glob, CaseSensitive=True, **kwds): + super(StrGlobMatch, self).__init__(**kwds) + if not CaseSensitive: + self.flags = re.I + self.glob = str(glob).lower() + else: + self.glags = 0 + self.glob = str(glob) def match(self, value): - return self.strmatch.match(value) + value = str(value) + if self.flags & re.I: value = value.lower() + return value.startswith(self.glob) ^ self.negate +class PackageRestriction(base): + """cpv data restriction. Inherit for anything that's more then cpv mangling please""" - def __setattr__(self, name, value): - try: getattr(self, name) - - except AttributeError: - object.__setattr__(self, name, value) - - else: raise AttributeError + __slots__ = tuple(["attr", "strmatch"] + base.__slots__) + def __init__(self, attr, StrMatchInstance, **kwds): + super(PackageRestriction, self).__init__(**kwds) + self.attr = attr.split(".") + self.strmatch = StrMatchInstance -#cough. yeah. somebody fill thus out please :) -class ConfigRestriction(Restriction): - pass + def match(self, packageinstance): + try: + o = packageinstance + for x in self.attr: + o = getattr(o, x) + return self.strmatch.match(o) ^ self.negate + + except AttributeError,ae: + logging.debug("failed getting attribute %s from %s, exception %s" % \ + (".".join(self.attr), str(packageinstance), str(ae))) + return self.negate diff --git a/portage/restrictions/restrictionSet.py b/portage/restrictions/restrictionSet.py index 0cdf1b9..71c2e3c 100644 --- a/portage/restrictions/restrictionSet.py +++ b/portage/restrictions/restrictionSet.py @@ -1,52 +1,29 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/Attic/restrictionSet.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/restrictions/Attic/restrictionSet.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import restriction -class RestrictionSet(restriction.Restriction): - __slots__ = ("restrictions") +class RestrictionSet(restriction.base): + __slots__ = tuple(["restrictions"] + restriction.base.__slots__) - def __init__(self, initialRestrictions=[]): - for x in initialRestrictions: - if not isinstance(x, Restriction.Restriction): + def __init__(self, *restrictions, **kwds): + super(RestrictionSet, self).__init__(**kwds) + for x in restrictions: + if not isinstance(x, restriction.base): #bad monkey. raise TypeError, x - self.restrictions = list(initialRestrictions) + self.restrictions = restrictions def addRestriction(self, NewRestriction): - if not isinstance(NewRestriction, Restriction.Restriction): + if not isinstance(NewRestriction, restriction.base): raise TypeError, NewRestriction self.restrictions.append(NewRestriction) - def get_tree_restrictions(self): - l = [] - for x in self.restrictions: - if isinstance(x, restriction.RestrictionSet): - l2 = x.get_tree_restrictions() - if len(l2): - l.append(l2) - elif not isinstance(x, restriction.ConfigRestriction): - l.append(x) - return self.__class__(l) - - - def get_conditionals(self): - l = [] - for x in self.restrictions: - if isinstance(x, restriction.RestrictionSet): - l2 = x.get_conditionals() - if len(l2): - l.append(l2) - elif isinstance(x, restriction.ConfigRestriction): - l.append(x) - return self.__class__(l) - - def pmatch(self, packagedataInstance): raise NotImplementedError @@ -60,9 +37,9 @@ class AndRestrictionSet(RestrictionSet): def match(self, packagedataInstance): for rest in self.restrictions: - if not rest.pmatch(packagedataInstance): - return False - return True + if not rest.match(packagedataInstance): + return self.negate + return not self.negate class OrRestrictionSet(RestrictionSet): @@ -70,13 +47,8 @@ class OrRestrictionSet(RestrictionSet): def match(self, packagedataInstance): for rest in self.restrictions: - if rest.pmatch(packagedataInstance): - return True - return False - + if rest.match(packagedataInstance): + return self.negate + return not self.negate -# this may not be used. intended as a way to identify a restrictionSet as specifically identifying a package. -# resolver shouldn't need it anymore -class PackageRestriction(AndRestrictionSet): - pass diff --git a/portage/sync/__init__.py b/portage/sync/__init__.py index 8638d13..157bed3 100644 --- a/portage/sync/__init__.py +++ b/portage/sync/__init__.py @@ -1,7 +1,7 @@ # sync/__init__.py; sync module namespace initialization # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import rsync import cvs diff --git a/portage/sync/cvs.py b/portage/sync/cvs.py index 196f860..7431133 100644 --- a/portage/sync/cvs.py +++ b/portage/sync/cvs.py @@ -1,7 +1,7 @@ # cvs.py; provides cvs sync capabilities, encapsulates the necessary cvs binary calls # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/cvs.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/cvs.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import os, stat from portage.spawn import spawn, spawn_bash, CommandNotFound diff --git a/portage/sync/parseuri.py b/portage/sync/parseuri.py index 06b0a88..4537a82 100644 --- a/portage/sync/parseuri.py +++ b/portage/sync/parseuri.py @@ -1,7 +1,7 @@ # parseuri.py; parses a SYNC uri, returning protocol/host_uri # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/parseuri.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/parseuri.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ #sanitize this to use listdir diff --git a/portage/sync/rsync.py b/portage/sync/rsync.py index 7503c9b..b1b4d56 100644 --- a/portage/sync/rsync.py +++ b/portage/sync/rsync.py @@ -1,7 +1,7 @@ # rsync.py; module providing an abstraction over the rsync binary # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/rsync.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/rsync.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ from portage_const import RSYNC_BIN, RSYNC_HOST import os, portage_exec diff --git a/portage/sync/snapshot.py b/portage/sync/snapshot.py index 02346d0..8934e27 100644 --- a/portage/sync/snapshot.py +++ b/portage/sync/snapshot.py @@ -1,7 +1,7 @@ # snapshot.py; provides the capability of fetching a portage tree snapshot, and syncing a tree with it. # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/snapshot.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/snapshot.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ raise Exception("won't work. portage_checksum clean ups needed") diff --git a/portage/sync/syncexceptions.py b/portage/sync/syncexceptions.py index da7f842..2c679e9 100644 --- a/portage/sync/syncexceptions.py +++ b/portage/sync/syncexceptions.py @@ -1,7 +1,7 @@ # syncexceptions.py: base sync exception class. not used currently (should be though) # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/syncexceptions.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/sync/syncexceptions.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class SyncException(Exception): """base sync exception""" diff --git a/portage/transports/__init__.py b/portage/transports/__init__.py index 037b136..22cac43 100644 --- a/portage/transports/__init__.py +++ b/portage/transports/__init__.py @@ -1,7 +1,7 @@ # transports/__init__.py; worthless file to keep python happy. # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/__init__.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/__init__.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ # worthless comment so diff creates this file. # yay. diff --git a/portage/transports/bundled_lib.py b/portage/transports/bundled_lib.py index 37634fc..04e7544 100644 --- a/portage/transports/bundled_lib.py +++ b/portage/transports/bundled_lib.py @@ -1,7 +1,7 @@ # bundled_lib.py; implementation of a fetcher class useing httplib and ftplib. # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/bundled_lib.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/bundled_lib.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import httplib, ftplib, urlparse, base64, re, sys, os diff --git a/portage/transports/fetchcommand.py b/portage/transports/fetchcommand.py index 5d10eb1..f18249b 100644 --- a/portage/transports/fetchcommand.py +++ b/portage/transports/fetchcommand.py @@ -1,7 +1,7 @@ # fetchcommand.py; fetcher class encapsulating make.conf FETCHCOMMAND/RESUMECOMMAND, and the ensueing spawn calls # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/fetchcommand.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +#$Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/transports/fetchcommand.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ import urlparse,types from portage.exec import spawn_bash diff --git a/portage/util/IndexableSequence.py b/portage/util/IndexableSequence.py index 7ec57cc..d8473ec 100644 --- a/portage/util/IndexableSequence.py +++ b/portage/util/IndexableSequence.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/Attic/IndexableSequence.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/Attic/IndexableSequence.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class IndexableSequence(object): def __init__(self, get_keys, get_values, recursive=False, returnEmpty=False, diff --git a/portage/util/dicts.py b/portage/util/dicts.py index 6283193..f6ca08d 100644 --- a/portage/util/dicts.py +++ b/portage/util/dicts.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/Attic/dicts.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/Attic/dicts.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ class IndexableSequence(object): def __init__(self, get_keys, get_values, recursive=False, returnEmpty=False, diff --git a/portage/util/fs.py b/portage/util/fs.py index e448990..848c73a 100644 --- a/portage/util/fs.py +++ b/portage/util/fs.py @@ -1,7 +1,7 @@ # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/fs.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ -cvs_id_string="$Id: fs.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $"[5:-2] +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/fs.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ +cvs_id_string="$Id: fs.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $"[5:-2] import os diff --git a/portage/util/misc.py b/portage/util/misc.py index 38df0f9..1969e55 100644 --- a/portage/util/misc.py +++ b/portage/util/misc.py @@ -1,7 +1,7 @@ # Copyright 1998-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/misc.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ -cvs_id_string="$Id: misc.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $"[5:-2] +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/misc.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ +cvs_id_string="$Id: misc.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $"[5:-2] #clean this up. import sys,string,shlex,os.path,stat,types diff --git a/portage/util/modules.py b/portage/util/modules.py index b6aad7e..81f5200 100644 --- a/portage/util/modules.py +++ b/portage/util/modules.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/modules.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/util/modules.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ def load_module(name): m = __import__(name) diff --git a/portage/vdb/repository.py b/portage/vdb/repository.py index 5e20702..2b1803e 100644 --- a/portage/vdb/repository.py +++ b/portage/vdb/repository.py @@ -1,7 +1,7 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/vdb/repository.py,v 1.1 2005/07/10 09:21:05 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/vdb/repository.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $ # hack, remove when it's fixed raise Exception("sorry, this won't work with current portage namespace layout. plsfix, kthnx") |