当前位置: 首页>>代码示例>>Python>>正文


Python FileUtils.readFromFile方法代码示例

本文整理汇总了Python中FileUtils.readFromFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.readFromFile方法的具体用法?Python FileUtils.readFromFile怎么用?Python FileUtils.readFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtils的用法示例。


在下文中一共展示了FileUtils.readFromFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: restoreBackUp

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
def restoreBackUp(_settingType="All", _isMakeBackUp=True):
    files = []
    isSuccessfully = True
    if _settingType == "database" or _settingType == "All":
        files.append("database.sqlite")
    if _settingType == "Settings" or _settingType == "All":
        files.append(uni.fileOfSettings)
    for backupFile in files:
        oldInfo = ""
        if _isMakeBackUp:
            oldInfo = fu.readFromFile(fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
        else:
            try:
                fu.removeFile(fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
            except: pass
        try:
            if fu.isFile(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile)):
                fu.moveFileOrDir(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile),
                                 fu.joinPath(fu.pathOfSettingsDirectory, backupFile))
            else:
                isSuccessfully = False
        except: pass
        if _isMakeBackUp:
            fu.writeToFile(fu.joinPath(fu.pathOfSettingsDirectory, "BackUps", backupFile), oldInfo)
    return isSuccessfully
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:27,代码来源:Settings.py

示例2: getReadOnlyPID

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
def getReadOnlyPID():
    global isReadOnlyStarted
    if fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/mysqld.pid"):
        isReadOnlyStarted = True
        return fu.readFromFile(fu.pathOfSettingsDirectory + "/Amarok/mysqld.pid").split("\n")[0]
    isReadOnlyStarted = False
    return None
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:9,代码来源:__init__.py

示例3: getPID

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
def getPID():
    global isStarted
    if fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid"):
        isStarted = True
        return fu.readFromFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid").split("\n")[0]
    isStarted = False
    return None
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:9,代码来源:__init__.py

