From 1426c7066bee83f65a5250811ae35ac8923f0661 Mon Sep 17 00:00:00 2001 From: Mieszko Boczkowski Date: Mon, 9 Dec 2019 11:52:30 +0100 Subject: [PATCH] Move has_occ() function to __init__ --- .../ifcopenshell/geom/__init__.py | 22 ++++++++++++++++++- .../ifcopenshell/geom/main.py | 19 +--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/geom/__init__.py b/src/ifcopenshell-python/ifcopenshell/geom/__init__.py index 8281bf0aca..04db49a6e2 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/__init__.py @@ -21,5 +21,25 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from . import occ_utils as utils +def _has_occ(): + try: + import OCC.Core.BRepTools + return True + except ImportError: + pass + + try: + import OCC.BRepTools + return True + except ImportError: + pass + + return False + + +has_occ = _has_occ() + +if has_occ: + from . import occ_utils as utils + from .main import * diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index 99656ce69b..d3a2161a8f 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -28,24 +28,7 @@ from .. import ifcopenshell_wrapper from ..file import file from ..entity_instance import entity_instance - -def has_occ(): - try: - import OCC.Core.BRepTools - return True - except ImportError: - pass - - try: - import OCC.BRepTools - return True - except ImportError: - pass - - return False - - -has_occ = has_occ() +from . import has_occ def wrap_shape_creation(settings, shape):