diff --git a/conan/api/model/remote.py b/conan/api/model/remote.py index 0f6120bd268..a66a28fb935 100644 --- a/conan/api/model/remote.py +++ b/conan/api/model/remote.py @@ -2,7 +2,10 @@ class Remote: - + """ + The ``Remote`` class represents a remote registry of packages. It's a read-only opaque object that + should not be created directly, but obtained from the relevant ``RemotesAPI`` subapi methods. + """ def __init__(self, name, url, verify_ssl=True, disabled=False, allowed_packages=None, remote_type=None): self.name = name # Read only, is the key @@ -11,7 +14,7 @@ def __init__(self, name, url, verify_ssl=True, disabled=False, allowed_packages= self.disabled = disabled self.allowed_packages = allowed_packages self.remote_type = remote_type - self.caching = {} + self._caching = {} def __eq__(self, other): if other is None: @@ -33,5 +36,4 @@ def __repr__(self): return str(self) def invalidate_cache(self): - # TODO: make it private - self.caching = {} + self._caching = {} diff --git a/conan/api/subapi/remotes.py b/conan/api/subapi/remotes.py index ebc17c4d920..1bb55664a3f 100644 --- a/conan/api/subapi/remotes.py +++ b/conan/api/subapi/remotes.py @@ -40,12 +40,12 @@ def reinit(self): def list(self, pattern=None, only_enabled=True): """ - Obtain a list of ``Remote`` objects matching the pattern. + Obtain a list of :ref:`Remote ` objects matching the pattern. :param pattern: ``None``, single ``str`` or list of ``str``. If it is ``None``, all remotes will be returned (equivalent to ``pattern="*"``). :param only_enabled: boolean, by default return only enabled remotes - :return: A list of ``Remote`` objects + :return: A list of :ref:`Remote ` objects """ remotes = _load(self._remotes_file) @@ -61,7 +61,7 @@ def disable(self, pattern): :param pattern: single ``str`` or list of ``str``. If the pattern is an exact name without wildcards like "*" and no remote is found matching that exact name, it will raise an error. - :return: the list of disabled ``Remote`` objects (even if they were already disabled) + :return: the list of disabled :ref:`Remote ` objects (even if they were already disabled) """ remotes = _load(self._remotes_file) disabled = _filter(remotes, pattern, only_enabled=False) @@ -79,7 +79,7 @@ def enable(self, pattern): :param pattern: single ``str`` or list of ``str``. If the pattern is an exact name without wildcards like "*" and no remote is found matching that exact name, it will raise an error. - :return: the list of enabled ``Remote`` objects (even if they were already enabled) + :return: the list of enabled :ref:`Remote ` objects (even if they were already enabled) """ remotes = _load(self._remotes_file) enabled = _filter(remotes, pattern, only_enabled=False) @@ -93,10 +93,10 @@ def enable(self, pattern): def get(self, remote_name): """ - Obtain a ``Remote`` object + Obtain a :ref:`Remote ` object :param remote_name: the exact name of the remote to be returned - :return: the ``Remote`` object, or raise an Exception if the remote does not exist. + :return: the :ref:`Remote ` object, or raise an Exception if the remote does not exist. """ remotes = _load(self._remotes_file) try: @@ -106,11 +106,11 @@ def get(self, remote_name): def add(self, remote: Remote, force=False, index=None): """ - Add a new ``Remote`` object to the existing ones + Add a new :ref:`Remote ` object to the existing ones - :param remote: a ``Remote`` object to be added - :param force: do not fail if the remote already exist (but default it failes) + :param remote: a :ref:`Remote ` object to be added + :param force: do not fail if the remote already exist (but default it fails) :param index: if not defined, the new remote will be last one. Pass an integer to insert the remote in that position instead of the last one """ @@ -143,7 +143,7 @@ def remove(self, pattern): :param pattern: single ``str`` or list of ``str``. If the pattern is an exact name without wildcards like "*" and no remote is found matching that exact name, it will raise an error. - :return: The list of removed ``Remote`` objects + :return: The list of removed :ref:`Remote ` objects """ remotes = _load(self._remotes_file) removed = _filter(remotes, pattern, only_enabled=False) @@ -220,7 +220,7 @@ def user_login(self, remote: Remote, username: str, password: str): """ Perform user authentication against the given remote with the provided username and password - :param remote: a ``Remote`` object + :param remote: a :ref:`Remote ` object :param username: the user login as ``str`` :param password: password ``str`` """ @@ -229,9 +229,9 @@ def user_login(self, remote: Remote, username: str, password: str): def user_logout(self, remote: Remote): """ - Logout from the given ``Remote`` + Logout from the given :ref:`Remote ` - :param remote: The ``Remote`` object to logout + :param remote: The :ref:`Remote ` object to logout """ localdb = LocalDB(self._home_folder) # The localdb only stores url + username + token, not remote name, so use URL as key diff --git a/conans/client/remote_manager.py b/conans/client/remote_manager.py index ae1c860deb0..4f5fff28e81 100644 --- a/conans/client/remote_manager.py +++ b/conans/client/remote_manager.py @@ -187,7 +187,7 @@ def _get_package(self, layout, pref, remote, scoped_output, metadata): raise def search_recipes(self, remote, pattern): - cached_method = remote.caching.setdefault("search_recipes", {}) + cached_method = remote._caching.setdefault("search_recipes", {}) try: return cached_method[pattern] except KeyError: @@ -241,7 +241,7 @@ def get_latest_package_reference(self, pref, remote, info=None) -> PkgReference: if options: headers['Conan-PkgID-Options'] = ';'.join(options) - cached_method = remote.caching.setdefault("get_latest_package_reference", {}) + cached_method = remote._caching.setdefault("get_latest_package_reference", {}) try: return cached_method[pref] except KeyError: