當前位置: 首頁>>代碼示例>>Python>>正文


Python FileTools.quote方法代碼示例

本文整理匯總了Python中RuboCop.file_tools.FileTools.quote方法的典型用法代碼示例。如果您正苦於以下問題:Python FileTools.quote方法的具體用法?Python FileTools.quote怎麽用?Python FileTools.quote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RuboCop.file_tools.FileTools的用法示例。


在下文中一共展示了FileTools.quote方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run(self, edit):
    super(RubocopAutoCorrectCommand, self).run(edit)

    cancel_op = self.user_wants_to_cancel()
    if cancel_op:
      return

    view = self.view
    path = view.file_name()
    quoted_file_path = FileTools.quote(path)

    if view.is_read_only():
      sublime.message_dialog('RuboCop: Unable to run auto correction on a read only buffer.')
      return

    # Inform user about unsaved contents of current buffer
    if view.is_dirty():
      warn_msg = 'RuboCop: The curent buffer is modified. Save the file and continue?'
      cancel_op = not sublime.ok_cancel_dialog(warn_msg)

    if cancel_op:
      return
    else:
      view.run_command('save')

    RubocopEventListener.instance().clear_marks(view)

    quoted_file_path = FileTools.quote(path)

    # Run rubocop with auto-correction
    self.runner.run(quoted_file_path, '-a')

    sublime.status_message('RuboCop: Auto correction done.')
開發者ID:ayonkhan,項目名稱:sublime_rubocop,代碼行數:35,代碼來源:rubocop_command.py

示例2: run

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run(self, edit):
    super(RubocopAutoCorrectCommand, self).run(edit)

    cancel_op = self.warning_msg()
    if cancel_op:
      return

    view = self.view
    path = view.file_name()
    quoted_file_path = FileTools.quote(path)

    if view.is_read_only():
      sublime.message_dialog('RuboCop: Unable to run auto correction on a read only buffer.')
      return

    # Inform user about unsaved contents of current buffer
    if view.is_dirty():
      warn_msg = 'RuboCop: The curent buffer is modified. Save the file and continue?'
      cancel_op = not sublime.ok_cancel_dialog(warn_msg)

    if cancel_op:
      return
    else:
      view.run_command('save')

    RubocopEventListener.instance().clear_marks(view)

    # Copy the current file to a temp file
    content = view.substr(sublime.Region(0, view.size()))
    f = tempfile.NamedTemporaryFile()

    try:
      self.write_to_file(f, content, view)
      f.flush()

      # Create path for possible config file in the source directory
      quoted_file_path = FileTools.quote(path)
      config_opt = '-c ' + os.path.dirname(quoted_file_path) + '/.rubocop.yml'
      print(config_opt)

      # Run rubocop with auto-correction on temp file
      self.runner.run(f.name, '-a ' + config_opt)

      # Read contents of file
      f.seek(0)
      content = self.read_from_file(f, view)

      # Overwrite buffer contents
      rgn = sublime.Region(0, view.size())
      view.replace(edit, rgn, content)
    finally:
      # TempFile will be deleted here
      f.close()

    sublime.status_message('RuboCop: Auto correction done.')
開發者ID:Mondego,項目名稱:pyreco,代碼行數:57,代碼來源:allPythonContent.py

示例3: run_rubocop

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run_rubocop(self, view):
    s = sublime.load_settings(SETTINGS_FILE)

    use_rvm = view.settings().get('check_for_rvm', s.get('check_for_rvm'))
    use_rbenv = view.settings().get('check_for_rbenv', s.get('check_for_rbenv'))
    cmd = view.settings().get('rubocop_command', s.get('rubocop_command'))
    rvm_path = view.settings().get('rvm_auto_ruby_path', s.get('rvm_auto_ruby_path'))
    rbenv_path = view.settings().get('rbenv_path', s.get('rbenv_path'))
    cfg_file = view.settings().get('rubocop_config_file', s.get('rubocop_config_file'))
    chdir = view.settings().get('rubocop_chdir', s.get('rubocop_chdir'))

    if cfg_file:
      cfg_file = FileTools.quote(cfg_file)

    runner = RubocopRunner(
      {
        'use_rbenv': use_rbenv,
        'use_rvm': use_rvm,
        'custom_rubocop_cmd': cmd,
        'rvm_auto_ruby_path': rvm_path,
        'rbenv_path': rbenv_path,
        'on_windows': sublime.platform() == 'windows',
        'rubocop_config_file': cfg_file,
        'chdir': chdir,
        'is_st2': sublime.version() < '3000'
      }
    )
    output = runner.run([view.file_name()], ['--format', 'emacs']).splitlines()

    return output
開發者ID:TristinDavis,項目名稱:sublime_rubocop,代碼行數:32,代碼來源:rubocop_listener.py

示例4: run_rubocop_on

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run_rubocop_on(self, path, file_list=False):
    if not path:
      return

    if not file_list:
      # Single item to check.
      quoted_file_path = FileTools.quote(path)
      working_dir = os.path.dirname(path)
    else:
      # Multiple files to check.
      working_dir = '.'
      quoted_file_path = ''
      for file in path:
        quoted_file_path += FileTools.quote(file) + ' '

    rubocop_cmd = self.runner.command_string(
      quoted_file_path, self.used_options()
    )
    self.run_shell_command(rubocop_cmd, working_dir)
