# Path: pyoptools/raytrace/mat_lib/material.py
# def get_material(material):
#     """Search for a material in all the libraries
# 
#     This function search in all the material libraries, and return the
#     first instance found, that matches the name of the material requested.
#     If no material found, returns None
#     Arguments:
# 
#     material
#         String with the material name
#     """
#     for libn, _ in liblist:
#         tdict=globals()[libn]
#         if material in tdict:
#             return tdict[material]
#     print (material, " not found")
#     raise KeyError


import six
import inspect
import pyoptools.raytrace.comp_lib as CL
import numpy as np
from six.moves import configparser as cp
from six.moves import reduce
from os import listdir, walk
from os.path import join, split, isdir, splitext,basename, expanduser
from numpy import sqrt
from pkg_resources import resource_stream, resource_filename, \
                        resource_string,  resource_listdir
from pyoptools.raytrace.mat_lib import get_material
from pyoptools.raytrace.system.system import System
from pyoptools.raytrace.component.component import Component
from struct import Struct

        self.parser=cp.ConfigParser()
        self.parser.read(filename)

        if libname != None:
            globals()[libname]=self
    def get(self, cmp):
        global _av_comp
        assert self.parser.has_section(cmp), "Library error in component %s, type not defined"%(cmp,)
        type=self.parser.get(cmp,"type")

        # Check that the class name is defined in the comp_lib module
        if not type in _av_comp:
            raise TypeError("Component type "+type+" not defined in comp_lib")
        options=self.parser.options(cmp)

        #Create the constructor string
        strobj="CL."+type+"("
        for opt in options:
            #Remove options not needed for the class constructors
            if opt=="type":
                pass
            elif opt=="description":
                pass
            elif opt=="glass_catalogs":
                pass

            #Check if the material exists in the material library and
            elif opt[0:3]=="mat":
                mat=self.parser.get(cmp,opt).upper()

# Path: pyoptools/raytrace/mat_lib/material.py
# def get_material(material):
#     """Search for a material in all the libraries
# 
#     This function search in all the material libraries, and return the
#     first instance found, that matches the name of the material requested.
#     If no material found, returns None
#     Arguments:
# 
#     material
#         String with the material name
#     """
#     for libn, _ in liblist:
#         tdict=globals()[libn]
#         if material in tdict:
#             return tdict[material]
#     print (material, " not found")
#     raise KeyError


# Path: pyoptools/raytrace/library/library.py
import six
import inspect
import pyoptools.raytrace.comp_lib as CL
import numpy as np
from six.moves import configparser as cp
from six.moves import reduce
from os import listdir, walk
from os.path import join, split, isdir, splitext,basename, expanduser
from numpy import sqrt
from pkg_resources import resource_stream, resource_filename, \
                        resource_string,  resource_listdir
from pyoptools.raytrace.mat_lib import get_material
from pyoptools.raytrace.system.system import System
from pyoptools.raytrace.component.component import Component
from struct import Struct


        self.parser=cp.ConfigParser()
        self.parser.read(filename)

        if libname != None:
            globals()[libname]=self
    def get(self, cmp):
        global _av_comp
        assert self.parser.has_section(cmp), "Library error in component %s, type not defined"%(cmp,)
        type=self.parser.get(cmp,"type")

        # Check that the class name is defined in the comp_lib module
        if not type in _av_comp:
            raise TypeError("Component type "+type+" not defined in comp_lib")
        options=self.parser.options(cmp)

        #Create the constructor string
        strobj="CL."+type+"("
        for opt in options:
            #Remove options not needed for the class constructors
            if opt=="type":
                pass
            elif opt=="description":
                pass
            elif opt=="glass_catalogs":
                pass

            #Check if the material exists in the material library and
            elif opt[0:3]=="mat":
                mat=self.parser.get(cmp,opt).upper()

                m=get_material(mat)