def savePrefs(): global DAVOS_PREFS if DAVOS_PREFS: p = pathResolve(r"%USERPROFILE%\davos_prefs.json") jsonWrite(p, DAVOS_PREFS)
def __writeTokenData(self, tokenData): cookieData = {} sCookieFilePath = self.cookieFilePath if os.path.isfile(sCookieFilePath): cookieData = jsonRead(sCookieFilePath) sFieldList = ("username", "token_iat", "token_exp", "token") savedData = dict((f, tokenData[f]) for f in sFieldList) cookieData[self._hashedServerURL()] = savedData return jsonWrite(sCookieFilePath, cookieData)
def writePackContent(sPackDirPath, dirStat=None): sPackDirPath = pathNorm(sPackDirPath) if not dirStat: dirStat = os.stat(sPackDirPath) sJsonPath = mkPackFilePath(sPackDirPath) iMtime = 0 if not osp.exists(sJsonPath): iMtime = dirStat.st_mtime iAtime = dirStat.st_atime try: open(sJsonPath, 'a+b').close() # create json file so it is listed by parseDirContent() dirContent = parseDirContent(sPackDirPath) jsonWrite(sJsonPath, dirContent, sort_keys=True) finally: if iMtime: os.utime(sPackDirPath, (iAtime, iMtime)) return dirContent
def save(self, sFilePath): exportDct = dict((k, v) for (k, v) in vars(self).iteritems() if k in ("topRefs", "deferredRefs", "loadedRefs")) jsonWrite(sFilePath, exportDct)
def logIn(self, sLogin, sPassword, **kwargs): userData = {"login":sLogin} jsonWrite(self.cookieFilePath, userData) return userData