開發者ID:ayonkhan,項目名稱:sublime_rubocop,代碼行數:21,代碼來源:rubocop_command.py

示例5: run_rubocop_on

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run_rubocop_on(self, path, file_list=False):
    if not path:
      return

    if not file_list:
      # Single item to check.
      quoted_file_path = FileTools.quote(path)
      working_dir = os.path.dirname(quoted_file_path)
    else:
      # Multiple files to check.
      working_dir = '.'
      quoted_file_path = ''
      for file in path:
        quoted_file_path += FileTools.quote(file) + ' '

    cop_command = self.command_with_options()
    rubocop_cmd = cop_command.replace('{path}', quoted_file_path)

    self.run_shell_command(rubocop_cmd, working_dir)
開發者ID:Mondego,項目名稱:pyreco,代碼行數:21,代碼來源:allPythonContent.py

示例6: run_rubocop_on

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
    def run_rubocop_on(self, pathlist):
        if len(pathlist) == 0:
            return

        working_dir = self.current_project_folder()

        quoted_paths = []
        for path in pathlist:
            quoted_paths.append(FileTools.quote(path))

        rubocop_cmd = self.runner.command_string(quoted_paths, self.used_options())

        self.run_shell_command(rubocop_cmd, working_dir)
開發者ID:evgenii,項目名稱:sublime_rubocop,代碼行數:15,代碼來源:rubocop_command.py

示例7: load_config

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
 def load_config(self):
   s = sublime.load_settings(SETTINGS_FILE)
   cfg_file = s.get('rubocop_config_file')
   if cfg_file:
     cfg_file = FileTools.quote(cfg_file)
   self.runner = RubocopRunner(
     {
       'use_rbenv': s.get('check_for_rbenv'),
       'use_rvm': s.get('check_for_rvm'),
       'custom_rubocop_cmd': s.get('rubocop_command'),
       'rvm_auto_ruby_path': s.get('rvm_auto_ruby_path'),
       'rbenv_path': s.get('rbenv_path'),
       'on_windows': (sublime.platform() == 'windows'),
       'rubocop_config_file': cfg_file
     }
   )
開發者ID:ayonkhan,項目名稱:sublime_rubocop,代碼行數:18,代碼來源:rubocop_command.py

示例8: run

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
  def run(self, edit):
    super(RubocopOpenAllOffensiveFilesCommand, self).run(edit)

    folders = self.view.window().folders()
    if len(folders) <= 0:
      sublime.status_message('RuboCop: No project folder available.')
      return

    folder = FileTools.quote(folders[0])

    # Run rubocop with file formatter
    file_list = self.runner.run([folder], ['--format files']).splitlines()

    for path in file_list:
      self.view.window().open_file(path.decode(locale.getpreferredencoding()))

    sublime.status_message('RuboCop: Opened ' + str(len(file_list)) + ' files.')
開發者ID:pderichs,項目名稱:sublime_rubocop,代碼行數:19,代碼來源:rubocop_command.py

示例9: load_config

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
 def load_config(self):
     s = sublime.load_settings(SETTINGS_FILE)
     cfg_file = s.get("rubocop_config_file")
     if cfg_file:
         cfg_file = FileTools.quote(cfg_file)
     self.runner = RubocopRunner(
         {
             "use_rbenv": s.get("check_for_rbenv"),
             "use_rvm": s.get("check_for_rvm"),
             "custom_rubocop_cmd": s.get("rubocop_command"),
             "rvm_auto_ruby_path": s.get("rvm_auto_ruby_path"),
             "rbenv_path": s.get("rbenv_path"),
             "on_windows": self.on_windows(),
             "rubocop_config_file": cfg_file,
             "is_st2": self.is_st2(),
         }
     )
開發者ID:evgenii,項目名稱:sublime_rubocop,代碼行數:19,代碼來源:rubocop_command.py

示例10: run_rubocop

# 需要導入模塊: from RuboCop.file_tools import FileTools [as 別名]
# 或者: from RuboCop.file_tools.FileTools import quote [as 別名]
 def run_rubocop(self, path):
   s = sublime.load_settings(SETTINGS_FILE)
   use_rvm = s.get('check_for_rvm')
   use_rbenv = s.get('check_for_rbenv')
   cmd = s.get('rubocop_command')
   rvm_path = s.get('rvm_auto_ruby_path')
   rbenv_path = s.get('rbenv_path')
   cfg_file = s.get('rubocop_config_file')
   if cfg_file:
     cfg_file = FileTools.quote(cfg_file)
   runner = RubocopRunner(
     {
       'use_rbenv': use_rbenv,
       'use_rvm': use_rvm,
       'custom_rubocop_cmd': cmd,
       'rvm_auto_ruby_path': rvm_path,
       'rbenv_path': rbenv_path,
       'on_windows': sublime.platform() == 'windows',
       'rubocop_config_file': cfg_file
     }
   )
   output = runner.run(path, '--format emacs').splitlines()
   return output
開發者ID:ayonkhan,項目名稱:sublime_rubocop,代碼行數:25,代碼來源:rubocop_listener.py


注:本文中的RuboCop.file_tools.FileTools.quote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。