# Path: pyilper/userconfig.py
# class cls_userconfig:
# 
#    def __init__(self,progname,filename,configversion,instance,production):
# #
# #  determine config file name
# #
#       self.__configfile__,self.__configpath__=buildconfigfilename(progname,filename,configversion,instance,production)
# 
# #
# #  read configuration, if no configuration exists write default configuration
# #
#    def read(self,default):
#       if not os.path.isfile(self.__configfile__):
#          if not os.path.exists(self.__configpath__):
#             try:
#                os.makedirs(self.__configpath__)
#             except OSError as e:
#                raise ConfigError("Cannot create path for configuration file", e.strerror)
#          try:
#             self.write(default)
#          except OSError as e:
#             raise ConfigError("Cannot write default configuration file", e.strerror)
#          return default
#       f=None
#       try:
#          f= open(self.__configfile__,"r")
#          config= json.load(f)
#       except json.JSONDecodeError as e:
#          add_msg="File: "+self.__configfile__+". Error: "+e.msg+" at line: "+str(e.lineno)
#          raise ConfigError("Cannot decode configuration data",add_msg)
#       except OSError as e:
#          raise ConfigError("Cannot read configuration file", e.strerror)
#       finally:
#          if f is not None:
#             f.close()
# 
#       return config
# #
# #  Store configuration, create file if it does not exist
# #
#    def write(self,config):
#       f=None
#       try:
#          f= open(self.__configfile__,"w")
#          json.dump(config,f,sort_keys=True,indent=3)
#       except json.JSONDecodeError as e:
#          add_msg="File: "+self.__configfile__+". Error: "+e.msg+" at line: "+str(e.lineno)
#          raise ConfigError("Cannot encode configuration data",add_msg)
#       except OSError as e:
#          raise ConfigError("Cannot write to configuration file", e.strerror)
#       finally:
#          if f is not None:
#             f.close()
# 
# class ConfigError(Exception):
#    def __init__(self,msg,add_msg= None):
#       self.msg= msg
#       self.add_msg = add_msg


import copy
from PyQt5 import QtCore, QtGui, QtWidgets
from .userconfig import cls_userconfig, ConfigError
      return [
       ["Black   0.3 mm", 0x00,0x00,0x00,0xff,1.0],
       ["Red     0.3 mm", 0xff,0x00,0x00,0xff,1.0],
       ["Green   0.3 mm", 0x00,0xff,0x00,0xff,1.0],
       ["Blue    0.3 mm", 0x00,0x00,0xff,0xff,1.0],
       ["Yellow  0.3 mm", 0xff,0xff,0x00,0xff,1.0],
       ["Cyan    0.3 mm", 0x00,0xff,0xff,0xff,1.0],
       ["Magenta 0.3 mm", 0xff,0x00,0xff,0xff,1.0],
       ["Black   0.7 mm", 0x00,0x00,0x00,0xff,2.0],
       ["Red     0.7 mm", 0xff,0x00,0x00,0xff,2.0],
       ["Green   0.7 mm", 0x00,0xff,0x00,0xff,2.0],
       ["Blue    0.7 mm", 0x00,0x00,0xff,0xff,2.0],
       ["Yellow  0.7 mm", 0x00,0xff,0xff,0xff,2.0],
       ["Cyan    0.7 mm", 0x00,0xff,0xff,0xff,2.0],
       ["Magenta 0.7 mm", 0xff,0x00,0xff,0xff,2.0], 
       ["Custom1 0.3 mm", 0x00,0x00,0x00,0xff,1.0],
       ["Custom2 0.3 mm", 0x00,0x00,0x00,0xff,1.0]]
   

#
#  open: read in the pen configuration. If the configuration file does not 
#  exist, the default configuration is written to the pen config file
#  If clean is true do not read an existing config file
#
   def open(self,name,configversion,instance,production,clean):
      self.__userconfig__= cls_userconfig(name,"penconfig",configversion,instance,production)
      if clean:
         return
      try:
         self.__penconfig__= self.__userconfig__.read(self.default_config())

