Skip to content
Snippets Groups Projects
Commit 6eab6f6a authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[python] move to common/ subdir

parent e5e1a1d2
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,3 @@
# ~~~
add_subdirectory(common)
dune_pybindxi_add_module(_common EXCLUDE_FROM_ALL bindings.cc)
dune_pybindxi_add_module(_empty EXCLUDE_FROM_ALL empty.cc)
dune_pybindxi_add_module(_logging EXCLUDE_FROM_ALL logging.cc)
dune_pybindxi_add_module(_timings EXCLUDE_FROM_ALL timings.cc)
......@@ -6,8 +6,11 @@
# or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
# with "runtime exception" (http://www.dune-project.org/license.html)
# Authors:
# René Fritze (2018)
# Tobias Leibner (2018)
#
# do not delete
# René Fritze (2018)
# ~~~
dune_pybindxi_add_module(_common EXCLUDE_FROM_ALL bindings.cc)
dune_pybindxi_add_module(_empty EXCLUDE_FROM_ALL empty.cc)
dune_pybindxi_add_module(_logging EXCLUDE_FROM_ALL logging.cc)
dune_pybindxi_add_module(_timings EXCLUDE_FROM_ALL timings.cc)
......@@ -12,13 +12,33 @@
from importlib import import_module
# This is here on purpose, needs to be imported as early as possible!
try:
from mpi4py import MPI
except ImportError:
pass
import dune.xt
from dune.xt._common import *
init_logger = dune.xt._common._init_logger
test_logger = dune.xt._common._test_logger
init_mpi = dune.xt._common._init_mpi
\ No newline at end of file
# empty is missing here on purpose!
_modules = (
'_common',
'_logging',
'_timings',
)
# see https://stackoverflow.com/questions/43059267/how-to-do-from-module-import-using-importlib
for mod_name in _modules:
try:
mod = import_module('.{}'.format(mod_name), 'dune.xt.common')
if "__all__" in mod.__dict__:
names = mod.__dict__["__all__"]
else:
# otherwise we import all names that don't begin with _
names = [x for x in mod.__dict__ if not x.startswith("_")]
globals().update({k: getattr(mod, k) for k in names})
except ImportError as e:
import os
import logging
if os.environ.get('DXT_PYTHON_DEBUG', False):
raise e
logging.error('dune-xt-common: could not import {} module'.format(mod_name))
File moved
File moved
File moved
File moved
File moved
File moved
# ~~~
# This file is part of the dune-xt-common project:
# https://github.com/dune-community/dune-xt-common
# Copyright 2009-2018 dune-xt-common developers and contributors. All rights reserved.
# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
# with "runtime exception" (http://www.dune-project.org/license.html)
# Authors:
# Felix Schindler (2017)
# René Fritze (2018)
# ~~~
from importlib import import_module
try:
from mpi4py import MPI
except ImportError:
pass
import dune.xt
from dune.xt._empty import *
......@@ -19,7 +19,7 @@ def test_load_all():
def test_empty():
from dune.xt.empty import Dog, Pet, Terrier
from dune.xt.common._empty import Dog, Pet, Terrier
dog = Dog('Susi')
pet = Pet('Bello')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment