Skip to content

Commit

Permalink
Rename Plugins as Hooks (#3867)
Browse files Browse the repository at this point in the history
* Rename Plugins as Hooks

* Migration from plugins to hooks
  • Loading branch information
danimtb authored and jgsogo committed Oct 29, 2018
1 parent 0816e3c commit 2339378
Show file tree
Hide file tree
Showing 27 changed files with 470 additions and 439 deletions.
22 changes: 11 additions & 11 deletions conans/client/client_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
REGISTRY = "registry.txt"
REGISTRY_JSON = "registry.json"
PROFILES_FOLDER = "profiles"
PLUGINS_FOLDER = "plugins"
HOOKS_FOLDER = "hooks"

# Client certificates
CLIENT_CERT = "client.crt"
Expand Down Expand Up @@ -156,11 +156,11 @@ def default_profile_path(self):
self.conan_config.default_profile)

@property
def plugins_path(self):
def hooks_path(self):
"""
:return: Plugins folder in client cache
:return: Hooks folder in client cache
"""
return join(self.conan_folder, PLUGINS_FOLDER)
return join(self.conan_folder, HOOKS_FOLDER)

@property
def default_profile(self):
Expand Down Expand Up @@ -210,13 +210,13 @@ def settings(self):
return self._settings

@property
def plugins(self):
"""Returns a list of plugins inside the plugins folder"""
plugins = []
for plugin_name in os.listdir(self.plugins_path):
if os.path.isfile(plugin_name) and plugin_name.endswith(".py"):
plugins.append(plugin_name[:-3])
return plugins
def hooks(self):
"""Returns a list of hooks inside the hooks folder"""
hooks = []
for hook_name in os.listdir(self.hooks_path):
if os.path.isfile(hook_name) and hook_name.endswith(".py"):
hooks.append(hook_name[:-3])
return hooks

def conan_packages(self, conan_reference):
""" Returns a list of package_id from a local cache package folder """
Expand Down
10 changes: 5 additions & 5 deletions conans/client/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conans.model.conan_file import get_env_context_manager


