本文整理汇总了Python中enstaller.repository.Repository.add_package方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.add_package方法的具体用法?Python Repository.add_package怎么用?Python Repository.add_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enstaller.repository.Repository
的用法示例。
在下文中一共展示了Repository.add_package方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: repository_factory
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def repository_factory(package_names, repository_info, reference_packages):
repository = Repository()
for package_name in package_names:
package = reference_packages[package_name]
package = RepositoryPackageMetadata.from_package(package, repository_info)
repository.add_package(package)
return repository
示例2: repository_factory_from_egg
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def repository_factory_from_egg(filenames):
repository = Repository()
for filename in filenames:
path = os.path.join(_EGGINST_COMMON_DATA, filename)
package = RemotePackageMetadata.from_egg(path)
repository.add_package(package)
return repository
示例3: test_simple_scenario
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def test_simple_scenario(self):
egg = DUMMY_EGG
r_actions = {1: [], 0: [("remove", os.path.basename(egg))]}
config = Configuration()
repository = Repository()
package = RepositoryPackageMetadata.from_egg(egg)
package.python = PY_VER
repository.add_package(package)
with open(egg, "rb") as fp:
responses.add(responses.GET, package.source_url,
body=fp.read(), status=200,
content_type='application/json')
session = Session(DummyAuthenticator(), config.repository_cache)
enpkg = Enpkg(repository, session, prefixes=self.prefixes)
actions = [("fetch", os.path.basename(egg)),
("install", os.path.basename(egg))]
enpkg.execute(actions)
name, version = egg_name_to_name_version(egg)
enpkg._installed_repository.find_package(name, version)
for state in [0, 1]:
actions = enpkg.revert_actions(state)
self.assertEqual(actions, r_actions[state])
示例4: repository_factory
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def repository_factory(session, repository_infos, quiet=False,
raise_on_error=False):
unavailables = []
full_repository = Repository()
_write_and_flush("Fetching indices: ", quiet)
with ThreadPoolExecutor(max_workers=4) as executor:
tasks = {}
for repository_info in repository_infos:
task = executor.submit(_fetch_repository, session,
repository_info, raise_on_error)
tasks[task] = repository_info
for task in as_completed(tasks):
repository_or_none = task.result()
if repository_or_none is None:
unavailables.append(tasks[task])
else:
for package in repository_or_none.iter_packages():
full_repository.add_package(package)
_write_and_flush(".", quiet)
_write_and_flush("\n\n", quiet)
if len(unavailables) > 0 and not quiet:
_print_unavailables_warning(unavailables)
return full_repository
示例5: test_simple_installed
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def test_simple_installed(self):
# Given
entries = [
dummy_repository_package_factory("MKL", "10.3", 1),
dummy_repository_package_factory("numpy", "1.8.0", 2,
dependencies=["MKL 10.3"]),
]
repository = repository_factory(entries)
installed_repository = Repository()
installed_repository.add_package(
dummy_installed_package_factory("MKL", "10.3", 1)
)
expected_actions = [
('install', "numpy-1.8.0-2.egg"),
]
# When
request = Request()
request.install(Requirement("numpy"))
solver = Solver(repository, installed_repository)
actions = solver.resolve(request)
# Then
self.assertListEqual(actions, expected_actions)
示例6: test_find_packages_sorting
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def test_find_packages_sorting(self):
# Given
entries = [
dummy_installed_package_factory("numpy", "1.6.1", 1),
dummy_installed_package_factory("numpy", "1.8.0", 2),
dummy_installed_package_factory("numpy", "1.7.1", 1),
]
repository = Repository()
for entry in entries:
repository.add_package(entry)
r_versions = [
EnpkgVersion.from_string(v)
for v in ("1.6.1-1", "1.7.1-1", "1.8.0-2")
]
# When
packages = repository.find_packages("numpy")
# Then
self.assertEqual(len(packages), 3)
self.assertEqual([p.version for p in packages], r_versions)
with self.assertWarns(DeprecationWarning):
deprecated_packages = repository.find_sorted_packages("numpy")
self.assertEqual([p.version for p in deprecated_packages], r_versions)
示例7: _downloader_factory
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _downloader_factory(self, paths):
repository = Repository()
for path in paths:
package = RepositoryPackageMetadata.from_egg(path)
repository.add_package(package)
return (_DownloadManager(Session(DummyAuthenticator(), self.tempdir), repository),
repository)
示例8: _create_store_and_repository
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _create_store_and_repository(self, eggs):
repository = Repository()
for egg in eggs:
path = os.path.join(_EGGINST_COMMON_DATA, egg)
package = RepositoryPackageMetadata.from_egg(path)
repository.add_package(package)
return repository
示例9: _create_repositories
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _create_repositories(self, entries, installed_entries):
repository = Repository()
for entry in entries:
repository.add_package(entry)
installed_repository = Repository()
for entry in installed_entries:
installed_repository.add_package(entry)
return repository, installed_repository
示例10: _install_eggs
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _install_eggs(self, paths):
repository = Repository()
for path in paths:
package = RepositoryPackageMetadata.from_egg(path)
repository.add_package(package)
for path in paths:
action = InstallAction(path, self.top_prefix, repository,
self.top_installed_repository,
self.installed_repository,
os.path.dirname(path))
action.execute()
示例11: remote_enstaller_available
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def remote_enstaller_available(versions):
repository = Repository()
for version in versions:
package = dummy_repository_package_factory("enstaller", version, build=1)
repository.add_package(package)
def dec(f):
@functools.wraps(f)
def wrapper(*a, **kw):
with mock.patch("enstaller.main.repository_factory",
return_value=repository):
return f(*a, **kw)
return wrapper
return dec
示例12: create_repositories
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def create_repositories(remote_entries=None, installed_entries=None):
if remote_entries is None:
remote_entries = []
if installed_entries is None:
installed_entries = []
remote_repository = Repository()
for remote_entry in remote_entries:
remote_repository.add_package(remote_entry)
installed_repository = Repository()
for installed_entry in installed_entries:
installed_repository.add_package(installed_entry)
return remote_repository, installed_repository
示例13: test_fetch_invalid_md5
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def test_fetch_invalid_md5(self):
# Given
filename = "nose-1.3.0-1.egg"
path = os.path.join(_EGGINST_COMMON_DATA, filename)
repository = Repository()
package = RepositoryPackageMetadata.from_egg(path)
package.md5 = "a" * 32
repository.add_package(package)
downloader = _DownloadManager(mocked_session_factory(self.tempdir),
repository)
with self.assertRaises(InvalidChecksum):
downloader.fetch(filename)
示例14: _retry_common_setup
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _retry_common_setup(self):
store_url = "http://acme.com"
repository_info = OldstyleRepositoryInfo(store_url)
filename = "nose-1.3.0-1.egg"
path = os.path.join(_EGGINST_COMMON_DATA, filename)
repository = Repository()
package = RemotePackageMetadata.from_egg(path, repository_info)
repository.add_package(package)
downloader = _DownloadManager(mocked_session_factory(self.tempdir),
repository)
return path, downloader, repository
示例15: _retry_common_setup
# 需要导入模块: from enstaller.repository import Repository [as 别名]
# 或者: from enstaller.repository.Repository import add_package [as 别名]
def _retry_common_setup(self):
store_location = "http://acme.com/"
filename = "nose-1.3.0-1.egg"
path = os.path.join(_EGGINST_COMMON_DATA, filename)
repository = Repository()
package = RepositoryPackageMetadata.from_egg(path,
store_location=store_location)
repository.add_package(package)
downloader = _DownloadManager(mocked_session_factory(self.tempdir),
repository)
return path, downloader, repository