X Tutup
Skip to content

Commit 2c906bf

Browse files
committed
PEP-8 conformance
1 parent 3cc42cb commit 2c906bf

File tree

9 files changed

+47
-26
lines changed

9 files changed

+47
-26
lines changed

bpython/_internal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
class _Helper(object):
11+
1112
def __init__(self):
1213
self.helper = pydoc.Helper(sys.stdin, sys.stdout)
1314

bpython/cli.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,11 @@ def cw(self):
412412
return
413413

414414
i = 1
415-
while i < l+1:
415+
while i < l + 1:
416416
if not self.s[-i].isalnum() and self.s[-i] not in ('.', '_'):
417417
break
418418
i += 1
419-
return self.s[-i +1:]
419+
return self.s[-i + 1:]
420420

421421
def delete(self):
422422
"""Process a del"""
@@ -597,17 +597,17 @@ def mkargspec(self, topline, down):
597597
y, x = self.list_win.getyx()
598598
ln = len(str(i))
599599
kw = None
600-
if kwargs and k+1 > len(args) - len(kwargs):
600+
if kwargs and k + 1 > len(args) - len(kwargs):
601601
kw = str(kwargs[k - (len(args) - len(kwargs))])
602602
ln += len(kw) + 1
603603

604604
if ln + x >= w:
605605
ty = self.list_win.getbegyx()[0]
606606
if not down and ty > 0:
607-
h +=1
607+
h += 1
608608
self.list_win.mvwin(ty-1, 1)
609609
self.list_win.resize(h, w)
610-
elif down and h + r < maxh-ty:
610+
elif down and h + r < maxh - ty:
611611
h += 1
612612
self.list_win.resize(h, w)
613613
else:
@@ -985,7 +985,7 @@ def show_list(self, items, topline=None, current_item=None):
985985
if down:
986986
max_h = h - y
987987
else:
988-
max_h = y+1
988+
max_h = y + 1
989989
max_w = int(w * 0.8)
990990
self.list_win.erase()
991991
if items:
@@ -1057,7 +1057,7 @@ def lsize():
10571057
w = t
10581058

10591059

1060-
if height_offset and display_rows+5 >= max_h:
1060+
if height_offset and display_rows + 5 >= max_h:
10611061
del v_items[-(cols * (height_offset)):]
10621062

10631063
if self.docstring is None:
@@ -1087,7 +1087,7 @@ def lsize():
10871087
if not py3:
10881088
i = i.encode(getpreferredencoding())
10891089
self.list_win.addstr(i + padding, color)
1090-
if ((cols == 1 or (ix and not (ix+1) % cols))
1090+
if ((cols == 1 or (ix and not (ix + 1) % cols))
10911091
and ix + 1 < len(v_items)):
10921092
self.list_win.addstr('\n ')
10931093

@@ -1392,7 +1392,8 @@ def gethw():
13921392
13931393
"""
13941394
h, w = struct.unpack(
1395-
"hhhh", fcntl.ioctl(sys.__stdout__, termios.TIOCGWINSZ, "\000"*8))[0:2]
1395+
"hhhh",
1396+
fcntl.ioctl(sys.__stdout__, termios.TIOCGWINSZ, "\000" * 8))[0:2]
13961397
return h, w
13971398

13981399

bpython/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
from bpython.keys import key_dispatch
66
import errno
77

8+
89
class Struct(object):
910
"""Simple class for instantiating objects we can add arbitrary attributes
1011
to and use for various arbitrary things."""
1112

13+
1214
def fill_config_with_default_values(config, default_values):
1315
for section in default_values.iterkeys():
1416
if not config.has_section(section):
@@ -42,8 +44,7 @@ def loadini(struct, configfile):
4244
'paste_time': 0.02,
4345
'syntax': True,
4446
'tab_length': 4,
45-
'pastebin_url': 'http://bpaste.net'
46-
},
47+
'pastebin_url': 'http://bpaste.net'},
4748
'keyboard': {
4849
'clear_line': 'C-u',
4950
'clear_screen': 'C-l',
@@ -57,9 +58,7 @@ def loadini(struct, configfile):
5758
'show_source': 'F2',
5859
'undo': 'C-r',
5960
'up_one_line': 'C-p',
60-
'yank_from_buffer': 'C-y'
61-
}
62-
})
61+
'yank_from_buffer': 'C-y'}})
6362
config.read(config_path)
6463

6564
struct.tab_length = config.getint('general', 'tab_length')
@@ -118,6 +117,7 @@ def loadini(struct, configfile):
118117
for key in (struct.pastebin_key, struct.save_key):
119118
key_dispatch[key]
120119

120+
121121
def load_theme(struct, path, inipath):
122122
theme = ConfigParser()
123123
try:
@@ -137,7 +137,8 @@ def load_theme(struct, path, inipath):
137137

138138

139139
def migrate_rc(path):
140-
"""Use the shlex module to convert the old configuration file to the new format.
140+
"""Use the shlex module to convert the old configuration file to the new
141+
format.
141142
The old configuration file is renamed but not removed by now."""
142143
import shlex
143144
f = open(path)
@@ -149,8 +150,7 @@ def migrate_rc(path):
149150
'on': True,
150151
'false': False,
151152
'no': False,
152-
'off': False
153-
}
153+
'off': False}
154154

