parameters: (self, name = None, url = None, path = None, pkg_type = "plugin", data = None)
docstring: Read json file of a plugin and make an object from it
              @param name : name of package
              @param url : url of file
              @param path : path of file
              @param pkg_type : package type (default : 'plugin')
                            To use only with name != None
              @param data : json data as a python object. Used by package.py when installing a zip file : the json is read from memory
docstring_summary: Read json file of a plugin and make an object from it
docstring_tokens: Read json file of a plugin and make an object from it
function: def __init__(self, name = None, url = None, path = None, pkg_type = "plugin", data = None):
          """ Read json file of a plugin and make an object from it
              @param name : name of package
              @param url : url of file
              @param path : path of file
              @param pkg_type : package type (default : 'plugin')
                            To use only with name != None
              @param data : json data as a python object. Used by package.py when installing a zip file : the json is read from memory
          """
          json_file = None
          try:
              # get config
              cfg = Loader('domogik')
              config = cfg.load()
              conf = dict(config[1])
              self.resources_dir = "{0}/resources".format(conf['libraries_path'])
              # load from sources repository
              if name != None:
  
                  if pkg_type in ["plugin", "brain", "interface"]:
                      json_file = "{0}/{1}/{2}_{3}/info.json".format(conf['libraries_path'], PACKAGES_DIR, pkg_type, name)
                      icon_file = "{0}/{1}/{2}_{3}/design/icon.png".format(conf['libraries_path'], PACKAGES_DIR, pkg_type, name)
                  # TODO : reactivate later
                  #elif pkg_type == "external":
                  #    if 'package_path' in conf:
                  #        json_directory = "%s/domogik_packages/externals/" % (conf['package_path'])
                  #    else:
                  #        json_directory = "%s/%s" % (conf['src_prefix'], "share/domogik/externals/")
                  else:
                      raise PackageException("Type '{0}' doesn't exists".format(pkg_type))
                  #json_file = "{0}/{1}.json".format(json_directory, name)
  
                  self.json = json.load(open(json_file))
              elif path != None:
                  json_file = path
                  icon_file = None
                  self.json = json.load(open(json_file))
  
              elif url != None:
                  json_file = url
                  icon_file = None
                  json_data = urlopen(json_file)
                  # TODO : there is an error here!!!!!
                  self.json = json.load(xml_data)
  
              elif data != None:
                  json_file = None
                  icon_file = None
                  self.json = data
  
              json_file = "{0}/datatypes.json".format(self.resources_dir)
              self._datatypes = None
              try:
                  self._datatypes = json.load(open(json_file))
              except:
                  raise PackageException("Error while reading datatypes json file '{0}'. Error is : {1}".format(json_file, traceback.format_exc()))
  
              self.validate()
  
              ### complete json
              # identity data
              self.json["identity"]["package_id"] = "{0}-{1}".format(self.json["identity"]["type"],
                                                             self.json["identity"]["name"])
              self.json["identity"]["icon_file"] = icon_file
  
              if not self.json["identity"].has_key("xpl_clients_only"):
                  self.json["identity"]["xpl_clients_only"] = False
  
              if not self.json["identity"].has_key("compliant_xpl_clients"):
                  self.json["identity"]["compliant_xpl_clients"] = []
  
              # common configuration items
              # to add only for a plugin with identity>xpl_clients_only not set to True !
              if self.json["identity"]["type"] in ["plugin", "interface"] and not (self.json["identity"].has_key("xpl_clients_only") and self.json["identity"]["xpl_clients_only"] == True):
                  auto_startup = {
                                     "default": False,
                                     "description": "Automatically start the client at Domogik startup",
                                     "key": "auto_startup",
                                     "name" : "Start the client with Domogik",
                                     "required": True,
                                     "type": "boolean"
                                 }
                  # check that auto_startup key is not already defined in the json
                  for config_elt in self.json["configuration"]:
                      if config_elt["key"] == "auto_startup":
                          raise PackageException("Configuration parameter 'auto_startup' has not to be defined in the json file. Please remove it")
                  self.json["configuration"].insert(0, auto_startup)
                    
  
  
          except PackageException as exp:
              raise PackageException(exp.value)
          except:
              raise PackageException("Error reading json file : {0} : {1}".format(json_file, str(traceback.format_exc())))
function_tokens: def __init__ ( self , name = None , url = None , path = None , pkg_type = "plugin" , data = None ) : json_file = None try : # get config cfg = Loader ( 'domogik' ) config = cfg . load ( ) conf = dict ( config [ 1 ] ) self . resources_dir = "{0}/resources" . format ( conf [ 'libraries_path' ] ) # load from sources repository if name != None : if pkg_type in [ "plugin" , "brain" , "interface" ] : json_file = "{0}/{1}/{2}_{3}/info.json" . format ( conf [ 'libraries_path' ] , PACKAGES_DIR , pkg_type , name ) icon_file = "{0}/{1}/{2}_{3}/design/icon.png" . format ( conf [ 'libraries_path' ] , PACKAGES_DIR , pkg_type , name ) # TODO : reactivate later #elif pkg_type == "external": #    if 'package_path' in conf: #        json_directory = "%s/domogik_packages/externals/" % (conf['package_path']) #    else: #        json_directory = "%s/%s" % (conf['src_prefix'], "share/domogik/externals/") else : raise PackageException ( "Type '{0}' doesn't exists" . format ( pkg_type ) ) #json_file = "{0}/{1}.json".format(json_directory, name) self . json = json . load ( open ( json_file ) ) elif path != None : json_file = path icon_file = None self . json = json . load ( open ( json_file ) ) elif url != None : json_file = url icon_file = None json_data = urlopen ( json_file ) # TODO : there is an error here!!!!! self . json = json . load ( xml_data ) elif data != None : json_file = None icon_file = None self . json = data json_file = "{0}/datatypes.json" . format ( self . resources_dir ) self . _datatypes = None try : self . _datatypes = json . load ( open ( json_file ) ) except : raise PackageException ( "Error while reading datatypes json file '{0}'. Error is : {1}" . format ( json_file , traceback . format_exc ( ) ) ) self . validate ( ) ### complete json # identity data self . json [ "identity" ] [ "package_id" ] = "{0}-{1}" . format ( self . json [ "identity" ] [ "type" ] , self . json [ "identity" ] [ "name" ] ) self . json [ "identity" ] [ "icon_file" ] = icon_file if not self . json [ "identity" ] . has_key ( "xpl_clients_only" ) : self . json [ "identity" ] [ "xpl_clients_only" ] = False if not self . json [ "identity" ] . has_key ( "compliant_xpl_clients" ) : self . json [ "identity" ] [ "compliant_xpl_clients" ] = [ ] # common configuration items # to add only for a plugin with identity>xpl_clients_only not set to True ! if self . json [ "identity" ] [ "type" ] in [ "plugin" , "interface" ] and not ( self . json [ "identity" ] . has_key ( "xpl_clients_only" ) and self . json [ "identity" ] [ "xpl_clients_only" ] == True ) : auto_startup = { "default" : False , "description" : "Automatically start the client at Domogik startup" , "key" : "auto_startup" , "name" : "Start the client with Domogik" , "required" : True , "type" : "boolean" } # check that auto_startup key is not already defined in the json for config_elt in self . json [ "configuration" ] : if config_elt [ "key" ] == "auto_startup" : raise PackageException ( "Configuration parameter 'auto_startup' has not to be defined in the json file. Please remove it" ) self . json [ "configuration" ] . insert ( 0 , auto_startup ) except PackageException as exp : raise PackageException ( exp . value ) except : raise PackageException ( "Error reading json file : {0} : {1}" . format ( json_file , str ( traceback . format_exc ( ) ) ) )