示例4: setSourceToSearch

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(pathToSearch, -1, "return", "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:Searcher.py

示例5: read

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
def read(_recordFilePath=None):
    if _recordFilePath is None:
        _recordFilePath = fu.recordFilePath
    if fu.isFile(_recordFilePath):
        return fu.readFromFile(_recordFilePath, "utf-8")
    else:
        create()
        setRecordType(1)
        fu.addToFile(_recordFilePath, recordContents)
        restoreRecordType()
        return recordContents
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:13,代码来源:Records.py

示例6: createPage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
 def createPage(self, _pageNo):
     pnlPage = MWidget()
     HBox = MHBoxLayout()
     pnlPage.setLayout(HBox)
     if _pageNo == 0:
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode)):
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode), "utf-8")
         else:
             aboutFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_en_GB"), "utf-8")
         lblAbout = MLabel(str(aboutFileContent))
         lblAbout.setWordWrap(True)
         HBox.addWidget(lblAbout)
     elif _pageNo == 1:
         if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode)):
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode), "utf-8")
         else:
             licenceFileContent = fu.readFromFile(
                 fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_en_GB"), "utf-8")
         teCopying = MTextEdit()
         teCopying.setPlainText(str(licenceFileContent))
         HBox.addWidget(teCopying)
     elif _pageNo == 2:
         lblPleaseSelect = MLabel(translate("Install", "Please Select A Folder For Installation."))
         installationDirPath = Settings.getUniversalSetting("HamsiManagerPath", None)
         if installationDirPath is not None:
             installationDirPath = fu.getDirName(installationDirPath)
         else:
             installationDirPath = fu.joinPath(fu.getDirName(fu.HamsiManagerDirectory), "Hamsi")
         self.leInstallationDirectory = MLineEdit(
             str(Settings.getUniversalSetting("pathOfInstallationDirectory", str(installationDirPath))))
         self.pbtnSelectInstallationDirectory = MPushButton(translate("Install", "Browse"))
         self.connect(self.pbtnSelectInstallationDirectory, SIGNAL("clicked()"),
                      self.selectInstallationDirectory)
         VBox = MVBoxLayout()
         VBox.addStretch(10)
         VBox.addWidget(lblPleaseSelect)
         HBox1 = MHBoxLayout()
         HBox1.addWidget(self.leInstallationDirectory)
         HBox1.addWidget(self.pbtnSelectInstallationDirectory)
         VBox.addLayout(HBox1)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     elif _pageNo == 3:
         VBox = MVBoxLayout()
         self.lblActions = MLabel("")
         self.prgbState = MProgressBar()
         VBox.addWidget(self.lblActions)
         VBox.addWidget(self.prgbState)
         HBox.addLayout(VBox)
     elif _pageNo == 4:
         VBox = MVBoxLayout()
         self.lblFinished = MLabel(translate("Install", "Installation Complete."))
         VBox.addStretch(10)
         VBox.addWidget(self.lblFinished)
         VBox.addStretch(2)
         self.isCreateDesktopShortcut = None
         self.isCreateExecutableLink = None
         if uni.isRunningAsRoot():
             self.isCreateExecutableLink = MCheckBox(translate("Install", "Add To The System"))
             self.isCreateExecutableLink.setCheckState(Mt.Checked)
             lblExecutableLink = MLabel(translate("Install", "Executable Link Path : "))
             self.leExecutableLink = MLineEdit(
                 str(Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")))
             self.connect(self.isCreateExecutableLink, SIGNAL("stateChanged(int)"),
                          self.createExecutableLinkChanged)
             VBox.addWidget(self.isCreateExecutableLink)
             HBox1 = MHBoxLayout()
             HBox1.addWidget(lblExecutableLink)
             HBox1.addWidget(self.leExecutableLink)
             VBox.addLayout(HBox1)
         else:
             self.isCreateDesktopShortcut = MCheckBox(translate("Install", "Create Desktop Shortcut."))
             self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
             VBox.addWidget(self.isCreateDesktopShortcut)
         VBox.addStretch(10)
         HBox.addLayout(VBox)
     return pnlPage
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:82,代码来源:install.py

示例7: reConfigureFile

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
def reConfigureFile(_filePath, _installationDirectory=fu.HamsiManagerDirectory, _executeCommandOfHamsiManager=None):
    fileContent = getConfiguredContent(fu.readFromFile(_filePath), _executeCommandOfHamsiManager)
    fileContent = fileContent.replace(fu.HamsiManagerDirectory, _installationDirectory)
    fu.writeToFile(_filePath, fileContent)
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:6,代码来源:MyConfigure.py

示例8: setup

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
    base=exeBase,
    targetName="hamsi" + fileExtension,
    compress=True,
    copyDependentFiles=False,
    appendScriptToExe=False,
    appendScriptToLibrary=False,
    icon=os.path.join(HamsiManagerDirectory, "Themes/Default/Images/hamsi" + iconExtension),
    shortcutName="Hamsi Manager",
    shortcutDir="ProgramMenuFolder"
)

setup(
    name="HamsiManager",
    version=uni.version,
    description="Hamsi Manager is a file manager which was developed for extra operations.",
    long_description=fu.readFromFile(os.path.join(HamsiManagerDirectory, "Languages/About_en_GB"), "utf-8"),
    author="Murat Demir",
    author_email="[email protected]",
    maintainer="Murat Demir",
    maintainer_email="[email protected]",
    url="http://hamsiapps.com/Hamsi-Manager",
    download_url="http://sourceforge.net/projects/hamsimanager/files/",
    license="GPLv3",
    options={"build_exe": {"includes": includes,
                           "excludes": excludes,
                           "packages": packages,
                           "path": path,
                           "include_files": include_files,
    }
    },
    executables=[MainExe],
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:setup.py

示例9: createPage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
    def createPage(self, _pageNo):
        pnlPage = MWidget()
        HBox = MHBoxLayout()
        pnlPage.setLayout(HBox)
        defaultLangCode = uni.getDefaultLanguageCode()
        if _pageNo == 0:
            if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode)):
                aboutFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + defaultLangCode), "utf-8")
            else:
                aboutFileContent = fu.readFromFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_en_GB"),
                                                   "utf-8")
            lblAbout = MLabel(str(aboutFileContent))
            lblAbout.setWordWrap(True)
            HBox.addWidget(lblAbout)
        elif _pageNo == 1:
            if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode)):
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + defaultLangCode), "utf-8")
            else:
                licenceFileContent = fu.readFromFile(
                    fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_en_GB"), "utf-8")
            teCopying = MTextEdit()
            teCopying.setPlainText(str(licenceFileContent))
            HBox.addWidget(teCopying)
        elif _pageNo == 2:
            VBox = MVBoxLayout()
            VBox.addStretch(10)
            self.isCreateDesktopShortcut = None
            self.isCreateExecutableLink = None
            self.wAvailableModules = MWidget(self)
            VBox.addWidget(self.wAvailableModules)
            self.vblAvailableModules = MVBoxLayout()
            self.checkAvailableModules()
            VBox.addStretch(1)
            if uni.isRunningAsRoot():
                self.isCreateExecutableLink = MCheckBox(translate("Reconfigure", "Add To The System"))
                self.isCreateExecutableLink.setCheckState(Mt.Checked)
                lblExecutableLink = MLabel(translate("Reconfigure", "Executable Link Path : "))
                self.leExecutableLink = MLineEdit(
                    str(Settings.getUniversalSetting("HamsiManagerExecutableLinkPath", "/usr/bin/hamsi")))
                self.connect(self.isCreateExecutableLink, SIGNAL("stateChanged(int)"), self.createExecutableLinkChanged)
                VBox.addWidget(self.isCreateExecutableLink)
                HBox1 = MHBoxLayout()
                HBox1.addWidget(lblExecutableLink)
                HBox1.addWidget(self.leExecutableLink, 10)
                VBox.addLayout(HBox1)
            else:
                self.isCreateDesktopShortcut = MCheckBox(translate("Reconfigure", "Create Desktop Shortcut."))
                self.isCreateDesktopShortcut.setCheckState(Mt.Checked)
                VBox.addWidget(self.isCreateDesktopShortcut)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        elif _pageNo == 3:
            import MyPlugins

            VBox = MVBoxLayout()
            VBox.addStretch(10)
            wPlugins = MyPlugins.MyPluginsForSystem(self)
            HBox.addWidget(wPlugins)
            VBox.addStretch(10)
            HBox.addLayout(VBox)
        return pnlPage
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:65,代码来源:Configurator.py

示例10: ki18n

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readFromFile [as 别名]
 Settings.checkSettings()
 uni.printForDevelopers("Before uni.fillMySettings")
 uni.fillMySettings()
 if isActivePyKDE4:
     uni.printForDevelopers("ActivePyKDE4")
     appName = "HamsiManager"
     programName = ki18n("Hamsi Manager")
     version = uni.version
     appLicense = MAboutData.License_GPL_V3
     appCopyright = ki18n(str("Murat Demir ([email protected])"))
     kde4LangCode = uni.MySettings["language"]
     text = ki18n(str(""))
     homePage = str("hamsiapps.com")
     bugEmail = str("Murat Demir ([email protected])")
     if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + kde4LangCode)):
         aboutFileContent = fu.readFromFile(
             fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_" + kde4LangCode), "utf-8")
     else:
         aboutFileContent = fu.readFromFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "About_en_GB"),
                                            "utf-8")
     description = ki18n(str(aboutFileContent))
     uni.printForDevelopers("Before MAboutData")
     aboutOfHamsiManager = MAboutData(appName, uni.Catalog, programName, version, description,
                                      appLicense, appCopyright, text, homePage, bugEmail)
     aboutOfHamsiManager.addAuthor(ki18n(str("Murat Demir")), ki18n(str("Project Manager and Developer")),
                                   "[email protected]", "hamsiapps.com")
     aboutOfHamsiManager.setProgramIconName(str(fu.joinPath(fu.themePath, "Images", "hamsi.png")))
     if fu.isFile(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + kde4LangCode)):
         aboutOfHamsiManager.addLicenseTextFile(
             str(fu.joinPath(fu.HamsiManagerDirectory, "Languages", "License_" + kde4LangCode)))
     else:
         aboutOfHamsiManager.addLicenseTextFile(
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:34,代码来源:HamsiManager.py


注:本文中的FileUtils.readFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。