Change import statements with try except to enable explicit import of submodules from import to avoid conflicts with parent project.

This commit is contained in:
2025-02-22 17:10:53 +01:00
parent c28286a626
commit 821d314cb6
10 changed files with 56 additions and 19 deletions

Binary file not shown.

View File

@ -6,7 +6,10 @@ import yaml
#root_dir = os.path.abspath(os.curdir)
#sys.path.append(root_dir)
import utils.g5505_utils as utils
try:
from dima.utils import g5505_utils as utils
except ModuleNotFoundError:
import utils.g5505_utils as utils

View File

@ -3,9 +3,13 @@ import sys
#root_dir = os.path.abspath(os.curdir)
#sys.path.append(root_dir)
from instruments.readers.xps_ibw_reader import read_xps_ibw_file_as_dict
from instruments.readers.g5505_text_reader import read_txt_files_as_dict
try:
from dima.instruments.readers.xps_ibw_reader import read_xps_ibw_file_as_dict
from dima.instruments.readers.g5505_text_reader import read_txt_files_as_dict
except ModuleNotFoundError:
from instruments.readers.xps_ibw_reader import read_xps_ibw_file_as_dict
from instruments.readers.g5505_text_reader import read_txt_files_as_dict
file_extensions = ['.ibw','.txt','.dat','.h5','.TXT','.csv','.pkl','.json','.yaml']

View File

@ -8,7 +8,10 @@ import json
#from instruments.readers import set_dima_path as configpath
#configpath.set_dima_path()
from utils import g5505_utils
try:
from dima.utils import g5505_utils as utils
except ModuleNotFoundError:
import utils.g5505_utils as utils
def read_jsonflag_as_dict(path_to_file):