Skip to content

Commit

Permalink
changed imp to importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelVRossi committed Oct 7, 2023
1 parent b627270 commit f93b5fb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions derpconf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import logging
from collections import defaultdict
from os.path import join, exists, abspath, dirname, isdir
import imp
import importlib
#import imp

import six
from textwrap import fill
Expand All @@ -23,6 +24,10 @@ class ConfigurationError(RuntimeError):
pass


class Test(object):
pass


class Config(object):
class_defaults = {}
class_group_items = defaultdict(list)
Expand Down Expand Up @@ -94,7 +99,8 @@ def __load_from_path(cls, conf, path):
with open(path) as config_file:
name = 'configuration'
code = config_file.read()
module = imp.new_module(name)
spec = importlib._bootstrap.ModuleSpec(name, None)
module = importlib.util.module_from_spec(spec)

six.exec_(code, module.__dict__)

Expand All @@ -118,7 +124,8 @@ def verify(cls, path):
with open(path) as config_file:
name = 'configuration'
code = config_file.read()
module = imp.new_module(name)
spec = importlib._bootstrap.ModuleSpec(name, None)
module = importlib.util.module_from_spec(spec)

six.exec_(code, module.__dict__)

Expand Down

0 comments on commit f93b5fb

Please sign in to comment.