Beispiel #1
0
def register_package(pkg_name: str, languages_dir: str = 'res/lang'):
    """Register language container
    """
    spec = _find_spec(pkg_name)
    if not spec or not spec.loader:
        raise RuntimeError("Package '{}' is not found".format(pkg_name))

    lng_dir = _path.join(_path.dirname(spec.origin), languages_dir)
    if not _path.isdir(lng_dir):
        raise RuntimeError("Language directory '{}' is not found".format(lng_dir))

    if pkg_name in _packages:
        raise _error.PackageAlreadyRegistered("Language package '{}' already registered".format(pkg_name))
    _packages[pkg_name] = {'__path': lng_dir}
Beispiel #2
0
def is_importable_path(path, with_ext=None):
    """
    Does ``path`` point to a module which can be imported?

    Should be called from inside a ``FiguraImportContext``.

    :param path: a python import path
    """
    try:
        module_spec = _find_spec(path)
    except (ImportError, AttributeError):
        module_spec = None
    if module_spec is None:
        return False
    if with_ext is not None:
        filepath = module_spec.origin
        if not filepath.endswith('.' + with_ext):
            return False
    return True
Beispiel #3
0
__email__ = "*****@*****.**"
__version__ = "0.2.4"

_MODULE_PATH: _Path = _Path(__file__).parent.absolute()

_OPTIONAL_DEPENDENCIES: _Set[str] = {
    "bs4",
    "IPython",
    "matplotlib",
    "pandas",
    "bokeh",
    "plotly",
    "weasyprint",
}

_INSTALLED_MODULES: _Set[str] = {
    x.name
    for x in [_find_spec(dep) for dep in _OPTIONAL_DEPENDENCIES] if x
}

from esparto._content import (
    DataFramePd,
    FigureBokeh,
    FigureMpl,
    FigurePlotly,
    Image,
    Markdown,
)
from esparto._layout import Column, Page, Row, Section
from esparto._options import options
Beispiel #4
0
                      "\nPlease install PyOpenGL(>=3,<4) for OpenGL functionality.")


from ._internals import get_version, import_all_extras
print("Expyriment {0} ".format(get_version()))


# Check if local 'test.py{c|o}' shadows 'test' package of standard library
try:
    from importlib.util import find_spec as _find_spec
    # TODO: previously used 'imp' module is deprecated
    # TODO: new method only works with Python 3.4+, but requirements are
    # TODO: currently 3.3+. What to do?

    for _package in ["test"]:
        if _find_spec(_package).submodule_search_locations is None:
            _m = "Warning: '{0}.py' is shadowing package '{1}'!"
            print(_m.format(_package, _package))
except:
    pass

from . import _internals
from . import design
from . import misc
from . import stimuli
from . import io
from . import control

if not misc.is_android_running():
    from ._api_reference_tool import show_documentation
Beispiel #5
0
def pip_package_exists(name) -> bool:
    if _find_spec(name):
        return True
    else:
        return False
Beispiel #6
0
def find_spec(name, path):
	print(_find_spec(name, path))
	return _find_spec(name, path)
Beispiel #7
0
The docstring examples assume that `numpy` has been imported as `np`::
  >>> import lind as ld
Code snippets are indicated by three greater-than signs::
  >>> x = 42
  >>> x = x + 1
Use the built-in ``help`` function to view a function's docstring::
  >>> help(ld.design.design_full_factorial)

For contributors, we have a template docstring at the bottom of this file for
reference. The style is a modified numpy style docstring. We have added sections
for academic references and statistical notes.
"""

from importlib.util import find_spec as _find_spec  # requires python >= 3.3

if _find_spec('rpy2') is not None:
    from lind import r_backends
if _find_spec('lind_static_resources') is not None:
    from lind_static_resources import static_files_abs_path as _sfap
else:
    _sfap = None

from lind import (design, analysis, library)

from ._version import __version__

# example / template docstring based on numpy style
"""
function name

Short description.