python类ok_cancel_dialog()的实例源码

imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def prompt_for_node_js_path(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_NODE_JS_PATH): return
        AnfNewProject(self.window, STR_NODE_JS_PATH, self.on_node_js_path_provided).run("/")
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def prompt_for_builder_cli_path(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_BUILDER_CLI_PATH): return
        AnfNewProject(self.window, STR_BUILDER_CLI_PATH, self.on_builder_cli_path_provided).run("/")
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def prompt_for_build_api_key(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_BUILD_API_KEY): return
        self.window.show_input_panel(STR_BUILD_API_KEY, "", self.on_build_api_key_provided, None, None)
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def select_device(self, need_to_confirm=True):
        model = self.load_this_model()
        if not model:
            sublime.message_dialog(STR_MODEL_NOT_ASSIGNED)
            return

        device_ids = model.get("devices")
        if not device_ids or not len(device_ids):
            sublime.message_dialog(STR_MODEL_HAS_NO_DEVICES)
            return

        if need_to_confirm and not sublime.ok_cancel_dialog(STR_SELECT_DEVICE): return
        (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids)
        self.window.show_quick_panel(device_names, self.on_device_selected)
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def on_project_path_provided(self, path):
        log_debug("Project path specified: " + path)
        # self.__tmp_project_path = path
        if os.path.exists(path):
            if not sublime.ok_cancel_dialog(STR_FOLDER_EXISTS.format(path)):
                return
        self.create_project(path)
        # self.prompt_for_build_api_key()
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def prompt_model_to_remove_device(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_REMOVE_DEVICE): return

        model = self.load_this_model()
        device_ids = model.get("devices") if model else None

        if not device_ids or len(device_ids) == 0:
            sublime.message_dialog(STR_MODEL_NO_DEVICES_TO_REMOVE)
            return

        (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids)
        self.window.show_quick_panel(device_names, self.on_remove_device_selected)
new_project.py 文件源码 项目:CMakeBuilder 作者: rwols 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _on_done_project_dir(self, text):
        self.project_dir = os.path.join(text, self.project_name)
        if os.path.exists(self.project_dir):
            sublime.error_message('The directory "%s" already exists!' % self.project_dir)
            return
        msg = 'The new project location will be "%s".\n\nPress OK to continue...' % (self.project_dir)
        if sublime.ok_cancel_dialog(msg):
            self.window.show_quick_panel([["C", "A project suitable for C"], ["C++", "A project suitable for C++"], ["C and C++", "A project suitable for both C and C++"]], self._on_done_select_project_type)
VUEFormatter.py 文件源码 项目:VUEFormatter 作者: baixuexiyang 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def run_script_on_file(self, temp_file_path):
    try:
      node_path = PluginUtils.get_node_path()
      script_path = PLUGIN_FOLDER + "/scripts/index.js"
      file_path = self.view.file_name()
      cmd = [node_path, script_path, temp_file_path, file_path or "?", USER_FOLDER]
      output = PluginUtils.get_output(cmd)

      # Make sure the correct/expected output is retrieved.
      if output.find(OUTPUT_VALID) != -1:
        return output

      msg = "Command " + '" "'.join(cmd) + " created invalid output."
      print(output)
      raise Exception(msg)

    except:
      # Something bad happened.
      print("Unexpected error({0}): {1}".format(sys.exc_info()[0], sys.exc_info()[1]))

      # Usually, it's just node.js not being found. Try to alleviate the issue.
      msg = "Node.js was not found in the default path. Please specify the location."
      if not sublime.ok_cancel_dialog(msg):
        msg = "You won't be able to use this plugin without specifying the path to node.js."
        sublime.error_message(msg)
      else:
        PluginUtils.open_sublime_settings(self.view.window())
SideBarAPI.py 文件源码 项目:new-file-pro 作者: KevinHoo 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def overwrite(self):
        overwrite = sublime.ok_cancel_dialog("Destination exists", "Delete, and overwrite")
        if overwrite:
            from SideBarEnhancements.send2trash import send2trash
            send2trash(self.path())
            return True
        else:
            return False
RemoteCpp.py 文件源码 项目:RemoteCpp 作者: ruibm 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def run(self, edit):
    view = self.view
    file = STATE.file(self.view.file_name())
    title = 'Delete file:\n\n{0}'.format(file.remote_path())
    if sublime.ok_cancel_dialog(title, 'Delete'):
      log("Deleting the file...")
      cmd_str = 'rm -f {remote_path}'.format(remote_path=file.remote_path())
      ssh_cmd(cmd_str)
      self.view.close()
      STATE.update_list(cwd=s_cwd(view), files_to_rm=[file])
