From bf0d9ad924b32cdde2ccfac10c6632d7ac843aa3 Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 8 Oct 2024 10:10:57 +0200 Subject: [PATCH 1/2] removing legacy from-conans usages --- .../clean/custom_command_clean_revisions.rst | 31 +++---------------- reference/conan_server.rst | 2 +- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/examples/extensions/commands/clean/custom_command_clean_revisions.rst b/examples/extensions/commands/clean/custom_command_clean_revisions.rst index b83ad574cb44..44797aaa314c 100644 --- a/examples/extensions/commands/clean/custom_command_clean_revisions.rst +++ b/examples/extensions/commands/clean/custom_command_clean_revisions.rst @@ -96,7 +96,6 @@ The ``conan clean`` command has the following code: from conan.api.conan_api import ConanAPI from conan.api.output import ConanOutput, Color from conan.cli.command import OnceArgument, conan_command - from conans.client.userio import UserInput recipe_color = Color.BRIGHT_BLUE @@ -111,23 +110,14 @@ The ``conan clean`` command has the following code: """ parser.add_argument('-r', '--remote', action=OnceArgument, help='Will remove from the specified remote') - parser.add_argument('--force', default=False, action='store_true', - help='Remove without requesting a confirmation') args = parser.parse_args(*args) - def confirmation(message): - return args.force or ui.request_boolean(message) - - ui = UserInput(non_interactive=False) out = ConanOutput() remote = conan_api.remotes.get(args.remote) if args.remote else None output_remote = remote or "Local cache" # Getting all the recipes recipes = conan_api.search.recipes("*/*", remote=remote) - if recipes and not confirmation("Do you want to remove all the recipes revisions and their packages ones, " - "except the latest package revision from the latest recipe one?"): - return for recipe in recipes: out.writeln(f"{str(recipe)}", fg=recipe_color) all_rrevs = conan_api.list.recipe_revisions(recipe, remote=remote) @@ -158,23 +148,12 @@ The ``parser`` param is an instance of the Python command-line parsing ``argpars so if you want to know more about its API, visit `its official website `_. -User input and user output -++++++++++++++++++++++++++ - -Important classes to manage user input and user output: - -.. code-block:: python - - ui = UserInput(non_interactive=False) - out = ConanOutput() - +User output ++++++++++++ -* ``UserInput(non_interactive)``: class to manage user inputs. In this example we're using ``ui.request_boolean("Do you want to proceed?")``, - so it'll be automatically translated to ``Do you want to proceed? (yes/no):`` in the command prompt. - **Note**: you can use ``UserInput(non_interactive=conan_api.config.get("core:non_interactive"))`` too. -* ``ConanOutput()``: class to manage user outputs. In this example, we're using only ``out.writeln(message, fg=None, bg=None)`` - where ``fg`` is the font foreground, and ``bg`` is the font background. Apart from that, you have some predefined methods - like ``out.info()``, ``out.success()``, ``out.error()``, etc. +``ConanOutput()``: class to manage user outputs. In this example, we're using only ``out.writeln(message, fg=None, bg=None)`` +where ``fg`` is the font foreground, and ``bg`` is the font background. Apart from that, you have some predefined methods +like ``out.info()``, ``out.success()``, ``out.error()``, etc. Conan public API diff --git a/reference/conan_server.rst b/reference/conan_server.rst index 9a3f34f013cc..5c03f7eca321 100644 --- a/reference/conan_server.rst +++ b/reference/conan_server.rst @@ -224,7 +224,7 @@ If you want to create your own Authorizer, create a Python module in .. code-block:: python - from conans.errors import AuthenticationException, ForbiddenException + from conan.internal.errors import AuthenticationException, ForbiddenException def get_class(): return MyAuthorizer() From 6ca51ee786efe0757124c5ae86ab14d4989f6a97 Mon Sep 17 00:00:00 2001 From: czoido Date: Wed, 9 Oct 2024 12:35:27 +0200 Subject: [PATCH 2/2] empty commit