From daa712622ddf9b909f208952e8d594e5fd4525b0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 17 Aug 2010 13:22:35 -0700 Subject: Temporarily disable portage.dep deprecation warnings for external api consumers. Once the relevant api changes are in a portage release with stable keywords, make these warnings unconditional. --- pym/_emerge/main.py | 1 + pym/portage/dep/__init__.py | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'pym') diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index f8a8f22e4..c8a6ee4bf 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1241,6 +1241,7 @@ def check_procfs(): def emerge_main(): global portage # NFC why this is necessary now - genone portage._disable_legacy_globals() + portage.dep._internal_warnings = True # Disable color until we're sure that it should be enabled (after # EMERGE_DEFAULT_OPTS has been parsed). portage.output.havecolor = 0 diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index a16697835..84cc57526 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -39,6 +39,11 @@ import portage.cache.mappings if sys.hexversion >= 0x3000000: basestring = str +# Api consumers included in portage should set this to True. +# Once the relevant api changes are in a portage release with +# stable keywords, make these warnings unconditional. +_internal_warnings = False + def cpvequal(cpv1, cpv2): """ @@ -97,8 +102,9 @@ def paren_reduce(mystr): @rtype: Array @return: The reduced string in an array """ - warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ - ('portage.dep.paren_reduce',), DeprecationWarning, stacklevel=2) + if _internal_warnings: + warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ + ('portage.dep.paren_reduce',), DeprecationWarning, stacklevel=2) mysplit = mystr.split() level = 0 stack = [[]] @@ -164,8 +170,9 @@ class paren_normalize(list): """Take a dependency structure as returned by paren_reduce or use_reduce and generate an equivalent structure that has no redundant lists.""" def __init__(self, src): - warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ - ('portage.dep.paren_normalize',), DeprecationWarning, stacklevel=2) + if _internal_warnings: + warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ + ('portage.dep.paren_normalize',), DeprecationWarning, stacklevel=2) list.__init__(self) self._zap_parens(src, self) @@ -252,9 +259,10 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i @return: The use reduced depend array """ if isinstance(depstr, list): - warnings.warn(_("Passing paren_reduced dep arrays to %s is deprecated. " + \ - "Pass the original dep string instead.") % \ - ('portage.dep.use_reduce',), DeprecationWarning, stacklevel=2) + if _internal_warnings: + warnings.warn(_("Passing paren_reduced dep arrays to %s is deprecated. " + \ + "Pass the original dep string instead.") % \ + ('portage.dep.use_reduce',), DeprecationWarning, stacklevel=2) depstr = paren_enclose(depstr) if opconvert and flat: @@ -464,8 +472,9 @@ def dep_opconvert(deplist): @return: The new list with the new ordering """ - warnings.warn(_("%s is deprecated. Use %s with the opconvert parameter set to True instead.") % \ - ('portage.dep.dep_opconvert', 'portage.dep.use_reduce'), DeprecationWarning, stacklevel=2) + if _internal_warnings: + warnings.warn(_("%s is deprecated. Use %s with the opconvert parameter set to True instead.") % \ + ('portage.dep.dep_opconvert', 'portage.dep.use_reduce'), DeprecationWarning, stacklevel=2) retlist = [] x = 0 @@ -494,8 +503,9 @@ def flatten(mylist): @rtype: List @return: A single list containing only non-list elements. """ - warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ - ('portage.dep.flatten',), DeprecationWarning, stacklevel=2) + if _internal_warnings: + warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ + ('portage.dep.flatten',), DeprecationWarning, stacklevel=2) newlist = [] for x in mylist: -- cgit v1.2.3-1-g7c22