code: def handle_deprecated_settings(settings):
      """Converts deprecated settings and issues warnings. Issues an exception
      if both old and new setting is specified.
      """
  
      # PLUGIN_PATH -> PLUGIN_PATHS
      if "PLUGIN_PATH" in settings:
          logger.warning(
              "PLUGIN_PATH setting has been replaced by "
              "PLUGIN_PATHS, moving it to the new setting name."
          )
          settings["PLUGIN_PATHS"] = settings["PLUGIN_PATH"]
          del settings["PLUGIN_PATH"]
  
      # PLUGIN_PATHS: str -> [str]
      if isinstance(settings.get("PLUGIN_PATHS"), str):
          logger.warning(
              "Defining PLUGIN_PATHS setting as string "
              "has been deprecated (should be a list)"
          )
          settings["PLUGIN_PATHS"] = [settings["PLUGIN_PATHS"]]
  
      # JINJA_EXTENSIONS -> JINJA_ENVIRONMENT > extensions
      if "JINJA_EXTENSIONS" in settings:
          logger.warning(
              "JINJA_EXTENSIONS setting has been deprecated, "
              "moving it to JINJA_ENVIRONMENT setting."
          )
          settings["JINJA_ENVIRONMENT"]["extensions"] = settings[
              "JINJA_EXTENSIONS"
          ]
          del settings["JINJA_EXTENSIONS"]
  
      # {ARTICLE,PAGE}_DIR -> {ARTICLE,PAGE}_PATHS
      for key in ["ARTICLE", "PAGE"]:
          old_key = key + "_DIR"
          new_key = key + "_PATHS"
          if old_key in settings:
              logger.warning(
                  "Deprecated setting %s, moving it to %s list",
                  old_key,
                  new_key,
              )
              settings[new_key] = [
                  settings[old_key]
              ]  # also make a list
              del settings[old_key]
  
      # EXTRA_TEMPLATES_PATHS -> THEME_TEMPLATES_OVERRIDES
      if "EXTRA_TEMPLATES_PATHS" in settings:
          logger.warning(
              "EXTRA_TEMPLATES_PATHS is deprecated use "
              "THEME_TEMPLATES_OVERRIDES instead."
          )
          if (
              "THEME_TEMPLATES_OVERRIDES" in settings
              and settings["THEME_TEMPLATES_OVERRIDES"]
          ):
              raise Exception(
                  "Setting both EXTRA_TEMPLATES_PATHS and "
                  "THEME_TEMPLATES_OVERRIDES is not permitted. Please move to "
                  "only setting THEME_TEMPLATES_OVERRIDES."
              )
          settings["THEME_TEMPLATES_OVERRIDES"] = settings[
              "EXTRA_TEMPLATES_PATHS"
          ]
          del settings["EXTRA_TEMPLATES_PATHS"]
  
      # MD_EXTENSIONS -> MARKDOWN
      if "MD_EXTENSIONS" in settings:
          logger.warning(
              "MD_EXTENSIONS is deprecated use MARKDOWN "
              "instead. Falling back to the default."
          )
          settings["MARKDOWN"] = DEFAULT_CONFIG["MARKDOWN"]
  
      # LESS_GENERATOR -> Webassets plugin
      # FILES_TO_COPY -> STATIC_PATHS, EXTRA_PATH_METADATA
      for old, new, doc in [
          ("LESS_GENERATOR", "the Webassets plugin", None),
          (
              "FILES_TO_COPY",
              "STATIC_PATHS and EXTRA_PATH_METADATA",
              "https://github.com/getpelican/pelican/"
              "blob/master/docs/settings.rst#path-metadata",
          ),
      ]:
          if old in settings:
              message = f"The {old} setting has been removed in favor of {new}"
              if doc:
                  message += f", see {doc} for details"
              logger.warning(message)
  
      # PAGINATED_DIRECT_TEMPLATES -> PAGINATED_TEMPLATES
      if "PAGINATED_DIRECT_TEMPLATES" in settings:
          message = (
              "The {} setting has been removed in favor of {}".format(
                  "PAGINATED_DIRECT_TEMPLATES", "PAGINATED_TEMPLATES"
              )
          )
          logger.warning(message)
  
          # set PAGINATED_TEMPLATES
          if "PAGINATED_TEMPLATES" not in settings:
              settings["PAGINATED_TEMPLATES"] = {
                  "tag": None,
                  "category": None,
                  "author": None,
              }
  
          for t in settings["PAGINATED_DIRECT_TEMPLATES"]:
              if t not in settings["PAGINATED_TEMPLATES"]:
                  settings["PAGINATED_TEMPLATES"][t] = None
          del settings["PAGINATED_DIRECT_TEMPLATES"]
  
      # {SLUG,CATEGORY,TAG,AUTHOR}_SUBSTITUTIONS ->
      # {SLUG,CATEGORY,TAG,AUTHOR}_REGEX_SUBSTITUTIONS
      url_settings_url = "http://docs.getpelican.com/en/latest/settings.html#url-settings"
      flavours = {"SLUG", "CATEGORY", "TAG", "AUTHOR"}
      old_values = {
          f: settings[f + "_SUBSTITUTIONS"]
          for f in flavours
          if f + "_SUBSTITUTIONS" in settings
      }
      new_values = {
          f: settings[f + "_REGEX_SUBSTITUTIONS"]
          for f in flavours
          if f + "_REGEX_SUBSTITUTIONS" in settings
      }
      if old_values and new_values:
          raise Exception(
              "Setting both {new_key} and {old_key} (or variants thereof) is "
              "not permitted. Please move to only setting {new_key}.".format(
                  old_key="SLUG_SUBSTITUTIONS",
                  new_key="SLUG_REGEX_SUBSTITUTIONS",
              )
          )
      if old_values:
          message = (
              "{} and variants thereof are deprecated and will be "
              "removed in the future. Please use {} and variants thereof "
              "instead. Check {}.".format(
                  "SLUG_SUBSTITUTIONS",
                  "SLUG_REGEX_SUBSTITUTIONS",
                  url_settings_url,
              )
          )
          logger.warning(message)
          if old_values.get("SLUG"):
              for f in {"CATEGORY", "TAG"}:
                  if old_values.get(f):
                      old_values[f] = old_values["SLUG"] + old_values[f]
              old_values["AUTHOR"] = old_values.get("AUTHOR", [])
          for f in flavours:
              if old_values.get(f) is not None:
                  regex_subs = []
                  # by default will replace non-alphanum characters
                  replace = True
                  for tpl in old_values[f]:
                      try:
                          src, dst, skip = tpl
                          if skip:
                              replace = False
                      except ValueError:
                          src, dst = tpl
                      regex_subs.append(
                          (re.escape(src), dst.replace("\\", r"\\"))
                      )
  
                  if replace:
                      regex_subs += [
                          (r"[^\w\s-]", ""),
                          (r"(?u)\A\s*", ""),
                          (r"(?u)\s*\Z", ""),
                          (r"[-\s]+", "-"),
                      ]
                  else:
                      regex_subs += [
                          (r"(?u)\A\s*", ""),
                          (r"(?u)\s*\Z", ""),
                      ]
                  settings[f + "_REGEX_SUBSTITUTIONS"] = regex_subs
              settings.pop(f + "_SUBSTITUTIONS", None)
  
      # `%s` -> '{slug}` or `{lang}` in FEED settings
      for key in ["TRANSLATION_FEED_ATOM", "TRANSLATION_FEED_RSS"]:
          if (
              settings.get(key)
              and not isinstance(settings[key], Path)
              and "%s" in settings[key]
          ):
              logger.warning(
                  "%%s usage in %s is deprecated, use {lang} "
                  "instead.",
                  key,
              )
              try:
                  settings[key] = _printf_s_to_format_field(
                      settings[key], "lang"
                  )
              except ValueError:
                  logger.warning(
                      "Failed to convert %%s to {lang} for %s. "
                      "Falling back to default.",
                      key,
                  )
                  settings[key] = DEFAULT_CONFIG[key]
      for key in [
          "AUTHOR_FEED_ATOM",
          "AUTHOR_FEED_RSS",
          "CATEGORY_FEED_ATOM",
          "CATEGORY_FEED_RSS",
          "TAG_FEED_ATOM",
          "TAG_FEED_RSS",
      ]:
          if (
              settings.get(key)
              and not isinstance(settings[key], Path)
              and "%s" in settings[key]
          ):
              logger.warning(
                  "%%s usage in %s is deprecated, use {slug} "
                  "instead.",
                  key,
              )
              try:
                  settings[key] = _printf_s_to_format_field(
                      settings[key], "slug"
                  )
              except ValueError:
                  logger.warning(
                      "Failed to convert %%s to {slug} for %s. "
                      "Falling back to default.",
                      key,
                  )
                  settings[key] = DEFAULT_CONFIG[key]
  
      # CLEAN_URLS
      if settings.get("CLEAN_URLS", False):
          logger.warning(
              "Found deprecated `CLEAN_URLS` in settings."
              " Modifying the following settings for the"
              " same behaviour."
          )
  
          settings["ARTICLE_URL"] = "{slug}/"
          settings["ARTICLE_LANG_URL"] = "{slug}-{lang}/"
          settings["PAGE_URL"] = "pages/{slug}/"
          settings["PAGE_LANG_URL"] = "pages/{slug}-{lang}/"
  
          for setting in (
              "ARTICLE_URL",
              "ARTICLE_LANG_URL",
              "PAGE_URL",
              "PAGE_LANG_URL",
          ):
              logger.warning("%s = '%s'", setting, settings[setting])
  
      # AUTORELOAD_IGNORE_CACHE -> --ignore-cache
      if settings.get("AUTORELOAD_IGNORE_CACHE"):
          logger.warning(
              "Found deprecated `AUTORELOAD_IGNORE_CACHE` in "
              "settings. Use --ignore-cache instead."
          )
          settings.pop("AUTORELOAD_IGNORE_CACHE")
  
      # ARTICLE_PERMALINK_STRUCTURE
      if settings.get("ARTICLE_PERMALINK_STRUCTURE", False):
          logger.warning(
              "Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in"
              " settings.  Modifying the following settings for"
              " the same behaviour."
          )
  
          structure = settings["ARTICLE_PERMALINK_STRUCTURE"]
  
          # Convert %(variable) into {variable}.
          structure = re.sub(r"%\((\w+)\)s", r"{\g<1>}", structure)
  
          # Convert %x into {date:%x} for strftime
          structure = re.sub(r"(%[A-z])", r"{date:\g<1>}", structure)
  
          # Strip a / prefix
          structure = re.sub("^/", "", structure)
  
          for setting in (
              "ARTICLE_URL",
              "ARTICLE_LANG_URL",
              "PAGE_URL",
              "PAGE_LANG_URL",
              "DRAFT_URL",
              "DRAFT_LANG_URL",
              "ARTICLE_SAVE_AS",
              "ARTICLE_LANG_SAVE_AS",
              "DRAFT_SAVE_AS",
              "DRAFT_LANG_SAVE_AS",
              "PAGE_SAVE_AS",
              "PAGE_LANG_SAVE_AS",
          ):
              settings[setting] = os.path.join(
                  structure, settings[setting]
              )
              logger.warning("%s = '%s'", setting, settings[setting])
  
      # {,TAG,CATEGORY,TRANSLATION}_FEED -> {,TAG,CATEGORY,TRANSLATION}_FEED_ATOM
      for new, old in [
          ("FEED", "FEED_ATOM"),
          ("TAG_FEED", "TAG_FEED_ATOM"),
          ("CATEGORY_FEED", "CATEGORY_FEED_ATOM"),
          ("TRANSLATION_FEED", "TRANSLATION_FEED_ATOM"),
      ]:
          if settings.get(new, False):
              logger.warning(
                  "Found deprecated `%(new)s` in settings. Modify %(new)s "
                  "to %(old)s in your settings and theme for the same "
                  "behavior. Temporarily setting %(old)s for backwards "
                  "compatibility.",
                  {"new": new, "old": old},
              )
              settings[old] = settings[new]
  
      # Warn if removed WRITE_SELECTED is present
      if "WRITE_SELECTED" in settings:
          logger.warning(
              "WRITE_SELECTED is present in settings but this functionality was removed. "
              "It will have no effect."
          )
  
      return settings
  
file_path: pelican/pelican/settings.py
imports: import copy
  import importlib.util
  import inspect
  import locale
  import logging
  import os
  import re
  import sys
  from os.path import isabs
  from pathlib import Path
  from pelican.log import LimitFilter
label_desc: Use image node_id 7 for calling a global function with example usage: handle_deprecated_settings(settings) and returns: settings