From ace74a557a3d6628a2fe9d9378fb89a394e1ebe0 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:41:27 -0300 Subject: [PATCH] Add some comments --- modules/extensions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/extensions.py b/modules/extensions.py index 1c1303fd..b06c5afa 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -10,16 +10,17 @@ def load_extensions(): for i, name in enumerate(shared.args.extensions): if name in available_extensions: print(f'Loading the extension "{name}"... ', end='') - import_string = f"extensions.{name}.script" - exec(f"import {import_string}") + exec(f"import extensions.{name}.script") state[name] = [True, i] print(f'Ok.') +# This iterator returns the extensions in the order specified in the command-line def iterator(): for name in sorted(state, key=lambda x : state[x][1]): if state[name][0] == True: yield eval(f"extensions.{name}.script"), name +# Extension functions that map string -> string def apply_extensions(text, typ): for extension, _ in iterator(): if typ == "input" and hasattr(extension, "input_modifier"):