155155
config = ConfigParser()
156156
config.add_section('general')

bpython/formatter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@
6868
Token: 'token',
6969
Whitespace: 'background',
7070
Parenthesis: 'paren',
71-
Parenthesis.UnderCursor: 'operator'
72-
}
71+
Parenthesis.UnderCursor: 'operator'}
7372

7473

7574
class BPythonFormatter(Formatter):
@@ -104,7 +103,7 @@ def format(self, tokensource, outfile):
104103

105104
while token not in self.f_strings:
106105
token = token.parent
107-
o += "%s\x03%s\x04" % (self.f_strings[token], text)
106+
o += "%s\x03%s\x04" % (self.f_strings[token], text)
108107
outfile.write(o.rstrip())
109108

110109
# vim: sw=4 ts=4 sts=4 ai et

bpython/gtk_.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ArgspecFormatter(object):
5353
"""
5454
Format an argspec using Pango markup language.
5555
"""
56+
5657
def format(self, args, varargs, varkw, defaults, in_arg):
5758
self.args_seen = 0
5859
self.in_arg = in_arg
@@ -76,6 +77,7 @@ class Nested(object):
7677
"""
7778
A helper class, inspired by a semaphore.
7879
"""
80+
7981
def __init__(self):
8082
self.counter = 0
8183

@@ -97,6 +99,7 @@ class SuggestionWindow(gtk.Window):
9799
__gsignals__ = dict(expose_event=None,
98100
selection_changed=(gobject.SIGNAL_RUN_LAST, None,
99101
(str, )))
102+
100103
def __init__(self):
101104
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
102105
self.set_app_paintable(True)
@@ -213,6 +216,7 @@ class ReplWidget(gtk.TextView, repl.Repl):
213216
focus_in_event=None,
214217
focus_out_event=None,
215218
realize=None)
219+
216220
def __init__(self, interpreter):
217221
gtk.TextView.__init__(self)
218222
repl.Repl.__init__(self, interpreter)
@@ -569,14 +573,17 @@ def init_import_completion():
569573
def on_about(widget):
570574
pass
571575

576+
572577
def on_quit(widget):
573578
pass
574579

580+
575581
def on_button_press_event(widget, event, popup):
576582
if event.button == 3:
577583
popup.popup(None, None, None, event.button, event.time)
578584
return True
579585

586+
580587
def main(args=None):
581588
if args is None:
582589
args = sys.argv[1:]

bpython/importcompletion.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
modules = set()
3131
fully_loaded = False
3232

33+
3334
def complete(line, cw):
3435
"""Construct a full list of possibly completions for imports."""
3536
if not cw:
@@ -102,6 +103,7 @@ def find_all_modules(path=None):
102103
modules.add(module)
103104
yield
104105

106+
105107
def find_coroutine():
106108
global fully_loaded
107109

@@ -115,6 +117,7 @@ def find_coroutine():
115117

116118
return True
117119

120+
118121
def reload():
119122
"""Refresh the list of known modules."""
120123
modules.clear()

bpython/inspection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
class AttrCleaner(object):
4242
"""A context manager that tries to make an object not exhibit side-effects
4343
on attribute lookup."""
44+
4445
def __init__(self, obj):
4546
self.obj = obj
4647

@@ -128,6 +129,7 @@ def parsekeywordpairs(signature):
128129
d[item[0]] = ''.join(item[2:])
129130
return d
130131

132+
131133
def fixlongargs(f, argspec):
132134
"""Functions taking default arguments that are references to other objects
133135
whose str() is too big will cause breakage, so we swap out the object

bpython/keys.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525

2626
import string
2727

28+
2829
class KeyMap:
30+
2931
def __init__(self):
3032
self.map = {}
3133

3234
def __getitem__(self, key):
3335
if key in self.map:
3436
return self.map[key]
3537
else:
36-
raise Exception('Configured keymap (%s) does not exist in bpython.keys' % key)
38+
raise Exception('Configured keymap (%s)\
39+
does not exist in bpython.keys' % key)
3740

3841
def __setitem__(self, key, value):
3942
self.map[key] = value
@@ -42,7 +45,7 @@ def __setitem__(self, key, value):
4245

4346
# fill dispatch with letters
4447
for c in string.ascii_lowercase:
45-
key_dispatch['C-%s' % c] = (chr(string.ascii_lowercase.index(c)+1),
48+
key_dispatch['C-%s' % c] = (chr(string.ascii_lowercase.index(c) + 1),
4649
'^%s' % c.upper())
4750

4851
# fill dispatch with cool characters
@@ -53,5 +56,5 @@ def __setitem__(self, key, value):
5356
key_dispatch['C-_'] = (chr(31), '^_')
5457

5558
# fill dispatch with function keys
56-
for x in xrange(1,13):
59+
for x in xrange(1, 13):
5760
key_dispatch['F%s' % str(x)] = ('KEY_F(%s)' % str(x),)

bpython/repl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(self, locals=None, encoding=sys.getdefaultencoding()):
6464
code.InteractiveInterpreter.__init__(self, locals)
6565

6666
if not py3:
67+
6768
def runsource(self, source, filename='<input>', symbol='single'):
6869
source = '# coding: %s\n%s' % (self.encoding,
6970
source.encode(self.encoding))
@@ -130,6 +131,7 @@ def writetb(self, lines):
130131

131132

132133
class History(object):
134+
133135
def __init__(self, entries=None):
134136
if entries is None:
135137
self.entries = ['']
@@ -189,6 +191,7 @@ def save(self, filename, encoding, lines=0):
189191

190192

191193
class MatchesIterator(object):
194+
192195
def __init__(self, current_word='', matches=[]):
193196
self.current_word = current_word
194197
self.matches = list(matches)
@@ -298,7 +301,6 @@ def __init__(self, interp, idle=None):
298301
with open(filename, 'r') as f:
299302
self.interp.runsource(f.read(), filename, 'exec')
300303

301-
302304
def attr_matches(self, text):
303305
"""Taken from rlcompleter.py and bent to my will."""
304306

@@ -586,7 +588,7 @@ def write2file(self):
586588
def pastebin(self):
587589
"""Upload to a pastebin and display the URL in the status bar."""
588590

589-
pasteservice_url = OPTS.pastebin_url
591+
pasteservice_url = OPTS.pastebin_url
590592
pasteservice = ServerProxy(urljoin(pasteservice_url, '/xmlrpc/'))
591593

592594
s = self.getstdout()
@@ -595,7 +597,7 @@ def pastebin(self):
595597
try:
596598
paste_id = pasteservice.pastes.newPaste('pycon', s)
597599
except XMLRPCError, e:
598-
self.statusbar.message( 'Upload failed: %s' % (str(e), ) )
600+
self.statusbar.message('Upload failed: %s' % (str(e), ) )
599601
return
600602

601603
paste_url = urljoin(pasteservice_url, '/show/%s/' % (paste_id, ))
@@ -849,9 +851,11 @@ def split_lines(tokens):
849851
if newline:
850852
yield (Token.Text, newline)
851853

854+
852855
def token_is(token_type):
853856
"""Return a callable object that returns whether a token is of the
854857
given type `token_type`."""
858+
855859
def token_is_type(token):
856860
"""Return whether a token is of a certain type or not."""
857861
token = token[0]
@@ -861,6 +865,7 @@ def token_is_type(token):
861865

862866
return token_is_type
863867

868+
864869
def token_is_any_of(token_types):
865870
"""Return a callable object that returns whether a token is any of the
866871
given types `token_types`."""

0 commit comments

Comments
 (0)
X Tutup