Replaced pkg_resources with importlib.resources
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
import pkg_resources
|
||||
from importlib.resources import files as resource_files
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
@@ -23,12 +23,12 @@ class Command(BaseCommand):
|
||||
raise CommandError('Module \'{}\' is already enabled'.format(module_name))
|
||||
|
||||
settings_file_name = 'settings-{}.py'.format(module_name)
|
||||
input_file = os.path.join('django_project_config', settings_file_name)
|
||||
if pkg_resources.resource_exists(module_name, input_file):
|
||||
input_file = resource_files(module_name).joinpath('django_project_config', settings_file_name)
|
||||
if input_file.is_file():
|
||||
output_file = os.path.join(django_base_dir, django_main_module, settings_file_name)
|
||||
if not os.path.exists(output_file):
|
||||
with open(output_file, 'wb') as f:
|
||||
f.write(pkg_resources.resource_string(module_name, input_file))
|
||||
f.write(input_file.read_bytes())
|
||||
|
||||
module_meta_obj = ModuleMeta(module_name)
|
||||
config.modules[module_name] = module_meta_obj
|
||||
|
||||
Reference in New Issue
Block a user