Skip to content

Commit e2dc1e8

Browse files
committed
Make dynamic imports relative to qiling package
1 parent 8ad4a1c commit e2dc1e8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

qiling/hw/hw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def create(self, label: str, struct: "QlPeripheral"=None, base: int=None) -> "Ql
3131

3232
try:
3333

34-
entity = ql_get_module_function('qiling.hw', struct)(self.ql, label, **kwargs)
34+
entity = ql_get_module_function('.hw', struct)(self.ql, label, **kwargs)
3535
setattr(self, label, entity)
3636
self.entity[label] = entity
3737
self.region[label] = [(lbound + base, rbound + base) for (lbound, rbound) in entity.region]

qiling/os/posix/posix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def load_syscall(self):
231231

232232
if not syscall_hook:
233233
def __get_os_module(osname: str):
234-
return ql_get_module_function(f'qiling.os.{osname.lower()}', 'syscall')
234+
return ql_get_module(f'.os.{osname.lower()}.syscall')
235235

236236
os_syscalls = __get_os_module(self.type.name)
237237
posix_syscalls = __get_os_module('posix')

qiling/os/qnx/syscall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _msg_sendv(ql:Qiling, coid, smsg, sparts, rmsg, rparts, *args, **kw):
198198
type_ = ql.unpack16(sbody[:2])
199199

200200
msg_name = map_msgtype(ql, type_)
201-
_msg_handler = ql_get_module_function(f"qiling.os.qnx", "message")
201+
_msg_handler = ql_get_module_function(f".os.qnx", "message")
202202

203203
if msg_name in dir(_msg_handler):
204204
msg_hook = eval(msg_name)

qiling/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def arch_os_convert(arch: QL_ARCH) -> Optional[QL_OS]:
7171
def ql_get_module_function(module_name: str, function_name: str):
7272

7373
try:
74-
imp_module = importlib.import_module(module_name)
74+
imp_module = importlib.import_module(module_name, 'qiling')
7575
except ModuleNotFoundError:
7676
raise QlErrorModuleNotFound(f'Unable to import module {module_name}')
7777
except KeyError:
@@ -313,15 +313,15 @@ def select_loader(ostype: QL_OS, libcache: bool) -> QlClassInit['QlLoader']:
313313
QL_OS.BLOB : r'blob'
314314
}[ostype]
315315

316-
qlloader_path = f'qiling.loader.{module}'
316+
qlloader_path = f'.loader.{module}'
317317
qlloader_class = f'QlLoader{module.upper()}'
318318

319319
obj = ql_get_module_function(qlloader_path, qlloader_class)
320320

321321
return partial(obj, **kwargs)
322322

323323
def select_component(component_type: str, component_name: str, **kwargs) -> QlClassInit[Any]:
324-
component_path = f'qiling.{component_type}.{component_name}'
324+
component_path = f'.{component_type}.{component_name}'
325325
component_class = f'Ql{component_name.capitalize()}Manager'
326326

327327
obj = ql_get_module_function(component_path, component_class)
@@ -352,7 +352,7 @@ def select_debugger(options: Union[str, bool]) -> Optional[QlClassInit['QlDebugg
352352
else:
353353
raise QlErrorOutput('Debugger not supported')
354354

355-
obj = ql_get_module_function(f'qiling.debugger.{objname}.{objname}', f'Ql{str.capitalize(objname)}')
355+
obj = ql_get_module_function(f'.debugger.{objname}.{objname}', f'Ql{str.capitalize(objname)}')
356356

357357
return partial(obj, **kwargs)
358358

@@ -383,7 +383,7 @@ def select_arch(archtype: QL_ARCH, endian: QL_ENDIAN, thumb: bool) -> QlClassIni
383383
QL_ARCH.RISCV64 : r'riscv64'
384384
}[archtype]
385385

386-
qlarch_path = f'qiling.arch.{module}'
386+
qlarch_path = f'.arch.{module}'
387387
qlarch_class = f'QlArch{archtype.name.upper()}'
388388

389389
obj = ql_get_module_function(qlarch_path, qlarch_class)
@@ -392,7 +392,7 @@ def select_arch(archtype: QL_ARCH, endian: QL_ENDIAN, thumb: bool) -> QlClassIni
392392

393393
def select_os(ostype: QL_OS) -> QlClassInit['QlOs']:
394394
qlos_name = ostype.name
395-
qlos_path = f'qiling.os.{qlos_name.lower()}.{qlos_name.lower()}'
395+
qlos_path = f'.os.{qlos_name.lower()}.{qlos_name.lower()}'
396396
qlos_class = f'QlOs{qlos_name.capitalize()}'
397397

398398
obj = ql_get_module_function(qlos_path, qlos_class)

0 commit comments

Comments
 (0)