Beispiel #1
0
 def loadBundleItem(cls, path, namespace, bundle, manager):
     info = os.path.join(path, cls.FILE)
     projectFilePaths = glob(os.path.join(path, '*'))
     projectFilePaths.remove(info)
     try:
         data = plist.readPlist(info)
         uuid = manager.uuidgen(data.pop('uuid', None))
         project = manager.getManagedObject(uuid)
         if project is None and not manager.isDeleted(uuid):
             project = cls(uuid, data)
             project.setBundle(bundle)
             project.setManager(manager)
             project.addSource(namespace, path)
             project = manager.addBundleItem(project)
             manager.addManagedObject(project)
             #Add files
             for projectFilePath in projectFilePaths:
                 projectFile = PMXTemplateFile(projectFilePath, project)
                 projectFile = manager.addTemplateFile(projectFile)
                 project.files.append(projectFile)
         elif project is not None:
             project.addSource(namespace, path)
         return project
     except Exception, e:
         print "Error in project %s (%s)" % (info, e)
Beispiel #2
0
 def test_readPlist(self):
     for plistPath in self.plist_files:
         with open(plistPath) as plistFile:
             content = plistFile.read()
             data = plist.readPlist(plistPath)
             print(plist.writePlistToString(data))
             self.assertEqual(content, plist.writePlistToString(data))
Beispiel #3
0
 def loadBundleItem(cls, path, namespace, bundle, manager):
     info = os.path.join(path, cls.FILE)
     templateFilePaths = glob(os.path.join(path, '*'))
     templateFilePaths.remove(info)
     try:
         data = plist.readPlist(info)
         uuid = manager.uuidgen(data.pop('uuid', None))
         template = manager.getManagedObject(uuid)
         if template is None and not manager.isDeleted(uuid):
             template = cls(uuid, data)
             template.setBundle(bundle)
             template.setManager(manager)
             template.addSource(namespace, path)
             template = manager.addBundleItem(template)
             manager.addManagedObject(template)
             #Add files
             for templateFilePath in templateFilePaths:
                 templateFile = PMXTemplateFile(templateFilePath, template)
                 templateFile = manager.addTemplateFile(templateFile)
                 template.files.append(templateFile)
         elif template is not None:
             template.addSource(namespace, path)
         return template
     except Exception, e:
         print "Error in template %s (%s)" % (info, e)
Beispiel #4
0
 def loadBundleItem(cls, path, namespace, bundle, manager):
     info = os.path.join(path, cls.FILE)
     projectFilePaths = glob(os.path.join(path, '*'))
     projectFilePaths.remove(info)
     try:
         data = plist.readPlist(info)
         uuid = manager.uuidgen(data.pop('uuid', None))
         project = manager.getManagedObject(uuid)
         if project is None and not manager.isDeleted(uuid):
             project = cls(uuid, data)
             project.setBundle(bundle)
             project.setManager(manager)
             project.addSource(namespace, path)
             project = manager.addBundleItem(project)
             manager.addManagedObject(project)
             #Add files
             for projectFilePath in projectFilePaths:
                 projectFile = PMXTemplateFile(projectFilePath, project)
                 projectFile = manager.addTemplateFile(projectFile)
                 project.files.append(projectFile)
         elif project is not None:
             project.addSource(namespace, path)
         return project
     except Exception, e:
         print "Error in project %s (%s)" % (info, e)
Beispiel #5
0
 def loadBundleItem(cls, path, namespace, bundle, manager):
     info = os.path.join(path, cls.FILE)
     templateFilePaths = glob(os.path.join(path, '*'))
     templateFilePaths.remove(info)
     try:
         data = plist.readPlist(info)
         uuid = manager.uuidgen(data.pop('uuid', None))
         template = manager.getManagedObject(uuid)
         if template is None and not manager.isDeleted(uuid):
             template = cls(uuid, data)
             template.setBundle(bundle)
             template.setManager(manager)
             template.addSource(namespace, path)
             template = manager.addBundleItem(template)
             manager.addManagedObject(template)
             #Add files
             for templateFilePath in templateFilePaths:
                 templateFile = PMXTemplateFile(templateFilePath, template)
                 templateFile = manager.addTemplateFile(templateFile)
                 template.files.append(templateFile)
         elif template is not None:
             template.addSource(namespace, path)
         return template
     except Exception, e:
         print "Error in template %s (%s)" % (info, e)
Beispiel #6
0
    def __init__(self, file):
        self.file = file

        if os.path.exists(self.file):
            try:
                self.settings = plist.readPlist(self.file)
            except Exception as e:
                print(("Exception raised while reading settings file: %s" % e))

        not hasattr(self, "settings") and self.initializeSettings()
Beispiel #7
0
 def reloadBundleItem(cls, bundleItem, path, namespace, manager):
     map(lambda style: manager.removeTemplateFile(style), bundleItem.files)
     info = os.path.join(path, cls.FILE)
     projectFilePaths = glob(os.path.join(path, '*'))
     projectFilePaths.remove(info)
     data = plist.readPlist(info)
     bundleItem.load(data)
     #Add files
     for projectFilePath in projectFilePaths:
         projectFile = PMXTemplateFile(projectFilePath, bundleItem)
         projectFile = manager.addTemplateFile(projectFile)
         project.files.append(projectFile)
Beispiel #8
0
 def reloadTheme(cls, theme, path, namespace, manager):
     #Remove all styles
     map(lambda style: manager.removeThemeStyle(style), theme.styles)
     data = plist.readPlist(path)
     theme.load(data)
     settings = data.pop('settings', [])
     if settings:
         self.setSettings(settings[0].settings)
     for setting in settings[1:]:
         style = PMXThemeStyle(setting, theme)
         style = manager.addThemeStyle(style)
         self.styles.append(style)
Beispiel #9
0
 def reloadBundleItem(cls, bundleItem, path, namespace, manager):
     map(lambda style: manager.removeTemplateFile(style), bundleItem.files)
     info = os.path.join(path, cls.FILE)
     projectFilePaths = glob(os.path.join(path, '*'))
     projectFilePaths.remove(info)
     data = plist.readPlist(info)
     bundleItem.load(data)
     #Add files
     for projectFilePath in projectFilePaths:
         projectFile = PMXTemplateFile(projectFilePath, bundleItem)
         projectFile = manager.addTemplateFile(projectFile)
         project.files.append(projectFile)
Beispiel #10
0
 def reloadTheme(cls, theme, path, namespace, manager):
     #Remove all styles
     map(lambda style: manager.removeThemeStyle(style), theme.styles)
     data = plist.readPlist(path)
     theme.load(data)
     settings = data.pop('settings', [])
     if settings:
         self.setSettings(settings[0].settings)
     for setting in settings[1:]:
         style = PMXThemeStyle(setting, theme)
         style = manager.addThemeStyle(style)
         self.styles.append(style)
Beispiel #11
0
 def loadProject(cls, path, manager):
     projectPath = os.path.join(path, config.PMX_HOME_NAME)
     fileInfo = os.path.join(projectPath, config.PMX_DESCRIPTOR_NAME)
     if not os.path.isfile(fileInfo):
         raise exceptions.FileNotExistsException(fileInfo)
     try:
         data = plist.readPlist(fileInfo)
         project = cls(path, data)
         manager.addProject(project)
         return project
     except Exception as e:
         import traceback
         traceback.print_exc()
         print("Error in project %s (%s)" % (path, e))
Beispiel #12
0
 def loadProject(cls, path, manager):
     projectPath = os.path.join(path, cls.FOLDER)
     fileInfo = os.path.join(projectPath, cls.FILE)
     if not os.path.isfile(fileInfo):
         raise exceptions.FileNotExistsException(fileInfo)
     try:
         data = plist.readPlist(fileInfo)
         project = cls(path, data)
         manager.addProject(project)
         return project
     except Exception, e:
         import traceback
         traceback.print_exc()
         print "Error in project %s (%s)" % (path, e)
Beispiel #13
0
 def loadProject(cls, path, manager):
     projectPath = os.path.join(path, cls.FOLDER)
     fileInfo = os.path.join(projectPath, cls.FILE)
     if not os.path.isfile(fileInfo):
         raise exceptions.FileNotExistsException(fileInfo)
     try:
         data = plist.readPlist(fileInfo)
         project = cls(path, data)
         manager.addProject(project)
         return project
     except Exception, e:
         import traceback
         traceback.print_exc()
         print "Error in project %s (%s)" % (path, e)
Beispiel #14
0
 def loadBundleItem(cls, path, namespace, bundle, manager):
     try:
         data = plist.readPlist(path)
         uuid = manager.uuidgen(data.pop('uuid', None))
         item = manager.getManagedObject(uuid)
         if item is None and not manager.isDeleted(uuid):
             item = cls(uuid, data)
             item.setBundle(bundle)
             item.setManager(manager)
             item.addSource(namespace, path)
             item = manager.addBundleItem(item)
             manager.addManagedObject(item)
         elif item is not None:
             item.addSource(namespace, path)
         return item
     except Exception, e:
         print "Error in bundle item %s (%s)" % (path, e)
Beispiel #15
0
 def loadBundle(cls, path, namespace, manager):
     info_file = os.path.join(path, cls.FILE)
     try:
         data = plist.readPlist(info_file)
         uuid = manager.uuidgen(data.pop('uuid', None))
         bundle = manager.getManagedObject(uuid)
         if bundle is None and not manager.isDeleted(uuid):
             bundle = cls(uuid, data)
             bundle.setManager(manager)
             bundle.addSource(namespace, path)
             bundle = manager.addBundle(bundle)
             manager.addManagedObject(bundle)
         elif bundle is not None:
             bundle.addSource(namespace, path)
         return bundle
     except Exception, e:
         print "Error in laod bundle %s (%s)" % (info_file, e)
Beispiel #16
0
 def loadProject(cls, path, manager):
     projectPath = os.path.join(path, cls.FOLDER)
     fileInfo = os.path.join(projectPath, cls.FILE)
     if not os.path.isfile(fileInfo):
         raise exceptions.FileNotExistsException(fileInfo)
     try:
         data = plist.readPlist(fileInfo)
         project = cls(path, data)
         if os.path.exists(os.path.join(projectPath, cls.SUPPORT)):
             project.ensureSupport()
         if os.path.exists(os.path.join(projectPath, cls.BUNDLES)):
             project.ensureBundles()
         if os.path.exists(os.path.join(projectPath, cls.THEMES)):
             project.ensureThemes()
         manager.addProject(project)
         return project
     except Exception, e:
         print "Error in project %s (%s)" % (filePath, e)
Beispiel #17
0
 def loadTheme(cls, path, namespace, manager):
     try:
         data = plist.readPlist(path)
         uuid = manager.uuidgen(data.pop('uuid', None))
         theme = manager.getManagedObject(uuid)
         if theme is None and not manager.isDeleted(uuid):
             theme = PMXTheme(uuid, data)
             theme.setManager(manager)
             theme.addSource(namespace, path)
             theme = manager.addTheme(theme)
             settings = data.pop('settings', [])
             if settings:
                 theme.setSettings(settings[0].settings)
             for setting in settings[1:]:
                 style = PMXThemeStyle(setting, theme)
                 style = manager.addThemeStyle(style)
                 theme.styles.append(style)
             manager.addManagedObject(theme)
         elif theme is not None:
             theme.addSource(namespace, path)
         return theme
     except Exception, e:
         print "Error en theme %s (%s)" % (path, e)
Beispiel #18
0
#!/usr/bin/env python
#-*- encoding: utf-8 -*-

import os
import os, sys
sys.path.append(os.path.abspath('../..'))

from PyQt4 import QtCore, QtGui
from prymatex.utils.plist import readPlist
from pprint import pprint

if __name__ == "__main__":
    pprint(readPlist("untitled.tmproj.txt"))
Beispiel #19
0
 def readPlist(self, path):
     if path in self.plistFileCache:
         return self.plistFileCache.get(path)
     return self.plistFileCache.setdefault(path, plist.readPlist(path))
Beispiel #20
0
 def reloadBundleItem(cls, bundleItem, path, namespace, manager):
     data = plist.readPlist(path)
     bundleItem.load(data)
Beispiel #21
0
 def reloadBundle(cls, bundle, path, namespace, manager):
     info_file = os.path.join(path, cls.FILE)
     data = plist.readPlist(info_file)
     bundle.load(data)
Beispiel #22
0
 def readPlist(path):
     return plist.readPlist(path)
Beispiel #23
0
 def get_data(path):
     return plist.readPlist(path) or {}