From 24c616a42162793e6bdcda5544a2955a27c4821e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 22 Feb 2009 04:47:25 +0000 Subject: Use lazyimport to avoid importing the checksum, locks, and util modules when portage is initially imported. svn path=/main/trunk/; revision=12680 --- pym/portage/__init__.py | 6 ++++-- pym/portage/data.py | 9 +++++++-- pym/portage/dbapi/__init__.py | 11 ++++++++--- pym/portage/dbapi/bintree.py | 10 ++++++---- pym/portage/dbapi/porttree.py | 11 +++++++---- pym/portage/dbapi/vartree.py | 16 ++++++++++------ pym/portage/elog/__init__.py | 9 ++++++--- pym/portage/elog/messages.py | 8 ++++++-- pym/portage/manifest.py | 10 +++++++--- pym/portage/output.py | 9 +++++++-- pym/portage/process.py | 8 ++++++-- pym/portage/update.py | 10 +++++++--- 12 files changed, 81 insertions(+), 36 deletions(-) (limited to 'pym') diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index b33330228..7b7c50b2a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1,5 +1,5 @@ # portage.py -- core Portage functionality -# Copyright 1998-2004 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -609,7 +609,9 @@ class digraph(object): #parse /etc/env.d and generate /etc/profile.env def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, - env=None, writemsg_level=portage.util.writemsg_level): + env=None, writemsg_level=None): + if writemsg_level is None: + writemsg_level = portage.util.writemsg_level if target_root is None: global settings target_root = settings["ROOT"] diff --git a/pym/portage/data.py b/pym/portage/data.py index a7ebd9cb3..a8ddf8250 100644 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@ -1,10 +1,15 @@ # data.py -- Calculated/Discovered Data Values -# Copyright 1998-2004 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ import os, sys, pwd, grp, platform -from portage.util import writemsg + +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:writemsg', +) + from portage.output import colorize from portage.output import create_color_func bad = create_color_func("BAD") diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index dae7ad014..2f2c2c8ab 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -1,4 +1,4 @@ -# Copyright 1998-2007 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -6,10 +6,15 @@ __all__ = ["dbapi"] import os import re + +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.locks:unlockfile', + 'portage.util:cmp_sort_key,writemsg', +) + from portage.dep import match_from_list -from portage.locks import unlockfile from portage.output import colorize -from portage.util import writemsg, cmp_sort_key from portage import auxdbkeys, dep_expand from portage.versions import catpkgsplit, pkgcmp diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 1d2c17ab8..1ccd6babf 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -1,23 +1,25 @@ -# Copyright 1998-2007 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ __all__ = ["bindbapi", "binarytree"] +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:ensure_dirs,normalize_path,writemsg,writemsg_stdout', +) + from portage.cache.mappings import slot_dict_class from portage.dep import isvalidatom, isjustname, dep_getkey, match_from_list from portage.dbapi.virtual import fakedbapi from portage.exception import InvalidPackageName, \ PermissionDenied, PortageException from portage.output import EOutput, colorize -from portage.util import ensure_dirs, normalize_path, writemsg, writemsg_stdout from portage.versions import best, catpkgsplit, catsplit from portage.update import update_dbentries from portage import dep_expand, listdir, _check_distfile, _movefile -import portage - import os, errno, stat import re from itertools import chain, izip diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index d342c22d9..bd831551f 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -1,9 +1,15 @@ -# Copyright 1998-2007 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ __all__ = ["portdbapi", "close_portdbapi_caches", "portagetree"] +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.checksum', + 'portage.util:ensure_dirs,writemsg', +) + from portage.cache.cache_errors import CacheError from portage.cache.mappings import slot_dict_class from portage.const import REPO_NAME_LOC @@ -13,11 +19,8 @@ from portage.dep import use_reduce, paren_reduce, dep_getkey, match_from_list from portage.exception import PortageException, \ FileNotFound, InvalidDependString, InvalidPackageName from portage.manifest import Manifest -from portage.util import ensure_dirs, writemsg from portage.versions import pkgsplit, catpkgsplit, best, ver_regexp -import portage.checksum - from portage import eclass_cache, auxdbkeys, doebuild, flatten, \ listdir, dep_expand, eapi_is_supported, key_expand, dep_check, \ _eapi_is_deprecated diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index cfabad844..4761057ae 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1,4 +1,4 @@ -# Copyright 1998-2007 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -6,7 +6,15 @@ __all__ = ["PreservedLibsRegistry", "LinkageMap", "vardbapi", "vartree", "dblink"] + \ ["write_contents", "tar_contents"] -from portage.checksum import perform_md5 +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.checksum:perform_md5', + 'portage.locks:lockdir,unlockdir', + 'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \ + 'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \ + 'grabfile,grabdict,normalize_path,new_protect_filename,getlibpaths' +) + from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \ PORTAGE_PACKAGE_ATOM, PRIVATE_PATH, VDB_PATH from portage.data import portage_gid, portage_uid, secpass @@ -16,12 +24,8 @@ from portage.dep import use_reduce, paren_reduce, isvalidatom, \ from portage.exception import CommandNotFound, \ InvalidData, InvalidPackageName, \ FileNotFound, PermissionDenied, UnsupportedAPIException -from portage.locks import lockdir, unlockdir from portage.output import bold, colorize from portage.update import fixdbentries -from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs, \ - writemsg, writemsg_level, write_atomic, atomic_ofstream, writedict, \ - grabfile, grabdict, normalize_path, new_protect_filename, getlibpaths from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp from portage import listdir, dep_expand, digraph, flatten, key_expand, \ diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py index ad5cc873c..5e8b11c8b 100644 --- a/pym/portage/elog/__init__.py +++ b/pym/portage/elog/__init__.py @@ -1,13 +1,16 @@ # elog/__init__.py - elog core functions -# Copyright 2006-2007 Gentoo Foundation +# Copyright 2006-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:writemsg', +) + from portage.const import EBUILD_PHASES from portage.exception import PortageException from portage.process import atexit_register -from portage.util import writemsg - from portage.elog.messages import collect_ebuild_messages, collect_messages from portage.elog.filtering import filter_loglevels diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index a09b73229..f171f2956 100644 --- a/pym/portage/elog/messages.py +++ b/pym/portage/elog/messages.py @@ -1,11 +1,15 @@ # elog/messages.py - elog core functions -# Copyright 2006-2007 Gentoo Foundation +# Copyright 2006-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:writemsg', +) + from portage.output import colorize from portage.const import EBUILD_PHASES -from portage.util import writemsg import os import sys diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 9329c889b..9d2bd216d 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -1,13 +1,17 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ import errno, os +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.checksum:hashfunc_map,perform_multiple_checksums,verify_all', + 'portage.util:write_atomic', +) + import portage.versions, portage.const -from portage.checksum import * from portage.exception import * -from portage.util import write_atomic class FileNotInManifestException(PortageException): pass diff --git a/pym/portage/output.py b/pym/portage/output.py index 1f0eec988..eaca066f4 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -1,4 +1,4 @@ -# Copyright 1998-2004 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -11,8 +11,13 @@ import os import re import shlex import sys + +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:writemsg', +) + from portage.const import COLOR_MAP_FILE -from portage.util import writemsg from portage.exception import CommandNotFound, FileNotFound, \ ParseError, PermissionDenied, PortageException diff --git a/pym/portage/process.py b/pym/portage/process.py index 3bc6bd1a8..7c0fb342f 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -1,5 +1,5 @@ # portage.py -- core Portage functionality -# Copyright 1998-2004 Gentoo Foundation +# Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -9,7 +9,11 @@ import atexit import signal import sys -from portage.util import dump_traceback +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:dump_traceback', +) + from portage.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY from portage.exception import CommandNotFound diff --git a/pym/portage/update.py b/pym/portage/update.py index 85d07f5a3..476806d6b 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -1,11 +1,15 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ import errno, os, re, sys -from portage.util import ConfigProtect, grabfile, new_protect_filename, \ - normalize_path, write_atomic, writemsg +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:ConfigProtect,grabfile,new_protect_filename,' + \ + 'normalize_path,write_atomic,writemsg', +) + from portage.exception import DirectoryNotFound, PortageException from portage.versions import ververify from portage.dep import dep_getkey, get_operator, isvalidatom, isjustname, \ -- cgit v1.2.3-1-g7c22