예제 #1
0
def readSettings():
    """
    Return the local settings from the location of the SETTING_PATH.

    :rtype: dict
    """
    return studiolibrary.readJson(SETTINGS_PATH)
예제 #2
0
    def read(self):
        """
        Read the database from disc and return a dict object.

        :rtype: dict
        """
        return studiolibrary.readJson(self.path())
예제 #3
0
def readSettings():
    """
    Return the local settings from the location of the SETTING_PATH.

    :rtype: dict
    """
    return studiolibrary.readJson(SETTINGS_PATH)
예제 #4
0
    def readSettings(self):
        """
        Return the local settings from the location of the SETTING_PATH.

        :rtype: dict
        """
        path = studiolibrary.localPath("FormWidget.json")
        return studiolibrary.readJson(path)
예제 #5
0
 def readMetadata(self):
     """
     Read the metadata for the item from disc.
     
     :rtype: dict
     """
     formatString = studiolibrary.config().get('metadataPath')
     path = studiolibrary.formatPath(formatString, self.path())
     metadata = studiolibrary.readJson(path)
     return metadata
예제 #6
0
    def libraries(self):
        """
        Get all the libraries as a dictionary indexed by name.
        
        :rtype: dict 
        """
        path = self.settingsPath()
        data = studiolibrary.readJson(path)

        return data
예제 #7
0
 def readMetadata(self):
     """
     Read the metadata for the item from disc.
     
     :rtype: dict
     """
     formatString = studiolibrary.config().get('metadataPath')
     path = studiolibrary.formatPath(formatString, self.path())
     metadata = studiolibrary.readJson(path)
     return metadata
예제 #8
0
    def read(self):
        """
        Read the database from disc and return a dict object.

        :rtype: dict
        """
        if self.isDirty():
            self._data = studiolibrary.readJson(self.databasePath())
            self.setDirty(False)

        return self._data
예제 #9
0
    def loadSettings(self):
        """
        Read the settings dict from the local json location.

        :rtype: None
        """
        path = self.settingsPath()
        try:
            data = studiolibrary.readJson(path)
            self.setSettings(data)
        except Exception, e:
            logger.exception(e)
예제 #10
0
def read():
    """
    Return the local settings from the location of the SETTING_PATH.

    :rtype: dict
    """
    global _settings

    if not _settings:
        _settings = studiolibrary.readJson(path())

    return _settings
예제 #11
0
    def loadSettings(self):
        """
        Read the settings dict from the local json location.

        :rtype: None
        """
        path = self.settingsPath()
        try:
            data = studiolibrary.readJson(path)
            self.setSettings(data)
        except:
            pass
예제 #12
0
    def read(self):
        """
        Read the database from disc and return a dict object.

        :rtype: dict
        """
        if self.path():
            if self.isDirty():
                self._data = studiolibrary.readJson(self.databasePath())
                self.setDirty(False)
        else:
            logger.info('No path set for reading the data from disc.')

        return self._data
예제 #13
0
    def read(self):
        """
        Read the database from disc and return a dict object.

        :rtype: dict
        """
        if self.path():
            if self.isDirty():
                self._data = studiolibrary.readJson(self.databasePath())
                self.setDirty(False)
        else:
            logger.info('No path set for reading the data from disc.')

        return self._data
예제 #14
0
    def readMetadata(self):
        """
        Read the metadata for the item from disc.
        
        :rtype: dict
        """
        if self._metadata is None:
            formatString = studiolibrary.config.get('metadataPath')
            path = studiolibrary.formatPath(formatString, self.path())

            if os.path.exists(path):
                self._metadata = studiolibrary.readJson(path)
            else:
                self._metadata = {}

        return self._metadata
예제 #15
0
def readSettings():
    """
    Get all the user settings.
    
    :rtype: dict 
    """
    path = settingsPath()

    logger.debug(u'Reading settings from "%s"', path)

    data = {}

    try:
        data = studiolibrary.readJson(path)
    except Exception as error:
        logger.exception('Cannot read settings from "%s"', path)

    return data
예제 #16
0
def readSettings():
    """
    Get all the user settings.
    
    :rtype: dict 
    """
    path = settingsPath()

    logger.debug(u'Reading settings from "%s"', path)

    data = {}

    try:
        data = studiolibrary.readJson(path)
    except Exception as error:
        logger.exception('Cannot read settings from "%s"', path)

    return data
예제 #17
0
def migrateLibraries():
    """
    Migrate all the old libraries to the new 1.21+ library location.

    :rtype: None
    """
    HOME_PATH = os.getenv('APPDATA') or os.getenv('HOME')
    OLD_LIBRARIES_PATH = HOME_PATH + "/StudioLibrary/Library"
    NEW_LIBRARIES_PATH = HOME_PATH + "/StudioLibrary/Libraries"

    if os.path.exists(OLD_LIBRARIES_PATH):
        for filename in os.listdir(OLD_LIBRARIES_PATH):

            libraryName = filename.replace(".dict", "").replace(".json", "")

            oldDictPath = os.path.join(OLD_LIBRARIES_PATH,
                                       libraryName + ".dict")
            oldJsonPath = os.path.join(OLD_LIBRARIES_PATH,
                                       libraryName + ".json")
            migratedPath = os.path.join(OLD_LIBRARIES_PATH,
                                        libraryName + ".migrated")

            newJsonPath = os.path.join(NEW_LIBRARIES_PATH, libraryName,
                                       "library.json")

            if os.path.exists(newJsonPath) or os.path.exists(migratedPath):
                continue

            msg = "Migrating old library: {0} -> {1}..."
            data = None

            if os.path.exists(oldJsonPath):
                msg = msg.format(oldJsonPath, newJsonPath)
                data = studiolibrary.readJson(oldJsonPath)

            elif os.path.exists(oldDictPath):
                msg = msg.format(oldDictPath, newJsonPath)
                data = studiolibrary.readDict(oldJsonPath)

            if data:
                logger.info(msg)
                studiolibrary.saveJson(newJsonPath, data)
                studiolibrary.saveJson(migratedPath, data)