Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77eb4ba2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "releasetools: Switch from imp to importlib.util" into main

parents 6fa780a9 0157cd3e
Loading
Loading
Loading
Loading
+11 −10
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ import fnmatch
import getopt
import getopt
import getpass
import getpass
import gzip
import gzip
import imp
import importlib.util
import json
import json
import logging
import logging
import logging.config
import logging.config
@@ -3132,16 +3132,17 @@ class DeviceSpecificParams(object):
        return
        return
      try:
      try:
        if os.path.isdir(path):
        if os.path.isdir(path):
          info = imp.find_module("releasetools", [path])
          path = os.path.join(path, "releasetools")
        else:
          if os.path.isdir(path):
          d, f = os.path.split(path)
            path = os.path.join(path, "__init__.py")
          b, x = os.path.splitext(f)
        if not os.path.exists(path) and os.path.exists(path + ".py"):
          if x == ".py":
          path = path + ".py"
            f = b
        spec = importlib.util.spec_from_file_location("device_specific", path)
          info = imp.find_module(f, [d])
        logger.info("loaded device-specific extensions from %s", path)
        logger.info("loaded device-specific extensions from %s", path)
        self.module = imp.load_module("device_specific", *info)
        module = importlib.util.module_from_spec(spec)
      except ImportError:
        spec.loader.exec_module(module)
        self.module = module
      except (ImportError, FileNotFoundError):
        logger.info("unable to load device-specific module; assuming none")
        logger.info("unable to load device-specific module; assuming none")


  def _DoCall(self, function_name, *args, **kwargs):
  def _DoCall(self, function_name, *args, **kwargs):