Skip to content

Commit

Permalink
Run Yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
catch22 committed Sep 10, 2017
1 parent aa41a4b commit eb1fb45
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions PyYapf.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def __enter__(self):
sublime.error_message(msg)
raise Exception(msg)
cmd = os.path.expanduser(cmd)
cmd = sublime.expand_variables(cmd, sublime.active_window().extract_variables())
cmd = sublime.expand_variables(
cmd, sublime.active_window().extract_variables())

self.popen_args = [cmd]
if self.custom_style_fname:
Expand Down Expand Up @@ -216,13 +217,14 @@ def format(self, edit, selection=None):
# run yapf
self.debug('Running %s in %s', self.popen_args, self.popen_cwd)
try:
popen = subprocess.Popen(self.popen_args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
cwd=self.popen_cwd,
env=self.popen_env,
startupinfo=self.popen_startupinfo)
popen = subprocess.Popen(
self.popen_args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
cwd=self.popen_cwd,
env=self.popen_env,
startupinfo=self.popen_startupinfo)
except OSError as err:
# always show error in popup
msg = "You may need to install YAPF and/or configure 'yapf_command' in PyYapf's Settings."
Expand Down Expand Up @@ -321,6 +323,7 @@ def error(self, msg, *args):
def get_setting(self, key, default_value=None):
return get_setting(self.view, key, default_value)


def is_python(view):
return view.score_selector(0, 'source.python') > 0

Expand Down

0 comments on commit eb1fb45

Please sign in to comment.