From: Zac Medico Date: Sun, 22 Feb 2009 05:23:34 +0000 (-0000) Subject: Use lazyimport to avoid importing the dep, output, update, and versions X-Git-Tag: v2.2_rc24~132 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=27eb5504f6886038d9d427385411715cd0b96d9c;p=portage.git Use lazyimport to avoid importing the dep, output, update, and versions modules when portage is initially imported. svn path=/main/trunk/; revision=12681 --- diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 7b7c50b2a..56a8c4f21 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -102,6 +102,7 @@ try: 'pickle_read,pickle_write,stack_dictlist,stack_dicts,' + \ 'stack_lists,unique_array,varexpand,writedict,writemsg,' + \ 'writemsg_stdout,write_atomic', + 'portage.versions', 'portage.versions:best,catpkgsplit,catsplit,endversion_keys,' + \ 'suffix_value@endversion,pkgcmp,pkgsplit,vercmp,ververify', 'portage.xpak', diff --git a/pym/portage/data.py b/pym/portage/data.py index a8ddf8250..3ae286b34 100644 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@ -7,13 +7,10 @@ import os, sys, pwd, grp, platform import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.output:colorize', 'portage.util:writemsg', ) -from portage.output import colorize -from portage.output import create_color_func -bad = create_color_func("BAD") - ostype=platform.system() userland = None if ostype == "DragonFly" or ostype.endswith("BSD"): @@ -39,7 +36,7 @@ if not lchown: lchown() def portage_group_warning(): - warn_prefix = bad("*** WARNING *** ") + warn_prefix = colorize("BAD", "*** WARNING *** ") mylines = [ "For security reasons, only system administrators should be", "allowed in the portage group. Untrusted users or processes", diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index 2f2c2c8ab..6bea1e5d3 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -9,15 +9,14 @@ import re import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.dep:match_from_list', 'portage.locks:unlockfile', + 'portage.output:colorize', 'portage.util:cmp_sort_key,writemsg', + 'portage.versions:catpkgsplit,pkgcmp', ) -from portage.dep import match_from_list -from portage.output import colorize from portage import auxdbkeys, dep_expand -from portage.versions import catpkgsplit, pkgcmp - class dbapi(object): _category_re = re.compile(r'^\w[-.+\w]*$') diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 1ccd6babf..40886a55b 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -6,17 +6,17 @@ __all__ = ["bindbapi", "binarytree"] import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list', + 'portage.output:EOutput,colorize', + 'portage.update:update_dbentries', 'portage.util:ensure_dirs,normalize_path,writemsg,writemsg_stdout', + 'portage.versions:best,catpkgsplit,catsplit', ) 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.versions import best, catpkgsplit, catsplit -from portage.update import update_dbentries from portage import dep_expand, listdir, _check_distfile, _movefile diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index bd831551f..ab5e9ba13 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -7,7 +7,9 @@ __all__ = ["portdbapi", "close_portdbapi_caches", "portagetree"] import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.checksum', + 'portage.dep:dep_getkey,match_from_list,paren_reduce,use_reduce', 'portage.util:ensure_dirs,writemsg', + 'portage.versions:best,catpkgsplit,pkgsplit,ver_regexp', ) from portage.cache.cache_errors import CacheError @@ -15,11 +17,9 @@ from portage.cache.mappings import slot_dict_class from portage.const import REPO_NAME_LOC from portage.data import portage_gid, secpass from portage.dbapi import dbapi -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.versions import pkgsplit, catpkgsplit, best, ver_regexp from portage import eclass_cache, auxdbkeys, doebuild, flatten, \ listdir, dep_expand, eapi_is_supported, key_expand, dep_check, \ diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 4761057ae..0b45f28d6 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -9,24 +9,24 @@ __all__ = ["PreservedLibsRegistry", "LinkageMap", import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.checksum:perform_md5', + 'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list,' + \ + 'use_reduce,paren_reduce', 'portage.locks:lockdir,unlockdir', + 'portage.output:bold,colorize', + 'portage.update:fixdbentries', 'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \ 'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \ - 'grabfile,grabdict,normalize_path,new_protect_filename,getlibpaths' + 'grabfile,grabdict,normalize_path,new_protect_filename,getlibpaths', + 'portage.versions:best,catpkgsplit,catsplit,pkgcmp,pkgsplit', ) 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 from portage.dbapi import dbapi -from portage.dep import use_reduce, paren_reduce, isvalidatom, \ - isjustname, dep_getkey, match_from_list from portage.exception import CommandNotFound, \ InvalidData, InvalidPackageName, \ FileNotFound, PermissionDenied, UnsupportedAPIException -from portage.output import bold, colorize -from portage.update import fixdbentries -from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp from portage import listdir, dep_expand, digraph, flatten, key_expand, \ doebuild_environment, doebuild, env_update, prepare_build_dirs, \ diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index f171f2956..4fa73ba5f 100644 --- a/pym/portage/elog/messages.py +++ b/pym/portage/elog/messages.py @@ -5,10 +5,10 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.output:colorize', 'portage.util:writemsg', ) -from portage.output import colorize from portage.const import EBUILD_PHASES import os diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 9d2bd216d..1244e4232 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -10,7 +10,6 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.util:write_atomic', ) -import portage.versions, portage.const from portage.exception import * class FileNotInManifestException(PortageException): diff --git a/pym/portage/update.py b/pym/portage/update.py index 476806d6b..fffdc26eb 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -6,14 +6,13 @@ import errno, os, re, sys import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.dep:dep_getkey,get_operator,isvalidatom,isjustname,remove_slot', 'portage.util:ConfigProtect,grabfile,new_protect_filename,' + \ 'normalize_path,write_atomic,writemsg', + 'portage.versions:ververify' ) from portage.exception import DirectoryNotFound, PortageException -from portage.versions import ververify -from portage.dep import dep_getkey, get_operator, isvalidatom, isjustname, \ - remove_slot from portage.const import USER_CONFIG_PATH, WORLD_FILE ignored_dbentries = ("CONTENTS", "environment.bz2")