# Path: pyilper/userconfig.py
# class cls_userconfig:
# 
#    def __init__(self,progname,filename,configversion,instance,production):
# #
# #  determine config file name
# #
#       self.__configfile__,self.__configpath__=buildconfigfilename(progname,filename,configversion,instance,production)
# 
# #
# #  read configuration, if no configuration exists write default configuration
# #
#    def read(self,default):
#       if not os.path.isfile(self.__configfile__):
#          if not os.path.exists(self.__configpath__):
#             try:
#                os.makedirs(self.__configpath__)
#             except OSError as e:
#                raise ConfigError("Cannot create path for configuration file", e.strerror)
#          try:
#             self.write(default)
#          except OSError as e:
#             raise ConfigError("Cannot write default configuration file", e.strerror)
#          return default
#       f=None
#       try:
#          f= open(self.__configfile__,"r")
#          config= json.load(f)
#       except json.JSONDecodeError as e:
#          add_msg="File: "+self.__configfile__+". Error: "+e.msg+" at line: "+str(e.lineno)
#          raise ConfigError("Cannot decode configuration data",add_msg)
#       except OSError as e:
#          raise ConfigError("Cannot read configuration file", e.strerror)
#       finally:
#          if f is not None:
#             f.close()
# 
#       return config
# #
# #  Store configuration, create file if it does not exist
# #
#    def write(self,config):
#       f=None
#       try:
#          f= open(self.__configfile__,"w")
#          json.dump(config,f,sort_keys=True,indent=3)
#       except json.JSONDecodeError as e:
#          add_msg="File: "+self.__configfile__+". Error: "+e.msg+" at line: "+str(e.lineno)
#          raise ConfigError("Cannot encode configuration data",add_msg)
#       except OSError as e:
#          raise ConfigError("Cannot write to configuration file", e.strerror)
#       finally:
#          if f is not None:
#             f.close()
# 
# class ConfigError(Exception):
#    def __init__(self,msg,add_msg= None):
#       self.msg= msg
#       self.add_msg = add_msg


# Path: pyilper/penconfig.py
import copy
from PyQt5 import QtCore, QtGui, QtWidgets
from .userconfig import cls_userconfig, ConfigError

      return [
       ["Black   0.3 mm", 0x00,0x00,0x00,0xff,1.0],
       ["Red     0.3 mm", 0xff,0x00,0x00,0xff,1.0],
       ["Green   0.3 mm", 0x00,0xff,0x00,0xff,1.0],
       ["Blue    0.3 mm", 0x00,0x00,0xff,0xff,1.0],
       ["Yellow  0.3 mm", 0xff,0xff,0x00,0xff,1.0],
       ["Cyan    0.3 mm", 0x00,0xff,0xff,0xff,1.0],
       ["Magenta 0.3 mm", 0xff,0x00,0xff,0xff,1.0],
       ["Black   0.7 mm", 0x00,0x00,0x00,0xff,2.0],
       ["Red     0.7 mm", 0xff,0x00,0x00,0xff,2.0],
       ["Green   0.7 mm", 0x00,0xff,0x00,0xff,2.0],
       ["Blue    0.7 mm", 0x00,0x00,0xff,0xff,2.0],
       ["Yellow  0.7 mm", 0x00,0xff,0xff,0xff,2.0],
       ["Cyan    0.7 mm", 0x00,0xff,0xff,0xff,2.0],
       ["Magenta 0.7 mm", 0xff,0x00,0xff,0xff,2.0], 
       ["Custom1 0.3 mm", 0x00,0x00,0x00,0xff,1.0],
       ["Custom2 0.3 mm", 0x00,0x00,0x00,0xff,1.0]]
   

#
#  open: read in the pen configuration. If the configuration file does not 
#  exist, the default configuration is written to the pen config file
#  If clean is true do not read an existing config file
#
   def open(self,name,configversion,instance,production,clean):
      self.__userconfig__= cls_userconfig(name,"penconfig",configversion,instance,production)
      if clean:
         return
      try:
         self.__penconfig__= self.__userconfig__.read(self.default_config())

      except ConfigError as e: