예제 #1
0
    def __load(self):
        """
        Carga los estilos desde el directorio de estilos definido en config
        (loads the styles from the directory defined in config)
        """
        styleDir = self._config.stylesDir

        log.debug("loadStyles from %s" % styleDir)
        for subDir in styleDir.dirs():
            style = Style(subDir)
            if style.isValid():
                log.debug(" loading style %s" % style.get_name())
                self.addStyle(style)
                #print style
            else:
                log.debug(" style %s is not valid")
예제 #2
0
    def __load(self):
        """
        Carga los estilos desde el directorio de estilos definido en config
        (loads the styles from the directory defined in config)
        """
        styleDir    = self._config.stylesDir

        log.debug("loadStyles from %s" % styleDir)
        for subDir in styleDir.dirs():
            style = Style(subDir)
            if style.isValid():
                log.debug(" loading style %s" % style.get_name())
                self.addStyle(style)
                #print style
            else:
                log.debug(" style %s is not valid")
예제 #3
0
 def doPropertiesStyle(self, style):
     styleDir        = self.config.stylesDir
     styleProperties = Style(styleDir/style)
     self.properties = styleProperties.renderPropertiesJSON()
     self.action     = 'Properties'
     self.style      = styleProperties.get_name()
예제 #4
0
 def doImportStyle(self, filename):
     """
     Importa un estilo desde un fichero ZIP
     Comprueba si es un estilo valido (contiene content.css), 
         si el directorio no existe (para no machacar)
         y si tiene config.xml que el nombre no exista ya.
     """
     styleDir    = self.config.stylesDir
     log.debug("Import style from %s" % filename)
     filename=filename.decode('utf-8')       
     BaseFile=os.path.basename(filename)
     targetDir=BaseFile[0:-4:]
     absoluteTargetDir=styleDir/targetDir 
     try:
         sourceZip = ZipFile( filename ,  'r')
     except IOError:
         self.alert(_(u'Error'), _(u'File %s does not exist or is not readable.') % filename)
         return None
     if os.path.isdir(absoluteTargetDir):
         self.alert(_(u'Error'), _(u'Style directory already exists: %s') % targetDir)
     else:
         os.mkdir(absoluteTargetDir)
         for name in sourceZip.namelist():
             sourceZip.extract(name, absoluteTargetDir )
         sourceZip.close() 
         style = Style(absoluteTargetDir)
         if style.isValid(): 
             if not self.config.styleStore.addStyle(style):
                 absoluteTargetDir.rmtree()
                 self.alert(_(u'Error'), _(u'The style name already exists: %s') % style.get_name())
             else:         
                 self.alert(_(u'Success'), _(u'Successfully imported style: %s') % style.get_name())  
         else:
             absoluteTargetDir.rmtree()
             self.alert(_(u'Error'), _(u'Incorrect style format (does not include content.css)'))
     self.action = ""
예제 #5
0
 def doPropertiesStyle(self, style):
     styleDir = self.config.stylesDir
     styleProperties = Style(styleDir / style)
     self.properties = styleProperties.renderPropertiesJSON()
     self.action = 'Properties'
     self.style = styleProperties.get_name()
 def doImportStyle(self, filename):
     """
     Importa un estilo desde un fichero ZIP
     Comprueba si es un estilo valido (contiene content.css), 
         si el directorio no existe (para no machacar)
         y si tiene config.xml que el nombre no exista ya.
     """
     styleDir    = self.config.stylesDir
     log.debug("Import style from %s" % filename)
     filename=filename.decode('utf-8')       
     BaseFile=os.path.basename(filename)
     targetDir=BaseFile[0:-4:]
     absoluteTargetDir=styleDir/targetDir 
     try:
         sourceZip = ZipFile( filename ,  'r')
     except IOError:
         self.alert(_(u'Error'), _(u'File %s does not exist or is not readable.') % filename)
         return None
     if os.path.isdir(absoluteTargetDir):
         self.alert(_(u'Error'), _(u'Style directory already exists: %s') % targetDir)
     else:
         os.mkdir(absoluteTargetDir)
         for name in sourceZip.namelist():
             sourceZip.extract(name, absoluteTargetDir )
         sourceZip.close() 
         style = Style(absoluteTargetDir)
         if style.isValid(): 
             if not self.config.styleStore.addStyle(style):
                 absoluteTargetDir.rmtree()
                 self.alert(_(u'Error'), _(u'The style name already exists: %s') % style.get_name())
             else:         
                 self.alert(_(u'Success'), _(u'Successfully imported style: %s') % style.get_name())  
         else:
             absoluteTargetDir.rmtree()
             self.alert(_(u'Error'), _(u'Incorrect style format (does not include content.css)'))
     self.action = ""