This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Nice, intelligent truncation of text.

Nicely truncate text

Intelligent truncation of text means that truncation does not take place inside a word but only between words. So the required length is only an approximation. The result text might be a bit longer than the required length:

>>> from icemac.truncatetext import truncate
>>> 'I was here.'[:3]
'I w'
>>> truncate('I was here.', 3)
'I was ...'

What can get truncated?

Only instances of basestring can be truncated:

>>> truncate(3, 3)
Traceback (most recent call last):
ValueError: 3 is no instance of basestring or None
>>> truncate(u'Lorem ipsum', 5)
u'Lorem ...'

None is handled nicely:

>>> truncate(None, 4)
''

What is returned?

Always at least one word is returned even when it is longer than the required length:

>>> truncate('Lorem ipsum', 1)
'Lorem ...'

If the text contains only of one word which is longer than the desired length it is returned without an ellipsis:

>>> truncate('The-really-long-word', 5)
'The-really-long-word'

If the text is shorter than the desired length it is returned without the ellipsis, too:

>>> truncate('Lorem ipsum', 11)
'Lorem ipsum'

Where gets the text truncated?

Truncation also takes place at tabs and linebreaks:

>>> truncate("I was here.\nNow I'm away", 11)
'I was here. ...'
>>> truncate("I was here.\rNow I'm away", 12)
'I was here.\rNow ...'
>>> truncate("I was here.\tNow I'm away", 11)
'I was here. ...'

I do not want as ellipsis.

truncate takes an optional argument which defines the ellipsis string:

>>> truncate(u'Lorem ipsum', 5, ellipsis=u':::')
u'Lorem :::'

Changelog

0.3 (2012-11-13)

  • Moved sources to bitbucket.org.
  • Added Travis-CI.
  • Dropped official support for Python 2.3 and Python 2.4. (Although these rather old Python versions still might be used with this release.)

0.2.1 (2011-07-28)

  • Updated categories: Python 2.7 is supported, too.

0.2 (2009-09-26)

  • Added ability pass a string used as ellipsis string.

0.1 (2009-01-31)

  • Initial public release.

Hacking

Fork me on bitbucket.org or put your issues to the issue tracker.

Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
icemac.truncatetext-0.3.zip (10.6 kB) Copy SHA256 Checksum SHA256 Source Nov 13, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting