From 07fbd0a29455f2e74c66b37f30c62a7ddb0c5571 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 10 Jun 2012 16:05:21 -0700 Subject: [PATCH] _get_eapi_attrs: move to eapi module --- pym/portage/dep/__init__.py | 33 +-------------------------------- pym/portage/eapi.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index d985486e1..6c2a3addd 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -27,7 +27,6 @@ __all__ = [ # "a? ( b? ( z ) ) -- Valid # -import collections import re, sys import warnings from itertools import chain @@ -38,9 +37,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage import _unicode_decode -from portage.eapi import eapi_has_slot_deps, eapi_has_src_uri_arrows, \ - eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_use_dep_defaults, \ - eapi_has_repo_deps, eapi_allows_dots_in_PN, eapi_allows_dots_in_use_flags +from portage.eapi import eapi_has_src_uri_arrows, _get_eapi_attrs from portage.exception import InvalidAtom, InvalidData, InvalidDependString from portage.localization import _ from portage.versions import catpkgsplit, catsplit, \ @@ -72,34 +69,6 @@ _repo = r'(?:' + _repo_separator + '(' + _repo_name + ')' + ')?' _extended_cat = r'[\w+*][\w+.*-]*' -_eapi_attrs = collections.namedtuple('_eapi_attrs', - 'dots_in_PN dots_in_use_flags repo_deps slot_deps ' - 'strong_blocks use_deps use_dep_defaults') - -_eapi_attrs_cache = {} - -def _get_eapi_attrs(eapi): - """ - When eapi is None then validation is not as strict, since we want the - same to work for multiple EAPIs that may have slightly different rules. - """ - eapi_attrs = _eapi_attrs_cache.get(eapi) - if eapi_attrs is not None: - return eapi_attrs - - eapi_attrs = _eapi_attrs( - dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)), - dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)), - repo_deps = (eapi is None or eapi_has_repo_deps(eapi)), - slot_deps = (eapi is None or eapi_has_slot_deps(eapi)), - strong_blocks = (eapi is None or eapi_has_strong_blocks(eapi)), - use_deps = (eapi is None or eapi_has_use_deps(eapi)), - use_dep_defaults = (eapi is None or eapi_has_use_dep_defaults(eapi)) - ) - - _eapi_attrs_cache[eapi] = eapi_attrs - return eapi_attrs - _atom_re_cache = {} def _get_atom_re(eapi_attrs): diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py index 79cf89118..4dd02db02 100644 --- a/pym/portage/eapi.py +++ b/pym/portage/eapi.py @@ -1,6 +1,8 @@ # Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import collections + def eapi_has_iuse_defaults(eapi): return eapi != "0" @@ -60,3 +62,31 @@ def eapi_allows_dots_in_PN(eapi): def eapi_allows_dots_in_use_flags(eapi): return eapi in ("4-python",) + +_eapi_attrs = collections.namedtuple('_eapi_attrs', + 'dots_in_PN dots_in_use_flags repo_deps slot_deps ' + 'strong_blocks use_deps use_dep_defaults') + +_eapi_attrs_cache = {} + +def _get_eapi_attrs(eapi): + """ + When eapi is None then validation is not as strict, since we want the + same to work for multiple EAPIs that may have slightly different rules. + """ + eapi_attrs = _eapi_attrs_cache.get(eapi) + if eapi_attrs is not None: + return eapi_attrs + + eapi_attrs = _eapi_attrs( + dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)), + dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)), + repo_deps = (eapi is None or eapi_has_repo_deps(eapi)), + slot_deps = (eapi is None or eapi_has_slot_deps(eapi)), + strong_blocks = (eapi is None or eapi_has_strong_blocks(eapi)), + use_deps = (eapi is None or eapi_has_use_deps(eapi)), + use_dep_defaults = (eapi is None or eapi_has_use_dep_defaults(eapi)) + ) + + _eapi_attrs_cache[eapi] = eapi_attrs + return eapi_attrs -- 2.26.2