def build(graph_manager, plugin_manager, conanfile_path, output,
def build(graph_manager, hook_manager, conanfile_path, output,
source_folder, build_folder, package_folder, install_folder,
test=False, should_configure=True, should_build=True, should_install=True,
should_test=True):
Expand Down Expand Up @@ -50,14 +50,14 @@ def build(graph_manager, plugin_manager, conanfile_path, output,
conan_file.source_folder = source_folder
conan_file.package_folder = package_folder
conan_file.install_folder = install_folder
plugin_manager.execute("pre_build", conanfile=conan_file,
conanfile_path=conanfile_path)
hook_manager.execute("pre_build", conanfile=conan_file,
conanfile_path=conanfile_path)
with get_env_context_manager(conan_file):
output.highlight("Running build()")
with conanfile_exception_formatter(str(conan_file), "build"):
conan_file.build()
plugin_manager.execute("post_build", conanfile=conan_file,
conanfile_path=conanfile_path)
hook_manager.execute("post_build", conanfile=conan_file,
conanfile_path=conanfile_path)
if test:
output.highlight("Running test()")
with conanfile_exception_formatter(str(conan_file), "test"):
Expand Down
8 changes: 4 additions & 4 deletions conans/client/cmd/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def download(reference, package_ids, remote_name, recipe, registry, remote_manager,
client_cache, out, recorder, loader, plugin_manager):
client_cache, out, recorder, loader, hook_manager):

assert(isinstance(reference, ConanFileReference))
output = ScopedOutput(str(reference), out)
Expand All @@ -16,7 +16,7 @@ def download(reference, package_ids, remote_name, recipe, registry, remote_manag
if not package: # Search the reference first, and raise if it doesn't exist
raise ConanException("'%s' not found in remote" % str(reference))

plugin_manager.execute("pre_download", reference=reference, remote=remote)
hook_manager.execute("pre_download", reference=reference, remote=remote)
# First of all download package recipe
remote_manager.get_recipe(reference, remote)
registry.refs.set(reference, remote.name)
Expand All @@ -41,8 +41,8 @@ def download(reference, package_ids, remote_name, recipe, registry, remote_manag
else:
_download_binaries(reference, list(packages_props.keys()), client_cache,
remote_manager, remote, output, recorder, loader)
plugin_manager.execute("post_download", conanfile_path=conan_file_path, reference=reference,
remote=remote)
hook_manager.execute("post_download", conanfile_path=conan_file_path, reference=reference,
remote=remote)


def _download_binaries(reference, package_ids, client_cache, remote_manager, remote, output,
Expand Down
8 changes: 4 additions & 4 deletions conans/client/cmd/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class AliasConanfile(ConanFile):


def cmd_export(conanfile_path, conanfile, reference, keep_source, output, client_cache,
plugin_manager, registry):
hook_manager, registry):
""" Export the recipe
param conanfile_path: the original source directory of the user containing a
conanfile.py
"""
plugin_manager.execute("pre_export", conanfile=conanfile, conanfile_path=conanfile_path,
reference=reference)
hook_manager.execute("pre_export", conanfile=conanfile, conanfile_path=conanfile_path,
reference=reference)
logger.debug("Exporting %s" % conanfile_path)
output.highlight("Exporting package recipe")

Expand All @@ -58,7 +58,7 @@ def cmd_export(conanfile_path, conanfile, reference, keep_source, output, client
_export_conanfile(conanfile_path, conanfile.output, client_cache, conanfile, reference,
keep_source)
conanfile_cache_path = client_cache.conanfile(reference)
plugin_manager.execute("post_export", conanfile=conanfile, conanfile_path=conanfile_cache_path,
hook_manager.execute("post_export", conanfile=conanfile, conanfile_path=conanfile_cache_path,
reference=reference)


Expand Down
6 changes: 3 additions & 3 deletions conans/client/cmd/export_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conans.client.graph.graph_manager import load_deps_info


def export_pkg(client_cache, graph_manager, plugin_manager, recorder, output,
def export_pkg(client_cache, graph_manager, hook_manager, recorder, output,
reference, source_folder, build_folder, package_folder, install_folder,
profile, force):

Expand Down Expand Up @@ -44,9 +44,9 @@ def export_pkg(client_cache, graph_manager, plugin_manager, recorder, output,
package_output = ScopedOutput(str(reference), output)
if package_folder:
packager.export_pkg(conanfile, pkg_id, package_folder, dest_package_folder, package_output,
plugin_manager, conan_file_path, reference)
hook_manager, conan_file_path, reference)
else:
packager.create_package(conanfile, pkg_id, source_folder, build_folder, dest_package_folder,
install_folder, package_output, plugin_manager, conan_file_path,
install_folder, package_output, hook_manager, conan_file_path,
reference, local=True)
recorder.package_exported(pkg_reference)
4 changes: 2 additions & 2 deletions conans/client/cmd/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def install_build_and_test(self, conanfile_abs_path, reference, profile,
manifest_verify=manifest_verify,
manifest_interactive=manifest_interactive,
keep_build=keep_build)
# FIXME: This is ugly access to graph_manager and plugin_manager. Will be cleaned in 2.0
build(self._manager._graph_manager, self._manager._plugin_manager, conanfile_abs_path,
# FIXME: This is ugly access to graph_manager and hook_manager. Will be cleaned in 2.0
build(self._manager._graph_manager, self._manager._hook_manager, conanfile_abs_path,
self._user_io.out,
base_folder, test_build_folder, package_folder=None,
install_folder=test_build_folder, test=str(reference))
Expand Down
12 changes: 6 additions & 6 deletions conans/client/cmd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

class CmdUpload(object):

def __init__(self, client_cache, user_io, remote_manager, registry, loader, plugin_manager):
def __init__(self, client_cache, user_io, remote_manager, registry, loader, hook_manager):
self._client_cache = client_cache
self._user_io = user_io
self._remote_manager = remote_manager
self._registry = registry
self._loader = loader
self._plugin_manager = plugin_manager
self._hook_manager = hook_manager

def upload(self, recorder, reference_or_pattern, package_id=None, all_packages=None,
confirm=False, retry=0, retry_wait=0, integrity_check=False, policy=None,
Expand Down Expand Up @@ -83,8 +83,8 @@ def _upload(self, conan_file, conan_ref, packages_ids, retry, retry_wait,
conanfile_path = self._client_cache.conanfile(conan_ref)
# FIXME: I think it makes no sense to specify a remote to "pre_upload"
# FIXME: because the recipe can have one and the package a different one
self._plugin_manager.execute("pre_upload", conanfile_path=conanfile_path,
reference=conan_ref, remote=recipe_remote)
self._hook_manager.execute("pre_upload", conanfile_path=conanfile_path,
reference=conan_ref, remote=recipe_remote)

if policy != UPLOAD_POLICY_FORCE:
remote_manifest = self._check_recipe_date(conan_ref, recipe_remote)
Expand Down Expand Up @@ -121,8 +121,8 @@ def _upload(self, conan_file, conan_ref, packages_ids, retry, retry_wait,

# FIXME: I think it makes no sense to specify a remote to "post_upload"
# FIXME: because the recipe can have one and the package a different one
self._plugin_manager.execute("post_upload", conanfile_path=conanfile_path,
reference=conan_ref, remote=recipe_remote)
self._hook_manager.execute("post_upload", conanfile_path=conanfile_path,
reference=conan_ref, remote=recipe_remote)

def _upload_recipe(self, conan_reference, retry, retry_wait, policy, remote, remote_manifest):
conan_file_path = self._client_cache.conanfile(conan_reference)
Expand Down
2 changes: 1 addition & 1 deletion conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def config(self, *args):
try:
key, value = args.item.split("=", 1)
except ValueError:
if "plugins." in args.item:
if "hooks." in args.item:
key, value = args.item.split("=", 1)[0], None
else:
raise ConanException("Please specify 'key=value'")
Expand Down
Loading

0 comments on commit 2339378

Please sign in to comment.