Add some comments

This commit is contained in:
oobabooga 2023-02-24 12:41:27 -03:00
parent 3ffd7d36fd
commit ace74a557a

View File

@ -10,16 +10,17 @@ def load_extensions():
for i, name in enumerate(shared.args.extensions): for i, name in enumerate(shared.args.extensions):
if name in available_extensions: if name in available_extensions:
print(f'Loading the extension "{name}"... ', end='') print(f'Loading the extension "{name}"... ', end='')
import_string = f"extensions.{name}.script" exec(f"import extensions.{name}.script")
exec(f"import {import_string}")
state[name] = [True, i] state[name] = [True, i]
print(f'Ok.') print(f'Ok.')
# This iterator returns the extensions in the order specified in the command-line
def iterator(): def iterator():
for name in sorted(state, key=lambda x : state[x][1]): for name in sorted(state, key=lambda x : state[x][1]):
if state[name][0] == True: if state[name][0] == True:
yield eval(f"extensions.{name}.script"), name yield eval(f"extensions.{name}.script"), name
# Extension functions that map string -> string
def apply_extensions(text, typ): def apply_extensions(text, typ):
for extension, _ in iterator(): for extension, _ in iterator():
if typ == "input" and hasattr(extension, "input_modifier"): if typ == "input" and hasattr(extension, "input_modifier"):