From cbbab21dfdd9bee79cddaaac12d7ea5890674d81 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 3 Jan 2013 15:04:40 -0800 Subject: Add portage._internal_caller var, and use it. --- bin/archive-conf | 3 ++- bin/binhost-snapshot | 3 ++- bin/clean_locks | 3 ++- bin/dispatch-conf | 3 ++- bin/ebuild | 4 ++-- bin/ebuild-ipc.py | 3 ++- bin/egencache | 3 ++- bin/emaint | 3 ++- bin/emerge | 5 ++++- bin/env-update | 3 ++- bin/fixpackages | 3 ++- bin/glsa-check | 3 ++- bin/lock-helper.py | 3 ++- bin/portageq | 3 ++- bin/quickpkg | 3 ++- bin/regenworld | 3 ++- bin/repoman | 4 ++-- bin/xpak-helper.py | 3 ++- pym/_emerge/main.py | 4 +--- pym/portage/__init__.py | 4 ++-- pym/portage/dbapi/porttree.py | 4 ++-- pym/portage/dep/__init__.py | 12 ++++++------ 22 files changed, 49 insertions(+), 33 deletions(-) diff --git a/bin/archive-conf b/bin/archive-conf index 80fa308a1..2c10884ea 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -17,6 +17,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage import dispatch_conf diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot index fe2cf6b53..e9bd45a2f 100755 --- a/bin/binhost-snapshot +++ b/bin/binhost-snapshot @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2010-2012 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import io @@ -17,6 +17,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True def parse_args(argv): prog_name = os.path.basename(argv[0]) diff --git a/bin/clean_locks b/bin/clean_locks index 09ee3e516..0a9791852 100755 --- a/bin/clean_locks +++ b/bin/clean_locks @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -9,6 +9,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 479647ede..e44c0eac8 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -20,6 +20,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage import dispatch_conf from portage import _unicode_decode diff --git a/bin/ebuild b/bin/ebuild index 36580bf3f..754b9a9bd 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -68,7 +68,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage -portage._internal_warnings = True +portage._internal_caller = True from portage import os from portage import _encodings from portage import _shell_quote diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py index 3caf2d185..52ea05ced 100755 --- a/bin/ebuild-ipc.py +++ b/bin/ebuild-ipc.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2010-2012 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # # This is a helper which ebuild processes can use @@ -38,6 +38,7 @@ if os.environ.get("SANDBOX_ON") == "1": ":".join(filter(None, sandbox_write)) import portage +portage._internal_caller = True portage._disable_legacy_globals() class EbuildIpc(object): diff --git a/bin/egencache b/bin/egencache index 110c47dcd..87673a0a0 100755 --- a/bin/egencache +++ b/bin/egencache @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2009-2012 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -44,6 +44,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os, _encodings, _unicode_encode, _unicode_decode from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision diff --git a/bin/emaint b/bin/emaint index fd9f346b2..bc1b92f22 100755 --- a/bin/emaint +++ b/bin/emaint @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 2005-2012 Gentoo Foundation +# Copyright 2005-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 """'The emaint program provides an interface to system health @@ -30,6 +30,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage.emaint.main import emaint_main try: diff --git a/bin/emerge b/bin/emerge index b749b0a8e..fc85d584e 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2006-2012 Gentoo Foundation +# Copyright 2006-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -39,6 +39,9 @@ try: pym_path = osp.join(osp.dirname(osp.dirname( osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) + import portage + portage._internal_caller = True + portage._disable_legacy_globals() from _emerge.main import emerge_main if __name__ == "__main__": diff --git a/bin/env-update b/bin/env-update index cee3fd683..b500c545c 100755 --- a/bin/env-update +++ b/bin/env-update @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -29,6 +29,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True try: portage.env_update(makelinks) diff --git a/bin/fixpackages b/bin/fixpackages index da08520e5..e224b62c2 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -11,6 +11,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage.output import EOutput from textwrap import wrap diff --git a/bin/glsa-check b/bin/glsa-check index b3eb14689..ed0df3586 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2008-2012 Gentoo Foundation +# Copyright 2008-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -10,6 +10,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage.output import * diff --git a/bin/lock-helper.py b/bin/lock-helper.py index dfb887669..128e4ddd0 100755 --- a/bin/lock-helper.py +++ b/bin/lock-helper.py @@ -1,11 +1,12 @@ #!/usr/bin/python -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import os import sys sys.path.insert(0, os.environ['PORTAGE_PYM_PATH']) import portage +portage._internal_caller = True portage._disable_legacy_globals() def main(args): diff --git a/bin/portageq b/bin/portageq index 7b5c2cd31..ee776ef4f 100755 --- a/bin/portageq +++ b/bin/portageq @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -36,6 +36,7 @@ if os.environ.get("SANDBOX_ON") == "1": sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage.eapi import eapi_has_repo_deps from portage.util import writemsg, writemsg_stdout diff --git a/bin/quickpkg b/bin/quickpkg index a6439e282..19d90b0d3 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -15,6 +15,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage import xpak from portage.dbapi.dep_expand import dep_expand diff --git a/bin/regenworld b/bin/regenworld index a2833445a..f74b3dde0 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -9,6 +9,7 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True from portage import os from portage._sets.files import StaticFileSet, WorldSelectedSet diff --git a/bin/repoman b/bin/repoman index 57ddf72fe..4c00d5bca 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # Next to do: dep syntax checking in mask files @@ -38,8 +38,8 @@ from os import path as osp pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") sys.path.insert(0, pym_path) import portage +portage._internal_caller = True portage._disable_legacy_globals() -portage._internal_warnings = True try: import xml.etree.ElementTree diff --git a/bin/xpak-helper.py b/bin/xpak-helper.py index ef74920db..7a3865c10 100755 --- a/bin/xpak-helper.py +++ b/bin/xpak-helper.py @@ -1,10 +1,11 @@ #!/usr/bin/python -# Copyright 2009-2011 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import optparse import sys import portage +portage._internal_caller = True from portage import os def command_recompose(args): diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 96d6a1600..c0e2d9643 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1,4 +1,4 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -999,8 +999,6 @@ def emerge_main(args=None): if args is None: args = sys.argv[1:] - portage._disable_legacy_globals() - portage._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/__init__.py b/pym/portage/__init__.py index 96a4fa98c..169c19783 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1,5 +1,5 @@ # portage.py -- core Portage functionality -# Copyright 1998-2012 Gentoo Foundation +# Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 VERSION="HEAD" @@ -335,7 +335,7 @@ _bin_path = PORTAGE_BIN_PATH _pym_path = PORTAGE_PYM_PATH # Api consumers included in portage should set this to True. -_internal_warnings = False +_internal_caller = False _sync_disabled_warnings = False diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index ebb1be87a..d8cd261b4 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -1,4 +1,4 @@ -# Copyright 1998-2012 Gentoo Foundation +# Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = [ @@ -197,7 +197,7 @@ class portdbapi(dbapi): @property def _event_loop(self): - if portage._internal_warnings: + if portage._internal_caller: # For internal portage usage, the global_event_loop is safe. return global_event_loop() else: diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index 634b42bb5..916d5ea66 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -1,5 +1,5 @@ # deps.py -- Portage dependency resolution functions -# Copyright 2003-2012 Gentoo Foundation +# Copyright 2003-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = [ @@ -269,7 +269,7 @@ def paren_reduce(mystr): @rtype: Array @return: The reduced string in an array """ - if portage._internal_warnings: + if portage._internal_caller: warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ ('portage.dep.paren_reduce',), DeprecationWarning, stacklevel=2) mysplit = mystr.split() @@ -361,7 +361,7 @@ 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): - if portage._internal_warnings: + if portage._internal_caller: warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ ('portage.dep.paren_normalize',), DeprecationWarning, stacklevel=2) list.__init__(self) @@ -457,7 +457,7 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i @return: The use reduced depend array """ if isinstance(depstr, list): - if portage._internal_warnings: + if portage._internal_caller: warnings.warn(_("Passing paren_reduced dep arrays to %s is deprecated. " + \ "Pass the original dep string instead.") % \ ('portage.dep.use_reduce',), DeprecationWarning, stacklevel=2) @@ -758,7 +758,7 @@ def dep_opconvert(deplist): @return: The new list with the new ordering """ - if portage._internal_warnings: + if portage._internal_caller: 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) @@ -789,7 +789,7 @@ def flatten(mylist): @rtype: List @return: A single list containing only non-list elements. """ - if portage._internal_warnings: + if portage._internal_caller: warnings.warn(_("%s is deprecated and will be removed without replacement.") % \ ('portage.dep.flatten',), DeprecationWarning, stacklevel=2) -- cgit v1.2.3-1-g7c22