def _importAccount(self, joeyAccountDirName, accountXmlFileName): ravenAccountDirName = self._getRavenAccountDirName(joeyAccountDirName) ravenAccountXmlName = os.path.join(ravenAccountDirName, u"account.xml") #$NON-NLS-1$ os.makedirs(ravenAccountDirName) # Copy over any icons that have been downloaded (or any other resource). fileutil.copyFiles(joeyAccountDirName, ravenAccountDirName) dom = ZDom() dom.load(accountXmlFileName) newDom = dom.transformToXML(self.accountTransformFilename) newDom.setNamespaceMap(ACCOUNT_NSS_MAP) # Encrypt the account password. passwordNode = newDom.selectSingleNode(u"/zns:account/zns:attributes/zns:attribute[@name = 'password']") #$NON-NLS-1$ if passwordNode: password = crypt.encryptPlainText(passwordNode.getText(), PASSWORD_ENCRYPTION_KEY) passwordNode.setText(password) # convert host, port & path combo to a single url attribute; also determine the raven publisher site/type. self._convertApiInfo(newDom) # account id accId = newDom.documentElement.getAttribute(u"account-id") #$NON-NLS-1$ self.validAccounts[accId] = True # convert blog and id format to raven format blogNodeList = newDom.selectNodes(u"/zns:account/zns:blogs/zns:blog") #$NON-NLS-1$ for blogNode in blogNodeList: self._convertAccBlogInfo(accId, blogNode) # Save to disk. newDom.save(ravenAccountXmlName, True) del dom del newDom
def _copyAspellDirToTemp(self, spellingDir): osutil = getOSUtil() tempDir = osutil.getSystemTempDirectory() if not os.path.isdir(tempDir): raise ZException(u"System temp directory not found.") #$NON-NLS-1$ tempSpellingDir = os.path.join(tempDir, u"_RavenSpellcheck_tmp") #$NON-NLS-1$ if not os.path.exists(tempSpellingDir): os.mkdir(tempSpellingDir) copyFiles(spellingDir, tempSpellingDir) return tempSpellingDir