本文整理汇总了Python中snakeoil.demandload.demandload函数的典型用法代码示例。如果您正苦于以下问题:Python demandload函数的具体用法?Python demandload怎么用?Python demandload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了demandload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_demandload
def test_demandload(self):
scope = {}
demandload.demandload(scope, 'snakeoil:demandload')
self.assertNotIdentical(demandload, scope['demandload'])
self.assertIdentical(
demandload.demandload, scope['demandload'].demandload)
self.assertIdentical(demandload, scope['demandload'])
示例2: demandload
# Rationale is the former should be a PYTHONPATH issue while the
# latter an installed plugin issue. May have to change this if it
# causes problems.
from collections import defaultdict
from importlib import import_module
import operator
import os.path
from snakeoil import compatibility, mappings, modules, sequences
from snakeoil.demandload import demandload
from snakeoil.osutils import pjoin, listdir_files
from pkgcore import plugins
demandload("errno", "tempfile", "snakeoil:fileutils,osutils", "pkgcore.log:logger")
_plugin_data = sequences.namedtuple("_plugin_data", ["key", "priority", "source", "target"])
PLUGIN_ATTR = "pkgcore_plugins"
CACHE_HEADER = "pkgcore plugin cache v3"
CACHE_FILENAME = "plugincache"
def _clean_old_caches(path):
for name in ("plugincache2",):
try:
osutils.unlink_if_exists(pjoin(path, name))
except EnvironmentError as e:
示例3: demandload
from copy import deepcopy
from operator import attrgetter
from urllib.parse import urlencode
from snakeoil.demandload import demandload
from . import Cli
demandload('bite:const')
class Monorail(Cli):
"""CLI for Monorail service."""
_service = 'monorail'
def _search_params(self, **kw):
query = {}
query_list = []
options_log = []
for k, v in ((k, v) for (k, v) in kw.items() if v):
if k == 'query':
query_list.append(v)
options_log.append(' advanced query: {}'.format(v))
if k == 'attachment':
query_list.append('attachment:{}'.format(v))
options_log.append(' attachment: {}'.format(v))
if k == 'blocked':
query_list.append('is:blocked')
options_log.append(' blocked: yes')
示例4: demandload
"describe_class", "describe_class_main",
"configurables", "configurables_main",
"dump_uncollapsed", "dump_uncollapsed_main"
)
from functools import partial
from snakeoil.demandload import demandload
from pkgcore.config import errors, basics
from pkgcore.ebuild import atom
from pkgcore.plugin import get_plugins
from pkgcore.util import commandline
demandload(
'textwrap',
'traceback',
)
def dump_section(config, out):
out.first_prefix.append(' ')
out.write('# typename of this section: %s' % (config.type.name,))
out.write('class %s.%s;' % (config.type.callable.__module__,
config.type.callable.__name__))
if config.default:
out.write('default true;')
for key, val in sorted(config.config.iteritems()):
typename = config.type.types.get(key)
if typename is None:
if config.type.allow_unknowns:
typename = 'str'
示例5: demandload
from collections import OrderedDict
from itertools import chain
import re
import subprocess
import sys
from snakeoil.demandload import demandload
from snakeoil.strings import pluralism
from . import Cli, login_required
from ..exceptions import BiteError
from ..utils import block_edit, get_input, launch_browser
demandload(
'pprint',
'urllib.parse:parse_qs',
'bite:const',
)
class Bugzilla(Cli):
"""CLI for Bugzilla service."""
_service = 'bugzilla'
def attach(self, *args, **kw):
if kw['comment'] is None:
kw['comment'] = block_edit('Enter optional long description of attachment')
super().attach(*args, **kw)
def create(self, *args, **kw):
示例6: fetch_base
"uninstall",
"replace",
"fetch_base",
"empty_build_op",
"FailedDirectory",
"GenericBuildError",
"errors",
)
from pkgcore import operations as _operations_mod
from snakeoil.dependant_methods import ForcedDepends
from snakeoil import klass
from snakeoil import demandload
demandload.demandload(globals(), "pkgcore:[email protected]_fetch_module", "snakeoil.lists:iflatten_instance")
class fetch_base(object):
def __init__(self, domain, pkg, fetchables, fetcher):
self.verified_files = {}
self._basenames = set()
self.domain = domain
self.pkg = pkg
self.fetchables = fetchables
self.fetcher = fetcher
def fetch_all(self, observer):
for fetchable in self.fetchables:
if not self.fetch_one(fetchable, observer):
return False
示例7: demandload
# Copyright: 2011-2012 Brian Harring <[email protected]>
# License: GPL2/BSD 3 clause
import os
import sys
from snakeoil.demandload import demandload
demandload(
globals(),
'subprocess',
'snakeoil.osutils:access',
'snakeoil.fileutils:readlines_ascii',
)
def _parse_cpuinfo():
data = readlines_ascii("/proc/cpuinfo", True, True, False)
procs = []
current = []
for line in data:
if not line:
if current:
procs.append(current)
current = []
else:
current.append(line.split(":", 1))
return [{k.strip(): v.strip() for k, v in items} for items in procs]
def _get_linux_physical_proc_count():
procs = _parse_cpuinfo()
if not procs:
return _get_linux_proc_count()
示例8: demandload
import os
import signal
from pkgcore import const, os_data
from pkgcore.ebuild import const as e_const
import pkgcore.spawn
from snakeoil import klass
from snakeoil.currying import pretty_docs
from snakeoil.demandload import demandload
from snakeoil.osutils import abspath, normpath, pjoin
from snakeoil.weakrefs import WeakRefFinalizer
demandload(
'traceback',
'snakeoil:fileutils',
'pkgcore.log:logger',
)
def _single_thread_allowed(functor):
def _inner(*args, **kwds):
_acquire_global_ebp_lock()
try:
return functor(*args, **kwds)
finally:
_release_global_ebp_lock()
_inner.func = functor
pretty_docs(_inner, name=functor.__name__)
return _inner
示例9: import
gentoo ebuild atom, should be generalized into an agnostic base
"""
__all__ = ("atom", "transitive_use_atom", "generate_collapsed_restriction")
import string
from pkgcore.restrictions import values, packages, boolean
from pkgcore.ebuild import cpv, errors, const, restricts
from snakeoil.compatibility import is_py3k, cmp, raise_from
from snakeoil.klass import (generic_equality, inject_richcmp_methods_from_cmp,
reflective_hash, alias_attr)
from snakeoil.demandload import demandload
from snakeoil.currying import partial
demandload(globals(),
"pkgcore.restrictions.delegated:delegate",
'pkgcore.restrictions.packages:Conditional,[email protected]',
'pkgcore.restrictions.values:ContainmentMatch',
'collections:defaultdict',
)
# namespace compatibility...
MalformedAtom = errors.MalformedAtom
alphanum = set(string.digits)
if is_py3k:
alphanum.update(string.ascii_letters)
else:
alphanum.update(string.letters)
valid_repo_chars = set(alphanum)
valid_repo_chars.update("_-")
valid_use_chars = set(alphanum)
示例10: _scan_directory
# Copyright: 2011 Brian Harring <[email protected]>
# License: GPL2/BSD 3 clause
from operator import itemgetter
from collections import deque, defaultdict
from snakeoil.osutils import listdir_files, pjoin
from snakeoil.fileutils import readlines
from snakeoil.iterables import chain_from_iterable
from pkgcore.ebuild.atom import atom
from snakeoil.lists import iflatten_instance
from snakeoil import demandload
demandload.demandload(globals(),
'pkgcore.log:logger',
)
demandload.demand_compile_regexp(globals(), "valid_updates_re", "^(\d)Q-(\d{4})$")
def _scan_directory(path):
files = []
for x in listdir_files(path):
match = valid_updates_re.match(x)
if match is not None:
files.append(((match.group(2), match.group(1)), x))
files.sort(key=itemgetter(0))
return [x[1] for x in files]
def read_updates(path):
def f():
d = deque()
return [d,d]
示例11: demandload
pkgset based around loading a list of atoms from a world file
"""
__all__ = ("FileList", "WorldFile")
from snakeoil import compatibility, klass
from snakeoil.demandload import demandload
from pkgcore.config import ConfigHint, errors
from pkgcore.ebuild import const
from pkgcore.ebuild.atom import atom
from pkgcore.package.errors import InvalidDependency
demandload(
'snakeoil.fileutils:AtomicWriteFile,readlines_ascii',
'pkgcore:os_data',
'pkgcore.log:logger',
)
class FileList(object):
pkgcore_config_type = ConfigHint({'location': 'str'}, typename='pkgset')
error_on_subsets = True
def __init__(self, location, gid=os_data.portage_gid, mode=0644):
self.path = location
self.gid = gid
self.mode = mode
# note that _atoms is generated on the fly.
@klass.jit_attr
示例12: behaviour
# Copyright: 2006-2011 Brian Harring <[email protected]>
# License: GPL2/BSD
"""
resolver configuration to match portage behaviour (misbehaviour in a few spots)
"""
__all__ = ["upgrade_resolver", "min_install_resolver"]
from pkgcore.repository import misc, multiplex
from pkgcore.resolver import plan
from snakeoil.demandload import demandload
demandload(globals(),
'pkgcore.restrictions:packages,values',
)
def upgrade_resolver(vdbs, dbs, verify_vdb=True, nodeps=False,
force_replacement=False,
resolver_cls=plan.merge_plan, **kwds):
"""
generate and configure a resolver for upgrading all processed nodes.
:param vdbs: list of :obj:`pkgcore.repository.prototype.tree` instances
that represents the livefs
:param dbs: list of :obj:`pkgcore.repository.prototype.tree` instances
representing sources of pkgs
:param verify_vdb: should we stop resolving once we hit the vdb,
or do full resolution?
:param force_vdb_virtuals: old style portage virtuals (non metapkgs)
示例13: demandload
Changing them triggering regen of other attributes on the package instance.
"""
__all__ = ("make_wrapper",)
from functools import partial
from operator import attrgetter
from snakeoil.containers import LimitedChangeSet, Unchangable
from snakeoil.demandload import demandload
from pkgcore.package.base import wrapper
demandload(
"copy:copy",
)
def _getattr_wrapped(attr, self):
o = self._cached_wrapped.get(attr)
if o is None or o[0] != self._reuse_pt:
o = self._wrapped_attr[attr](
getattr(self._raw_pkg, attr),
self._configurable,
pkg=self)
o = self._cached_wrapped[attr] = (self._reuse_pt, o)
return o[1]
def make_wrapper(wrapped_repo, configurable_attribute_name, attributes_to_wrap=(),
示例14: demandload
__all__ = (
"syncer_exception", "uri_exception", "generic_exception",
"missing_local_user", "missing_binary", "syncer", "ExternalSyncer",
"dvcs_syncer", "GenericSyncer", "DisabledSyncer",
"AutodetectSyncer",
)
from snakeoil import compatibility
from snakeoil.demandload import demandload
from pkgcore.config import ConfigHint, configurable
demandload(
'os',
'pwd',
'stat',
'errno',
'pkgcore:os_data,plugin,spawn',
)
class syncer_exception(Exception):
pass
class uri_exception(syncer_exception):
pass
class generic_exception(syncer_exception):
pass
示例15: demandload
Changing them triggering regen of other attributes on the package instance.
"""
__all__ = ("make_wrapper",)
from operator import attrgetter
from snakeoil.containers import LimitedChangeSet, Unchangable
from snakeoil.currying import partial
from pkgcore.package.base import wrapper
from snakeoil.demandload import demandload
demandload(globals(),
"copy",
)
def _getattr_wrapped(attr, self):
o = self._cached_wrapped.get(attr)
if o is None or o[0] != self._reuse_pt:
o = self._wrapped_attr[attr](getattr(self._raw_pkg, attr),
self._configurable)
o = self._cached_wrapped[attr] = (self._reuse_pt, o)
return o[1]
def make_wrapper(configurable_attribute_name, attributes_to_wrap=(),
kls_injections={}):
"""