mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
imp. is deprecated, use types.ModuleType instead
Thanks https://stackoverflow.com/a/32175781
This commit is contained in:
parent
dd67c491f3
commit
dc893692fb
1 changed files with 2 additions and 2 deletions
|
|
@ -3,7 +3,6 @@ from collections import OrderedDict
|
||||||
import base64
|
import base64
|
||||||
import click
|
import click
|
||||||
import hashlib
|
import hashlib
|
||||||
import imp
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
@ -11,6 +10,7 @@ import re
|
||||||
import shlex
|
import shlex
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import types
|
||||||
import shutil
|
import shutil
|
||||||
import urllib
|
import urllib
|
||||||
import numbers
|
import numbers
|
||||||
|
|
@ -588,7 +588,7 @@ def link_or_copy_directory(src, dst):
|
||||||
|
|
||||||
def module_from_path(path, name):
|
def module_from_path(path, name):
|
||||||
# Adapted from http://sayspy.blogspot.com/2011/07/how-to-import-module-from-just-file.html
|
# Adapted from http://sayspy.blogspot.com/2011/07/how-to-import-module-from-just-file.html
|
||||||
mod = imp.new_module(name)
|
mod = types.ModuleType(name)
|
||||||
mod.__file__ = path
|
mod.__file__ = path
|
||||||
with open(path, "r") as file:
|
with open(path, "r") as file:
|
||||||
code = compile(file.read(), path, "exec", dont_inherit=True)
|
code = compile(file.read(), path, "exec", dont_inherit=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue