def readSettings(): """ Return the local settings from the location of the SETTING_PATH. :rtype: dict """ return studiolibrary.readJson(SETTINGS_PATH)
def read(self): """ Read the database from disc and return a dict object. :rtype: dict """ return studiolibrary.readJson(self.path())
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)
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
def libraries(self): """ Get all the libraries as a dictionary indexed by name. :rtype: dict """ path = self.settingsPath() data = studiolibrary.readJson(path) return data
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
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)
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
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
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
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
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
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)