Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64cafbe

Browse files
committed
Code cleanup
1 parent5a34c00 commit64cafbe

File tree

2 files changed

+2
-102
lines changed

2 files changed

+2
-102
lines changed

‎pymode/run.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def run_code():
3333
# A false code will be treated as a
3434
# successful run, and the error will be hidden from Vim
3535
env.error("Script exited with code %s"%e.code)
36-
env.stop()
36+
returnenv.stop()
3737

3838
exceptException:
3939
importtraceback
@@ -43,13 +43,9 @@ def run_code():
4343
err=sys.stderr.getvalue()
4444

4545
output=sys.stdout.getvalue().strip()
46+
output=env.prepare_value(output)
4647
sys.stdout,sys.stderr=stdout_,stderr_
4748

48-
try:
49-
output=output.decode('utf-8').encode(env.options.get('encoding'))
50-
exceptAttributeError:
51-
pass
52-
5349
errors+= [erforerinerr.splitlines()iferand"<string>"notiner]
5450

5551
env.let('l:traceback',errors[2:])

‎pymode/utils.py

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
""" Pymode utils. """
2-
importjson
32
importos.path
43
importsys
54
importthreading
@@ -18,92 +17,6 @@
1817
PY2=sys.version_info[0]==2
1918

2019

21-
defpymode_message(content):
22-
""" Show message. """
23-
24-
vim.command('call pymode#wide_message("%s")'%str(content))
25-
26-
27-
defpymode_confirm(yes=True,msg='Do the changes:'):
28-
""" Confirmation.
29-
30-
:return bool:
31-
32-
"""
33-
default='yes'ifyeselse'no'
34-
action=pymode_input(msg,default)
35-
returnactionand'yes'.startswith(action)
36-
37-
38-
defpymode_inputlist(msg,opts):
39-
""" Get user choice.
40-
41-
:return str: A choosen option
42-
43-
"""
44-
choices= ['[Pymode] %s'%msg]
45-
choices+= ["%s. %s"% (num,opt)fornum,optinenumerate(opts,1)]
46-
try:
47-
input_str=int(vim.eval('inputlist(%s)'%json.dumps(choices)))
48-
except (KeyboardInterrupt,ValueError):
49-
input_str=0
50-
51-
ifnotinput_str:
52-
pymode_message('Cancelled!')
53-
returnFalse
54-
55-
try:
56-
returnopts[input_str-1]
57-
except (IndexError,ValueError):
58-
pymode_error('Invalid option: %s'%input_str)
59-
returnpymode_inputlist(msg,opts)
60-
61-
62-
defpymode_input(umsg,udefault='',opts=None):
63-
""" Get user input.
64-
65-
:return str: A user input
66-
67-
"""
68-
msg='[Pymode] %s '%umsg
69-
default=udefault
70-
71-
ifdefault!='':
72-
msg+='[%s] '%default
73-
74-
try:
75-
vim.command('echohl Debug')
76-
input_str=vim.eval('input("%s> ")'%msg)
77-
vim.command('echohl none')
78-
exceptKeyboardInterrupt:
79-
input_str=''
80-
81-
returninput_strordefault
82-
83-
84-
defpymode_error(content):
85-
""" Show error. """
86-
87-
vim.command('call pymode#error("%s")'%str(content))
88-
89-
90-
defcatch_and_print_exceptions(func):
91-
""" Catch any exception.
92-
93-
:return func:
94-
95-
"""
96-
defwrapper(*args,**kwargs):
97-
try:
98-
returnfunc(*args,**kwargs)
99-
except (Exception,vim.error)ase:# noqa
100-
ifDEBUG:
101-
raise
102-
pymode_error(e)
103-
returnNone
104-
returnwrapper
105-
106-
10720
@contextmanager
10821
defsilence_stderr():
10922
""" Redirect stderr. """
@@ -127,12 +40,3 @@ def patch_paths():
12740
sys.path.insert(0,os.path.join(os.path.dirname(__file__),'libs2'))
12841
else:
12942
sys.path.insert(0,os.path.join(os.path.dirname(__file__),'libs3'))
130-
131-
132-
debug=lambda_:None
133-
134-
ifDEBUG:
135-
defdebug(msg):# noqa
136-
""" Debug message. """
137-
138-
print(msg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp