当前位置: 首页>>代码示例>>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;未经允许,请勿转载。