__init__.py 2.46 KB
"""
guitastro_device_ascomcam.device_ascomcam
-------------------------------------------
.. automodule:: guitastro_device_ascomcam.device_ascomcam
   :members:

"""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

__version__ = "20240702"

import os, sys, pathlib

# --- Get the module name
# __file__ = 'C:\\d\\python\\gestion_packages\\mymodule\\src\\mymodule\\__init__.py'
modulename = pathlib.Path(__file__).parts[-2]

# --- Special for Sphinx in mymodule/docs
path = os.path.abspath(os.path.join(__file__, "..", "..", modulename))
sys.path.append(path) if path not in sys.path else None

# --- Switch on True to update the list of imports
if False:
    import glob, os
    import importlib
    pyfiles = glob.glob(os.path.abspath(os.path.join(__file__, "..", "*.py")))
    files = []
    imps = []
    for pyfile in pyfiles:
        if os.path.basename(pyfile)[0] != "_" and os.path.isfile(pyfile):
            file = os.path.splitext(os.path.basename(pyfile))[0]
            #print(f"{file=}")
            with open(pyfile, "rt") as fid:
                lines = fid.readlines()
            for line in lines:
                # 0123456789
                # class O(
                if len(line) < 8:
                    continue
                if line[0:6] == "class ":
                    k = line.find("(")
                    if k > 6:
                        obj = line[6:k].strip()
                        imp = f"from .{file} import {obj}"
                        imps.append(imp)
            files.append(file)
    #importlib.__import__(modulename, fromlist=files)
    print("="*40)
    for file in files:
        print(f"import {file}")
    print()
    for imp in imps:
        print(f"{imp}")
    print("="*40)
    del pyfiles, pyfile, file, files, os, glob, importlib, fid, lines, line, k, obj, imp, imps

# --- All imports generated by the switch = True
import component_detector_shutter_ascomcam
import component_detector_timer_ascomcam
import component_sensor_detector_ascomcam
import device_ascomcam

from .component_detector_shutter_ascomcam import ComponentDetectorShutterAscomcam
from .component_detector_timer_ascomcam import ComponentDetectorTimerAscomcam
from .component_sensor_detector_ascomcam import ComponentSensorDetectorAscomcamDoAcq
from .component_sensor_detector_ascomcam import ComponentSensorDetectorAscomcam
from .device_ascomcam import Device_Ascomcam