INNER CODE UNIT · Python

check_and_replace_config

AbdBarho/stable-diffusion-webui-docker · services/AUTOMATIC1111/config.py:52

def check_and_replace_config(config_file: str, target_file: str = None):
  """Checks given file for invalid values. Replaces those with fallback values (default: overwrites file)."""

  # Get current user config, or empty if file does not exists
  data = json_file_to_dict(config_file) or {}

  # Check and fix output directories
  for k, def_val in DEFAULT_OUTDIRS.items():
    if k not in data:
      data[k] = def_val
    else:
      data[k] = replace_if_invalid(value=data[k], replacement=def_val, pattern=RE_VALID_OUTDIR)

  # Check and fix other default settings
  for k, def_val in DEFAULT_OTHER.items():
    if k not in data:
      data[k] = def_val

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…