[issue18585] Add a text truncation function

2014-01-02 Thread Daniel Holth
Daniel Holth added the comment: Previous changeset was meant for #18515 -- nosy: +dholth ___ Python tracker ___ ___ Python-bugs-list m

[issue18585] Add a text truncation function

2014-01-02 Thread Roundup Robot
Roundup Robot added the comment: New changeset 536a2cf5f1d2 by Daniel Holth in branch 'default': Issue #18585: speed zipfile import by only generating zipfile._ZipDecryptor on demand http://hg.python.org/cpython/rev/536a2cf5f1d2 -- ___ Python tracker

[issue18585] Add a text truncation function

2013-10-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0bd257cd3e88 by Serhiy Storchaka in branch 'default': Add shorten to __all_ (issues #18585 and #18725). http://hg.python.org/cpython/rev/0bd257cd3e88 -- ___ Python tracker

[issue18585] Add a text truncation function

2013-08-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: (Ezio noticed that I had left the placeholder as " (...)". This is now fixed.) -- ___ Python tracker ___ ___

[issue18585] Add a text truncation function

2013-08-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset be5481bf4c57 by Antoine Pitrou in branch 'default': Fix the default placeholder in textwrap.shorten() to be " [...]". http://hg.python.org/cpython/rev/be5481bf4c57 -- ___ Python tracker

[issue18585] Add a text truncation function

2013-08-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What about a multiline summarize? The textwrap module is designed to work with multiline text. Let we want wrap 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' in 40 column and s

[issue18585] Add a text truncation function

2013-08-12 Thread Roundup Robot
Roundup Robot added the comment: New changeset c27ec198d3d1 by Antoine Pitrou in branch 'default': Issue #18585: Add :func:`textwrap.shorten` to collapse and truncate a piece of text to a given length. http://hg.python.org/cpython/rev/c27ec198d3d1 -- nosy: +python-dev _

[issue18585] Add a text truncation function

2013-08-12 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue18585] Add a text truncation function

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, I've committed after having addressed (most of) RDM's comments. -- resolution: -> fixed stage: patch review -> committed/rejected ___ Python tracker __

[issue18585] Add a text truncation function

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch addressing Ezio's comments. -- Added file: http://bugs.python.org/file31257/shorten2.patch ___ Python tracker ___

[issue18585] Add a text truncation function

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch renaming summarize() to shorten(), and adding docs and a fix for a nit reported by Vajrasky. -- Added file: http://bugs.python.org/file31250/shorten.patch ___ Python tracker

[issue18585] Add a text truncation function

2013-08-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Looking just at the proposed functionality (taking a prefix) and > ignoring the requested complexification :), the usual name for the > text produced by this process is a > "lead" (http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Lead_section), > althoug

[issue18585] Add a text truncation function

2013-08-05 Thread R. David Murray
R. David Murray added the comment: Looking just at the proposed functionality (taking a prefix) and ignoring the requested complexification :), the usual name for the text produced by this process is a "lead" (http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Lead_section), although form

[issue18585] Add a text truncation function

2013-08-05 Thread Ezio Melotti
Ezio Melotti added the comment: Perhaps "shorten" would be a better name -- "summarize" sounds smarter than it actually is :) -- ___ Python tracker ___ _

[issue18585] Add a text truncation function

2013-08-05 Thread Ezio Melotti
Ezio Melotti added the comment: [...] and ASCII are fine with me. > Perhaps there could be an argument controlling where to truncate > (left, right or centre). A good use-case for the new Enums, perhaps? :-) I wrote a similar function once and in addition to the width it had this feature too (

[issue18585] Add a text truncation function

2013-08-02 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Bike-shedding here... why "(...)"? Is it common to use round brackets > for this purpose? In English-speaking countries, it is usual to use > square brackets for editorial comments, including ellipsis "[...]". Ah, really? French uses "[...]" but I thought Engl

[issue18585] Add a text truncation function

2013-08-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Bike-shedding here... why "(...)"? Is it common to use round brackets for this purpose? In English-speaking countries, it is usual to use square brackets for editorial comments, including ellipsis "[...]". Either way, if you wanted to be more Unicode aware, y

[issue18585] Add a text truncation function

2013-08-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: A function like this often gets called to truncate lots of lines. Unfortunately for many use-cases, the part truncated is the most significant part of the line. E.g.: Scanning file: /home/fred/documents/datafil... /home/fred/documents/datafil... /home/fred/do

[issue18585] Add a text truncation function

2013-07-30 Thread Vajrasky Kok
Vajrasky Kok added the comment: Monsieur Pitrou, thanks for the explanation. Actually, IMHO I prefer, 'hello (...)' should be the minimum words we can use not '(...)' because '(...)' does not make any sense. But, anyway, it's your call. :) Anyway, using your summarize2.patch: >>> textwrap.sum

[issue18585] Add a text truncation function

2013-07-30 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch to not add any space before the placeholder, with " (...)" as default placeholder value. -- Added file: http://bugs.python.org/file31084/summarize2.patch ___ Python tracker

[issue18585] Add a text truncation function

2013-07-30 Thread Antoine Pitrou
Antoine Pitrou added the comment: Oops, sorry, I was mistaken. There is no bug actually here: >>> textwrap.summarize('hello world!', width=10) '(...)' 'hello (...)' cannot be the right answer since its len() is 11, greater than 10. -- ___ Pytho

[issue18585] Add a text truncation function

2013-07-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Vajrasky, thanks. The former is a bug, but the latter is a feature. summarize() re-uses the textwrap machinery to normalize spaces. -- ___ Python tracker _

[issue18585] Add a text truncation function

2013-07-29 Thread Vajrasky Kok
Vajrasky Kok added the comment: Beside of that, I notice the new lines are deleted silently. >>> textwrap.summarize('republicans are red,\ndemocrats are blue,\nneither one >>> of them,\ncares about you.', width=46) 'republicans are red, democrats are blue, (...)' -- __

[issue18585] Add a text truncation function

2013-07-29 Thread Vajrasky Kok
Vajrasky Kok added the comment: Something is not right if we use more than one space. >>> textwrap.summarize('hello world!', width=12) 'hello world!' >>> textwrap.summarize('hello world!', width=11) 'hello (...)' >>> textwrap.summarize('hello world!', width=10) '(...)' I expect t

[issue18585] Add a text truncation function

2013-07-29 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue18585] Add a text truncation function

2013-07-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: > >Perhaps the "placeholder" argument should actually include the last > >whitespace, to allow people to omit the whitespace, or use a > >non-breaking space instead? > > > > >>> textwrap.summarize("Hello world!", width=11, > > >>> placeholder='...') > > 'H

[issue18585] Add a text truncation function

2013-07-29 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Jul 29, 2013, at 01:55 PM, Antoine Pitrou wrote: >Perhaps the "placeholder" argument should actually include the last >whitespace, to allow people to omit the whitespace, or use a non-breaking >space instead? > > >>> textwrap.summarize("Hello world!", w

[issue18585] Add a text truncation function

2013-07-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Perhaps the "placeholder" argument should actually include the last whitespace, to allow people to omit the whitespace, or use a non-breaking space instead? >>> textwrap.summarize("Hello world!", width=11, placeholder='...') 'Hello...' -- _

[issue18585] Add a text truncation function

2013-07-29 Thread Antoine Pitrou
New submission from Antoine Pitrou: Following patch proposed to add a function named textwrap.summarize(): >>> textwrap.summarize("Hello world!", width=12) 'Hello world!' >>> textwrap.summarize("Hello world!", width=11) 'Hello (...)' -- components: Library (Lib) files: sum