Skip to content

Commit

Permalink
Support star import
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed May 16, 2018
1 parent ffa8c57 commit ee0994c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion julia/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#-----------------------------------------------------------------------------

# Stdlib
from __future__ import print_function
from __future__ import print_function, absolute_import
import ctypes
import ctypes.util
import os
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/_star_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from julia.Base.REPL import *
4 changes: 4 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ee0994c

Please sign in to comment.