# Path: pyfusion/conf/utils.py
# def kwarg_config_handler(component_type, component_name, **kwargs):
#     for config_var in pyfusion.config.pf_options(component_type, component_name):
#             if not config_var in kwargs.keys():
#                 kwargs[config_var] = pyfusion.config.pf_get(component_type,
#                                                    component_name, config_var)
#     return kwargs
# 
# def import_from_str(string_value):
#     # TODO: make shortcuts for loading from within pyfusion
#     split_val = string_value.split('.')
#     val_module = __import__('.'.join(split_val[:-1]),
#                             globals(), locals(),
#                             [split_val[-1]])
#     return val_module.__dict__[split_val[-1]]
# 
# def get_config_as_dict(component_type, component_name):
#     config_option_list = pyfusion.config.pf_options(component_type, component_name)
#     config_map = lambda x: (x, pyfusion.config.pf_get(component_type, component_name, x))
#     return dict(map(config_map, config_option_list))
# 
# Path: pyfusion/orm/utils.py
# def orm_register():
#     def reg_item(orm_func):
#         pyfusion.orm_manager.add_reg_func(orm_func)
#         return orm_func
#     return reg_item


from pyfusion.conf.utils import kwarg_config_handler, import_from_str, get_config_as_dict
from pyfusion.orm.utils import orm_register
    from sqlalchemy import Table, Column, Integer, String
    from sqlalchemy.orm import mapper
import pyfusion
"""Basic device class"""


class Device(object):
    """Represent a laboratory device.  

    In general, a customised subclass of Device will be used.
    
    Usage: Device(device_name, **kwargs)

    Arguments:
    device_name -- name of device as listed in configuration file, 
       i.e.: [Device:device_name]
    
    Keyword arguments:
    Any setting in the [Device:device_name] section of the
    configuration file can be overridden by supplying a keyword
    argument to here, e.g.: Device(device_name)

    """
    
    def __init__(self, config_name, **kwargs):
        if pyfusion.config.pf_has_section('Device', config_name):

# Path: pyfusion/conf/utils.py
# def kwarg_config_handler(component_type, component_name, **kwargs):
#     for config_var in pyfusion.config.pf_options(component_type, component_name):
#             if not config_var in kwargs.keys():
#                 kwargs[config_var] = pyfusion.config.pf_get(component_type,
#                                                    component_name, config_var)
#     return kwargs
# 
# def import_from_str(string_value):
#     # TODO: make shortcuts for loading from within pyfusion
#     split_val = string_value.split('.')
#     val_module = __import__('.'.join(split_val[:-1]),
#                             globals(), locals(),
#                             [split_val[-1]])
#     return val_module.__dict__[split_val[-1]]
# 
# def get_config_as_dict(component_type, component_name):
#     config_option_list = pyfusion.config.pf_options(component_type, component_name)
#     config_map = lambda x: (x, pyfusion.config.pf_get(component_type, component_name, x))
#     return dict(map(config_map, config_option_list))
# 
# Path: pyfusion/orm/utils.py
# def orm_register():
#     def reg_item(orm_func):
#         pyfusion.orm_manager.add_reg_func(orm_func)
#         return orm_func
#     return reg_item


# Path: pyfusion/devices/base.py
from pyfusion.conf.utils import kwarg_config_handler, import_from_str, get_config_as_dict
from pyfusion.orm.utils import orm_register
    from sqlalchemy import Table, Column, Integer, String
    from sqlalchemy.orm import mapper
import pyfusion

"""Basic device class"""


class Device(object):
    """Represent a laboratory device.  

    In general, a customised subclass of Device will be used.
    
    Usage: Device(device_name, **kwargs)

    Arguments:
    device_name -- name of device as listed in configuration file, 
       i.e.: [Device:device_name]
    
    Keyword arguments:
    Any setting in the [Device:device_name] section of the
    configuration file can be overridden by supplying a keyword
    argument to here, e.g.: Device(device_name)

    """
    
    def __init__(self, config_name, **kwargs):
        if pyfusion.config.pf_has_section('Device', config_name):

            self.__dict__.update(get_config_as_dict('Device', config_name))