OpenEnergyPlatform / omi

Repository for the Open Metadata Integration (OMI). For metadata definition see metadata repo:
https://github.com/OpenEnergyPlatform/metadata
GNU Affero General Public License v3.0
7 stars 4 forks source link

Import fails when local folders have the same name as dialects #22

Closed wingechr closed 4 years ago

wingechr commented 4 years ago

Steps to reproduce:

Result:

ModuleNotFoundError: No module named 'omi.dialects.base.test'

Reason:

the __import__ function gets confused because it searches in __path__ as well as the local path.

Solution:

Maybe do the dynamic import manually, for instance by replacing code in in dialects/__init__.py:

import os

from omi.dialects.base.register import get_dialect
path = os.path.dirname(__file__)
for d in os.listdir(path):
    if os.path.isfile(os.path.join(path, d, 'dialect.py')):
        module_name = 'omi.dialects.' + d + '.dialect'
        __import__(module_name)
MGlauer commented 4 years ago

This should have been fixed in 2e3fb99 but is not in the current release