Navigation Menu

Skip to content

Commit

Permalink
Merge pull request pypingou#4 from ralphbean/infinite_loop
Browse files Browse the repository at this point in the history
Infinite loop
  • Loading branch information
pypingou committed Feb 28, 2012
2 parents 28ab401 + 31c81c4 commit 9b7ac69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pypi2spec.spec
Expand Up @@ -8,7 +8,7 @@ URL: http://github.com/pypingou/pypi2spec
Source0: %{name}-%{version}.tar.gz

BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-devel,python-setuptools

Requires: python-rdflib
Requires: python-jinja2
Expand Down Expand Up @@ -41,6 +41,7 @@ chmod -x %{buildroot}/%{python_sitelib}/pypi2spec/specfile.tpl

%changelog
* Mon Feb 27 2012 Ralph Bean <rbean@redhat.com> - 0.1.1-1
- Changed to use textwrap to format descriptions
- Changed to use setuptools instead of distutils
- Misc bugfixes
* Sat Feb 11 2012 Pierre-Yves Chibon <pingou@pingoured.fr> - 0.1.0-1
Expand Down
27 changes: 13 additions & 14 deletions pypi2spec/spec.py
Expand Up @@ -25,6 +25,7 @@
import os
import re
import sys
import textwrap
from jinja2 import Template
try:
from pypi2spec import get_logger, get_rpm_tag, Pypi2specError
Expand All @@ -34,20 +35,18 @@

def format_description(description):
""" Format the description as required by rpm """
step = 75
cnt = 0
out = []
char = 0
while cnt < len(description) and char < description.rfind(" "):
if len(description[cnt:]) >= step:
char = description[cnt: cnt + step].rfind(" ") + cnt
out.append(description[cnt: char])
cnt = char + 1
else:
out.append(description[cnt:])
cnt += len(description[cnt:])

return "\n".join(out)

# Return the description unadulterated if it is already valid.
if not any([len(line) > 75 for line in description.split('\n')]):
return description

# Otherwise, run it through the textwrap module. This can have a
# destructive affect on reStructuredText markup.
wrapper = textwrap.TextWrapper(width=75)
# First, remove trailing whitespace from every line
cleaned = '\n'.join([l.strip() for l in description.split('\n')])
# Format each paragraph into 75 chars per line and re-join
return '\n\n'.join([wrapper.fill(p) for p in cleaned.split('\n\n')])


def format_dependencies(dependencies):
Expand Down

0 comments on commit 9b7ac69

Please sign in to comment.