Skip to content

Commit 5713bfa

Browse files
author
Charles Duffy
committed
PEP-8 compliance
committer: Charles Duffy <cduffy@messageone.com>
1 parent a4248de commit 5713bfa

5 files changed

Lines changed: 326 additions & 266 deletions

File tree

‎bpython/__init__.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# The MIT License
2-
#
2+
#
33
# Copyright (c) 2008 Bob Farrell
4-
#
4+
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
77
# in the Software without restriction, including without limitation the rights
88
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
# copies of the Software, and to permit persons to whom the Software is
1010
# furnished to do so, subject to the following conditions:
11-
#
11+
#
1212
# The above copyright notice and this permission notice shall be included in
1313
# all copies or substantial portions of the Software.
14-
#
14+
#
1515
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

‎bpython/_internal.py‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# actual user input, I couldn't think of another way of doing this.
99
window = None
1010

11-
def _help( obj ):
11+
12+
def _help(obj):
1213
"""Wrapper for the regular help() function but with a ghetto
1314
PAGER since curses + less = :(
1415
As per the vanilla help(), this function special-cases for str,
@@ -17,7 +18,7 @@ def _help( obj ):
1718
"""
1819
io = cStringIO.StringIO()
1920
doc = pydoc.TextDoc()
20-
helper = pydoc.Helper( None, io )
21+
helper = pydoc.Helper(None, io)
2122

2223
rows, columns = window.getmaxyx()
2324
rows -= 3
@@ -29,19 +30,26 @@ def _help( obj ):
2930
# the bpython help is no compliant with the vanilla help.
3031
# Please let me know if you find this to be untrue.
3132
if type(obj) is type(''):
32-
if obj == 'help': helper.intro()
33-
elif obj == 'keywords': helper.listkeywords()
34-
elif obj == 'topics': helper.listtopics()
35-
elif obj == 'modules': helper.listmodules()
33+
if obj == 'help':
34+
helper.intro()
35+
elif obj == 'keywords':
36+
helper.listkeywords()
37+
elif obj == 'topics':
38+
helper.listtopics()
39+
elif obj == 'modules':
40+
helper.listmodules()
3641
elif obj[:8] == 'modules ':
3742
helper.listmodules(split(obj)[1])
38-
elif obj in helper.keywords: helper.showtopic(obj)
39-
elif obj in helper.topics: helper.showtopic(obj)
40-
elif obj: output = doc.document( eval(obj) )
43+
elif obj in helper.keywords:
44+
helper.showtopic(obj)
45+
elif obj in helper.topics:
46+
helper.showtopic(obj)
47+
elif obj:
48+
output = doc.document(eval(obj))
4149
#######################
4250

4351
else:
44-
output = doc.document( obj )
52+
output = doc.document(obj)
4553
if not output:
4654
output = "No help found for %s" % obj
4755
return
@@ -63,19 +71,20 @@ def _help( obj ):
6371

6472
paragraphs = []
6573
for o in output:
66-
paragraphs.append( textwrap.wrap( o, columns ) )
74+
paragraphs.append(textwrap.wrap(o, columns))
6775

6876
i = 0
69-
for j, paragraph in enumerate( paragraphs ):
77+
for j, paragraph in enumerate(paragraphs):
7078
for line in paragraph:
71-
sys.stdout.write( line + '\n' )
79+
sys.stdout.write(line + '\n')
7280
i += 1
7381
# This is a little unclear, but it just waits for a
7482
# keypress when the a page worth of text has been
7583
# displayed and returns if 'q' is pressed:
7684
if not i % rows and not wait_for_key():
7785
return
7886

87+
7988
def wait_for_key():
8089
"""Block until a key is pressed for the ghetto paging."""
8190

@@ -90,7 +99,10 @@ def wait_for_key():
9099
clear_line()
91100
return q
92101

102+
93103
def clear_line():
94104
y = window.getyx()[0]
95105
window.move(y, 0)
96106
window.clrtoeol()
107+
108+
# vim: sw=4 ts=4 sts=4 ai et

0 commit comments

Comments
 (0)