sidebar.py 文件源码 项目:rekit-sublime 作者: supnate 项目源码 文件源码 阅读 52 收藏 0 点赞 0 评论 0
def run(self, paths = []):
    p = get_path(paths)
    rekitRoot = get_rekit_root(p)
    targetName = get_filename_without_ext(p)
    featureName = None
    if is_reducer(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/redux/reducer.test.js' % featureName)
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_reducer_test'
          run_script(p, script, [featureName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
    if is_action(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/redux/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_action_test'
          if is_async_action(p):
            script = 'add_async_action_test';
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)

      return
    elif is_page(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_page_test'
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)

    elif is_feature_component(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_component_test'
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
    elif is_component(p):
      testPath = os.path.join(rekitRoot, 'test/app/components/%s.test.js' % targetName)
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_component_test'
          run_script(p, script, [targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
main.py 文件源码 项目:SalesforceXyTools 作者: exiahuang 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def main_handle(self):

        self.sftype = self.sf.get_sobject(self.picked_name)

        sftypedesc = self.sftype.describe()

        # util.show_in_new_tab(util.get_dto_class(self.picked_name, sftypedesc["fields"], self.is_custom_only))


        sub_folder = AUTO_CODE_DIR
        sfdc_name_map = codecreator.get_sfdc_namespace(self.picked_name)

        is_open = False
        save_path_list = []

        # dto Code
        dto_code, class_name = codecreator.get_dto_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['dto_file']
        save_path = util.save_and_open_in_panel(dto_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # dao Code
        dao_code = codecreator.get_dao_class(self.picked_name, sftypedesc["fields"], self.sf, self.is_custom_only)
        file_name = sfdc_name_map['dao_file']
        save_path = util.save_and_open_in_panel(dao_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # controller code
        controller_code, class_name = codecreator.get_controller_class(self.picked_name)
        file_name = sfdc_name_map['controller_file']
        save_path = util.save_and_open_in_panel(controller_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # visualforce code
        vf_code, class_name = codecreator.get_vf_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['vf_file']
        save_path = util.save_and_open_in_panel(vf_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # list controller code
        list_controller_code, class_name = codecreator.get_list_controller_class(self.picked_name)
        file_name = sfdc_name_map['list_controller_file']
        save_path = util.save_and_open_in_panel(list_controller_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # visualforce code
        list_vf_code, class_name = codecreator.get_list_vf_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['list_vf_file']
        save_path = util.save_and_open_in_panel(list_vf_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # SfdcXyController
        src_code = codecreator.get_sfdcxycontroller()
        file_name = 'SfdcXyController.cls'
        save_path = util.save_and_open_in_panel(src_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        if sublime.ok_cancel_dialog('Create Source Over,Do you want to open the sources? '):
            for save_path in save_path_list:
                util.open_file(save_path)
autoformat.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self, edit: sublime.Edit) -> None:
        if self.data is not None:
            self.replace(edit)
            return

        aggresive_level = get_settings(self.view, 'aggressive', 0)
        if aggresive_level > 0:
            if not sublime.ok_cancel_dialog(
                'You have an aggressive level of {} this may cause '
                'anaconda to change things that you don\'t really want to '
                'change.\n\nAre you sure do you want to continue?'.format(
                    aggresive_level
                )
            ):
                return

        self.code = self.view.substr(sublime.Region(0, self.view.size()))
        settings = {
            'aggressive': aggresive_level,
            'list-fixes': get_settings(self.view, 'list-fixes', False),
            'autoformat_ignore': get_settings(
                self.view, 'autoformat_ignore', []
            ),
            'autoformat_select': get_settings(
                self.view, 'autoformat_select', []
            ),
            'pep8_max_line_length': get_settings(
                self.view, 'pep8_max_line_length', 79
            )
        }
        try:
            messages = {
                'start': 'Autoformatting please wait... ',
                'end': 'Autoformatting done!',
                'fail': 'Autoformatting failed, buffer not changed.',
                'timeout': 'Autoformatting failed, buffer not changed.',
            }
            self.pbar = ProgressBar(messages)
            self.pbar.start()
            self.view.set_read_only(True)

            data = {
                'vid': self.view.id(),
                'code': self.code,
                'method': 'pep8',
                'settings': settings,
                'handler': 'autoformat'
            }
            timeout = get_settings(self.view, 'auto_formatting_timeout', 1)

            callback = Callback(timeout=timeout)
            callback.on(success=self.get_data)
            callback.on(error=self.on_failure)
            callback.on(timeout=self.on_failure)

            Worker().execute(callback, **data)
        except:
            logging.error(traceback.format_exc())
imp_developer.py 文件源码 项目:ElectricImp-Sublime 作者: electricimp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_model_selected(self, index):
        # Selection was canceled, nothing to do here
        if index == -1:
            return

        model_id, model_name = self.__tmp_all_models[index]

        self.__tmp_all_models = None  # We don't need it anymore
        log_debug("Model selected id: " + model_id)

        # Save newly created model to the project settings
        settings = self.load_settings()
        settings[EI_MODEL_ID] = model_id
        settings[EI_MODEL_NAME] = model_name
        self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings)

        # Reset the logs
        self.env.log_manager.reset()

        # Update the Model name in the status bar
        self.update_model_name_in_status(query_model_name=False)

        if not sublime.ok_cancel_dialog(STR_MODEL_CONFIRM_PULLING_MODEL_CODE):
            return

        # Pull the latest code from the Model
        source_dir = self.env.project_manager.get_source_directory_path()
        agent_file = os.path.join(source_dir, PR_AGENT_FILE_NAME)
        device_file = os.path.join(source_dir, PR_DEVICE_FILE_NAME)

        revisions, code = HTTP.get(self.env.project_manager.get_build_api_key(),
                                   PL_BUILD_API_URL_V4 + "models/" + model_id + "/revisions")
        if len(revisions["revisions"]) > 0:
            latest_revision_url = PL_BUILD_API_URL_V4 + "models/" + model_id + "/revisions/" + \
                                  str(revisions["revisions"][0]["version"])
            source, code = HTTP.get(self.env.project_manager.get_build_api_key(), latest_revision_url)
            with open(agent_file, "w", encoding="utf-8") as file:
                file.write(source["revision"]["agent_code"])
            with open(device_file, "w", encoding="utf-8") as file:
                file.write(source["revision"]["device_code"])
        else:
            # Create initial source files
            with open(agent_file, "w", encoding="utf-8") as file:
                file.write(STR_INITIAL_SRC_CONTENT.format("Agent"))
            with open(device_file, "w", encoding="utf-8") as file:
                file.write(STR_INITIAL_SRC_CONTENT.format("Device"))


问题


面经


文章

微信
公众号

扫码关注公众号