Fix emoticons module import on windows
This commit is contained in:
parent
288b2a3bce
commit
3d8be9ebe2
|
@ -16,6 +16,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import importlib.util as imp
|
import importlib.util as imp
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -58,8 +59,13 @@ class SubPixbuf:
|
||||||
return subpixbuf
|
return subpixbuf
|
||||||
|
|
||||||
def load(path):
|
def load(path):
|
||||||
theme_path = os.path.join(path, 'emoticons_theme.py')
|
module_name = 'emoticons_theme.py'
|
||||||
spec = imp.spec_from_file_location("emoticons_theme.py", theme_path)
|
theme_path = os.path.join(path, module_name)
|
||||||
|
if sys.platform == 'win32' and not os.path.exists(theme_path):
|
||||||
|
module_name = 'emoticons_theme.pyc'
|
||||||
|
theme_path = os.path.join(path, module_name)
|
||||||
|
|
||||||
|
spec = imp.spec_from_file_location(module_name, theme_path)
|
||||||
try:
|
try:
|
||||||
theme = imp.module_from_spec(spec)
|
theme = imp.module_from_spec(spec)
|
||||||
spec.loader.exec_module(theme)
|
spec.loader.exec_module(theme)
|
||||||
|
|
Loading…
Reference in New Issue