Permalink
Browse files

title and body width is now 79 columns, at most

  • Loading branch information...
1 parent bac43a0 commit b05953c447f0edacbd15e939869c987594896066 @jsmits committed May 8, 2009
Showing with 21 additions and 5 deletions.
  1. +1 −1 setup.py
  2. +11 −4 src/github/issues.py
  3. +9 −0 src/github/utils.py
View
@@ -1,7 +1,7 @@
import os
from setuptools import setup, find_packages
-version = '0.2.4'
+version = '0.2.5'
cur_dir = os.path.dirname(__file__)
readme = open(os.path.join(cur_dir, 'README.rst')).read()
View
@@ -11,7 +11,7 @@
sys.exit(1)
from github.utils import urlopen2, get_remote_info, edit_text, \
- get_remote_info_from_option, get_prog, Pager
+ get_remote_info_from_option, get_prog, Pager, wrap_text
def format_issue(issue, verbose=True):
output = []
@@ -20,11 +20,18 @@ def format_issue(issue, verbose=True):
else:
indent = " " * (5 - len(str(issue['number'])))
title = "%s%s. %s" % (indent, issue['number'], issue['title'])
- output.append(title)
+ if not verbose:
+ output.append(title[:80])
if verbose:
- output.append("-" * len(title))
+ title = wrap_text(title)
+ output.append(title)
+ if len(title) > 79:
+ output.append("-" * 79)
+ else:
+ output.append("-" * len(title))
if issue['body']:
- output.append("%s" % issue['body'])
+ body = wrap_text(issue['body'])
+ output.append(body)
output.append(" state: %s" % issue['state'])
output.append(" user: %s" % issue['user'])
output.append(" votes: %s" % issue['votes'])
View
@@ -7,6 +7,7 @@
import urllib2
import tempfile
import subprocess
+import textwrap
opener = build_opener(HTTPCookieProcessor)
@@ -142,4 +143,12 @@ def close(self):
except KeyboardInterrupt:
# TODO: should kill the self.proc here gracefully
sys.exit(0) # close silently no matter what
+
+def wrap_text(text, width=79):
+ if text:
+ output = []
+ for part in text.splitlines():
+ output.append(textwrap.fill(part, width))
+ return "\n".join(output)
+ return text

0 comments on commit b05953c

Please sign in to comment.