本文整理汇总了Python中snakeoil.demandload.demandload函数的典型用法代码示例。如果您正苦于以下问题:Python demandload函数的具体用法?Python demandload怎么用?Python demandload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了demandload函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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'])
开发者ID:chutz,项目名称:snakeoil,代码行数:7,代码来源:test_demandload.py
示例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:
开发者ID:neko259,项目名称:pkgcore,代码行数:31,代码来源:plugin.py
示例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')
开发者ID:radhermit,项目名称:bite,代码行数:31,代码来源:monorail.py
示例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'
开发者ID:neko259,项目名称:pkgcore,代码行数:32,代码来源:pconfig.py
示例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):
开发者ID:radhermit,项目名称:bite,代码行数:31,代码来源:bugzilla.py
示例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
开发者ID:veelai,项目名称:pkgcore-1,代码行数:31,代码来源:format.py
示例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()
开发者ID:vapier,项目名称:snakeoil,代码行数:31,代码来源:__init__.py
示例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
开发者ID:vapier,项目名称:pkgcore,代码行数:30,代码来源:processor.py
示例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)
开发者ID:chutz,项目名称:pkgcore,代码行数:32,代码来源:atom.py
示例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]
开发者ID:veelai,项目名称:pkgcore,代码行数:31,代码来源:pkg_updates.py
示例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
开发者ID:den4ix,项目名称:pkgcore,代码行数:31,代码来源:filelist.py
示例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)
开发者ID:veelai,项目名称:pkgcore,代码行数:31,代码来源:resolver.py
示例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=(),
开发者ID:radhermit,项目名称:pkgcore,代码行数:30,代码来源:conditionals.py
示例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
开发者ID:neko259,项目名称:pkgcore,代码行数:31,代码来源:base.py
示例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={}):
"""
开发者ID:chutz,项目名称:pkgcore,代码行数:30,代码来源:conditionals.py
示例16: demandload
__all__ = (
"ConfigType", "LazySectionRef", "LazyNamedSectionRef", "ConfigSection",
"DictConfigSection", "FakeIncrementalDictConfigSection", "convert_string",
"convert_asis", "convert_hybrid", "section_alias", "str_to_list",
"str_to_str", "str_to_bool", "str_to_int", "parse_config_file",
)
from functools import partial
from snakeoil import compatibility
from snakeoil.demandload import demandload
from pkgcore.config import errors, configurable
demandload("snakeoil:modules")
type_names = ("list", "str", "bool", "int")
# Copied from inspect.py which copied it from compile.h.
# Also documented in http://docs.python.org/ref/types.html.
CO_VARARGS, CO_VARKEYWORDS = 4, 8
if compatibility.is_py3k:
_code_attrname = '__code__'
else:
_code_attrname = 'func_code'
class ConfigType(object):
开发者ID:den4ix,项目名称:pkgcore,代码行数:30,代码来源:basics.py
示例17: demandload
# Copyright: 2006-2011 Brian Harring <[email protected]>
# License: BSD/GPL2
from snakeoil.cli import arghparse
from snakeoil.demandload import demandload
from pkgcore.util import commandline
demandload(
'os',
'functools:partial',
'snakeoil:osutils',
'pkgcore.ebuild:atom,conditionals',
'pkgcore.ebuild.eapi:get_eapi',
'pkgcore.restrictions.boolean:AndRestriction',
'pkgcore.util:packages',
)
def str_pkg(pkg):
pkg = packages.get_raw_pkg(pkg)
# special casing; old style virtuals come through as the original pkg.
if pkg.package_is_real:
return pkg.cpvstr
if hasattr(pkg, "actual_pkg"):
return pkg.actual_pkg.cpvstr
# icky, but works.
return str(pkg.rdepend).lstrip("=")
def get_atom_kls(value):
eapi = get_eapi(value)
开发者ID:radhermit,项目名称:pkgcore,代码行数:31,代码来源:portageq.py
示例18: demandload
@copyright: 2012-2015 by Brian Dolbec <[email protected]>
@copyright: 2014-2015 by Pavlos Ratis <[email protected]>
@license: GNU GPL2, see COPYING for details.
"""
import os
import re
from snakeoil.demandload import demandload
from gkeys.gkey import GKEY
from gkeys.seed import Seeds, decoder
demandload(
"json:load",
"gkeys.exception:UpdateDbError",
"gkeys.fileops:ensure_dirs",
)
class SeedHandler(object):
def __init__(self, logger, config):
self.config = config
self.logger = logger
self.fingerprint_re = re.compile('[0-9A-Fa-f]{40}')
self.finerprint_re2 = re.compile('[0-9A-Fa-f]{4}( [0-9A-Fa-f]{4}){9}')
self.seeds = None
def new(self, args, checkgkey=False):
开发者ID:aeroniero33,项目名称:gentoo-keys,代码行数:31,代码来源:seedhandler.py
示例19: demandload
import copy
import logging
import optparse
import os.path
import sys
from snakeoil import klass
from snakeoil.demandload import demandload
from pkgcore.config import load_config
demandload(
'snakeoil.bash:iter_read_bash',
'snakeoil:version',
'pkgcore.config:basics',
'pkgcore.ebuild:atom',
'pkgcore.util:parserestrict',
)
CONFIG_LOADED_MSG = (
'Configuration already loaded. If moving the option earlier '
'on the commandline does not fix this report it as a bug.')
# Mix in object here or properties do not work (Values is an oldstyle class).
class Values(optparse.Values, object):
"""Values with an autoloaded config property.
开发者ID:ferringb,项目名称:pkgcore,代码行数:29,代码来源:commandline_optparse.py
示例20: demandload
ChunkedDataDict, chunked_data, collapsed_restrict_to_data,
incremental_expansion, incremental_expansion_license,
non_incremental_collapsed_restrict_to_data, optimize_incrementals,
package_keywords_splitter)
from pkgcore.ebuild.repo_objs import OverlayedLicenses
from pkgcore.repository import visibility
from pkgcore.restrictions import packages, values
from pkgcore.restrictions.delegated import delegate
from pkgcore.util.parserestrict import parse_match
demandload(
'collections:defaultdict',
'errno',
'multiprocessing:cpu_count',
'operator:itemgetter',
're',
'pkgcore.binpkg:[email protected]_repo',
'pkgcore.ebuild:[email protected]_repo',
'pkgcore.ebuild.triggers:[email protected]_generate_triggers',
'pkgcore.fs.livefs:iter_scan',
"pkgcore.repository:util",
)
class MissingFile(BaseError):
"""Required file is missing."""
def __init__(self, filename, setting):
BaseError.__init__(
self, "setting %s points at %s, which doesn't exist."
% (setting, filename))
self.file, self.setting = filename, setting
开发者ID:den4ix,项目名称:pkgcore,代码行数:31,代码来源:domain.py
注:本文中的snakeoil.demandload.demandload函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论