# Path: spimagine/config/myconfigparser.py
# class MyConfigParser(SafeConfigParser):
#     def __init__(self, fName=None, defaults={}, create_file = True):
#         SafeConfigParser.__init__(self, defaults)
#         self.dummySection = "dummy"
# 
#         if fName:
#             if create_file and not os.path.exists(fName):
#                 try:
#                     logger.debug("trying to create %s"%fName)
#                     with open(fName,"w") as f:
#                         pass
#                 except Exception as e:
#                     logger.debug("failed to create %s"%fName)
#                     logger.debug(e)
#             self.read(fName)
# 
# 
# 
#     def read(self, fName):
#         try:
#             with open(fName) as f:
#                 if six.PY2:
#                     f = io.StringIO("[%s]\n%s" % (self.dummySection, f.read()))
#                     self.readfp(f)
#                 else:
#                     f = chain(("[%s]"%self.dummySection,), f)
#                     self.read_file(f)
# 
#         except Exception as e:
#             logger.debug(e)
# 
# 
# 
#     def get(self, key, defaultValue=None, **kwargs):
#         try:
#             val = SafeConfigParser.get(self, self.dummySection, key,**kwargs)
#             logger.debug("from config file: %s = %s " % (key, val))
# 
#             return val
#         except Exception as e:
#             logger.debug("%s (%s)" % (e, key))
#             return defaultValue
# 
# Path: spimagine/config/loadcolormaps.py
# def loadcolormaps():
#     cmaps = {}
# 
#     try:
#         basePath = sys._MEIPASS
#     except:
#         basePath = _absPath("../colormaps/")
# 
#     reg = re.compile("cmap_(.*)\.png")
#     for fName in os.listdir(basePath):
#         match = reg.match(fName)
#         if match:
#             try:
#                 cmaps[match.group(1)] = _arrayFromImage(os.path.join(basePath,fName))[0,:,:]
#             except Exception as e:
#                 print(e)
#                 print("could not load %s"%fName)
# 
#     return cmaps


import logging
import os
import platform
from .myconfigparser import MyConfigParser
from .loadcolormaps import loadcolormaps
from gputools import init_device
        from subprocess import check_output
from __future__ import absolute_import
from __future__ import print_function

logger = logging.getLogger(__name__)




__CONFIGFILE__ = os.path.expanduser("~/.spimagine")

config_parser = MyConfigParser(__CONFIGFILE__)

defaults = {
    "id_device": 0,
    "spin_axis" : 1, # x,y,z = 0,1,2
    "id_platform": 0,

# Path: spimagine/config/myconfigparser.py
# class MyConfigParser(SafeConfigParser):
#     def __init__(self, fName=None, defaults={}, create_file = True):
#         SafeConfigParser.__init__(self, defaults)
#         self.dummySection = "dummy"
# 
#         if fName:
#             if create_file and not os.path.exists(fName):
#                 try:
#                     logger.debug("trying to create %s"%fName)
#                     with open(fName,"w") as f:
#                         pass
#                 except Exception as e:
#                     logger.debug("failed to create %s"%fName)
#                     logger.debug(e)
#             self.read(fName)
# 
# 
# 
#     def read(self, fName):
#         try:
#             with open(fName) as f:
#                 if six.PY2:
#                     f = io.StringIO("[%s]\n%s" % (self.dummySection, f.read()))
#                     self.readfp(f)
#                 else:
#                     f = chain(("[%s]"%self.dummySection,), f)
#                     self.read_file(f)
# 
#         except Exception as e:
#             logger.debug(e)
# 
# 
# 
#     def get(self, key, defaultValue=None, **kwargs):
#         try:
#             val = SafeConfigParser.get(self, self.dummySection, key,**kwargs)
#             logger.debug("from config file: %s = %s " % (key, val))
# 
#             return val
#         except Exception as e:
#             logger.debug("%s (%s)" % (e, key))
#             return defaultValue
# 
# Path: spimagine/config/loadcolormaps.py
# def loadcolormaps():
#     cmaps = {}
# 
#     try:
#         basePath = sys._MEIPASS
#     except:
#         basePath = _absPath("../colormaps/")
# 
#     reg = re.compile("cmap_(.*)\.png")
#     for fName in os.listdir(basePath):
#         match = reg.match(fName)
#         if match:
#             try:
#                 cmaps[match.group(1)] = _arrayFromImage(os.path.join(basePath,fName))[0,:,:]
#             except Exception as e:
#                 print(e)
#                 print("could not load %s"%fName)
# 
#     return cmaps


# Path: spimagine/config/config.py
import logging
import os
import platform
from .myconfigparser import MyConfigParser
from .loadcolormaps import loadcolormaps
from gputools import init_device
        from subprocess import check_output

from __future__ import absolute_import
from __future__ import print_function

logger = logging.getLogger(__name__)




__CONFIGFILE__ = os.path.expanduser("~/.spimagine")

config_parser = MyConfigParser(__CONFIGFILE__)

defaults = {
    "id_device": 0,
    "spin_axis" : 1, # x,y,z = 0,1,2
    "id_platform": 0,

    "use_gpu": 1,