From ee0994cfec9c5d4ec955227156be4a277c430e63 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 15 May 2018 13:07:22 -0700 Subject: [PATCH] Support star import --- julia/core.py | 9 ++++++++- test/_star_import.py | 1 + test/test_core.py | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/_star_import.py diff --git a/julia/core.py b/julia/core.py index 8ee84ca1..57b13b07 100644 --- a/julia/core.py +++ b/julia/core.py @@ -14,7 +14,7 @@ #----------------------------------------------------------------------------- # Stdlib -from __future__ import print_function +from __future__ import print_function, absolute_import import ctypes import ctypes.util import os @@ -58,6 +58,13 @@ def __init__(self, loader, *args, **kwargs): self._julia = loader.julia self.__loader__ = loader + @property + def __all__(self): + juliapath = self.__name__.lstrip("julia.") + names = set(self._julia.eval("names({})".format(juliapath))) + names.discard(juliapath.rsplit('.', 1)[-1]) + return list(names) + def __getattr__(self, name): try: return self.__try_getattr(name) diff --git a/test/_star_import.py b/test/_star_import.py new file mode 100644 index 00000000..c8146efb --- /dev/null +++ b/test/_star_import.py @@ -0,0 +1 @@ +from julia.Base.REPL import * diff --git a/test/test_core.py b/test/test_core.py index ab6bc843..cc7d8125 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -84,6 +84,10 @@ def test_import_julia_submodule(self): from julia.Base import REPL assert isinstance(REPL, ModuleType) + def test_star_import_julia_module(self): + from . import _star_import + _star_import.BasicREPL + #TODO: this causes a segfault """ def test_import_julia_modules(self):