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


Python FileSystem.isfile方法代码示例

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


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

示例1: UserSettings

# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import isfile [as 别名]
class UserSettings():
    def __init__(self, fileName=None, fileSystem=None):
        if fileSystem is not None:
            self.fileSystem = FileSystem()
        self._settingsVariables = dict()
        if fileName is not None:
            self.setFile(fileName)

    def set(self, variable, value):
        self._settingsVariables[variable] = value
        settingsNewContent = json.dumps(self._settingsVariables)

        return self.fileSystem.replaceFile(self.fileName, settingsNewContent)
    
    def get(self, variableName):
        return self._settingsVariables[variableName]

    def deleteAll(self):
        self.fileSystem.remove(self.fileName)

    def setFile(self, fileName):
        self.fileName = fileName
        userSettingsExist = self.fileSystem.isfile(fileName)
        if userSettingsExist != True:
            settingsContent = "{\n}"
            created = self.fileSystem.createFile(fileName, settingsContent)
        else:
            settingsContent = self.fileSystem.getFileContent(self.fileName)
        self._settingsVariables = json.loads(settingsContent)
开发者ID:anconaesselmann,项目名称:LiveUnit,代码行数:31,代码来源:UserSettings.py

示例2: UserSettingsSetter

# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import isfile [as 别名]
class UserSettingsSetter():
    def __init__(self, window, fileName, userInput, userInputCaption):
        self.window = window
        self.fileSystem = FileSystem()
        self.fileName = fileName
        self.userInput = userInput
        self.userInputCaption = userInputCaption
        self.callback = None

        self.setUserSettings()

    def setCallbackWhenFinished(self, callback):
        self.callback = callback
    
    def setUserSettings(self):
        self.userSettings = UserSettings(self.fileName, self.fileSystem)
        userSettingsExist = self.fileSystem.isfile(self.fileName)

        self.userInputResponse = []
        self.currentInput = 0
        if userSettingsExist == True:
            self.captureInput(self.userInputCaption[self.currentInput], "")
        else:
            print("Error trying to write to " + self.fileName)

    def captureInput(self, caption, initial):
        if self.currentInput != None:
            self.inputPanelView = self.window.show_input_panel(
                caption, initial,
                self.settingEntered, self.settingEnteringChange, self.settingEnteringAbort
            )
            self.inputPanelView.set_name("InputPanel")
            self.inputPanelView.settings().set("caret_style", "solid")
            pass

    def settingEntered(self, command_string):
        self.userInputResponse.append(command_string)
        self.currentInput += 1
        if self.currentInput < len(self.userInput):
            self.captureInput(self.userInputCaption[self.currentInput], "")
        else:
            for x in range(0,len(self.userInput)):
                if len(self.userInputResponse[x]) > 0:
                    self.userSettings.set(self.userInput[x], self.userInputResponse[x])
            view = self.window.active_view()
            view.erase_status("InputPanel")

            if self.callback is not None:
                sublime.set_timeout(lambda: self.callback(), 100)

    def settingEnteringChange(self, command_string):
        view = self.window.active_view()
        view.set_status("InputPanel", command_string)

    def settingEnteringAbort(self):
        self.userSettings.deleteAll()
        view = self.window.active_view()
        view.erase_status("InputPanel")
开发者ID:anconaesselmann,项目名称:LiveUnit,代码行数:60,代码来源:UserSettingsSetter.py


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