Skip to content

Commit

Permalink
Merge pull request #48 from doronz88/feature/import-module-expandsuser
Browse files Browse the repository at this point in the history
hilda_client: add `expanduser` to `p.import_module()`
  • Loading branch information
doronz88 authored Mar 4, 2024
2 parents daf1245 + 1650ea0 commit eebc741
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hilda/hilda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,14 @@ def evaluate_expression(self, expression) -> Symbol:

return self.symbol(e.unsigned)

def import_module(self, filename, name=None):
def import_module(self, filename: str, name: Optional[str] = None) -> Any:
"""
Import & reload given python module (intended mainly for external snippets)
:param filename: Python filename to import
:param name: Optional module name, or otherwise use the filename
:return: Python module
"""
filename = os.path.expanduser(filename)
if name is None:
name = os.path.splitext(os.path.basename(filename))[0]
spec = importlib.util.spec_from_file_location(name, filename)
Expand Down

0 comments on commit eebc741

Please sign in to comment.