Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > cz.comp.lang.python > #3177
| Path | csiph.com!news.mixmin.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer04.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx47.am4.POSTED!not-for-mail |
|---|---|
| Received-SPF | pass (Address passes the Sender Policy Framework) SPF=MAILFROM; sender=prikryl@atlas.cz; remoteip=::ffff:46.255.227.252; remotehost=; helo=gmmr2.centrum.cz; receiver=hugo.zagamma.cz; |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=atlas.cz; s=mail; t=1494487884; bh=v2oFYqoU5Luyd/b+VJXDwZfWk3k9msLfdmm5nWRllGk=; h=To:Subject:Date:From:References:In-Reply-To:From; b=RmSZaN1MPiZowHyRyO/ks1r+7keI3hCN5YDhEvu5tzO45LUL3osdFCdAhqf20lq23 Zzn6vdx2lPVGOM7hwAT/YzbELmofjq7oouX2KQeBT1uLCXbCySvwrR3zvgOXv/V7rY Lrxbr41nli+GlFfqPT7dyICpOSXsZzDfBbI4OOpc= |
| From | Petr Přikryl <prikryl@atlas.cz> |
| In-Reply-To | 000500000b090006a0ac0241a92c |
| X-Mailer | Centrum Email 5.3 |
| X-Priority | 3 |
| X-Original-From | prikryl@atlas.cz |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Subject | Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? |
| X-BeenThere | python@py.cz |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Konference PyCZ <python.py.cz> |
| List-Unsubscribe | <http://www.py.cz/mailman/options/python>, <mailto:python-request@py.cz?subject=unsubscribe> |
| List-Archive | <http://www.py.cz/pipermail/python/> |
| List-Post | <mailto:python@py.cz> |
| List-Help | <mailto:python-request@py.cz?subject=help> |
| List-Subscribe | <http://www.py.cz/mailman/listinfo/python>, <mailto:python-request@py.cz?subject=subscribe> |
| Newsgroups | cz.comp.lang.python |
| Message-ID | <mailman.3.1494487891.22440.python@py.cz> (permalink) |
| X-Mailman-Original-Message-ID | <20170511093124.A5004794@atlas.cz> |
| X-Mailman-Original-References | <slrnoh6qs6.4c8.mcepl@mitmanek.ceplovi.cz>, <CADoCwr0n57Uhm9RKy8N=GpRqC_xp=vGF9gyj7m1j4e0OqLB5=Q@mail.gmail.com>, <mailman.1.1494450194.22440.python@py.cz>, <slrnoh72qm.kmr.mcepl@mitmanek.ceplovi.cz>, <17124f05-2e0e-bddf-6b84-81efa2df2616@sandbox.cz>, <mailman.2.1494455290.22440.python@py.cz> 000500000b090006a0ac0241a92c |
| References | <mailman.2.1494455290.22440.python@py.cz> <20170511093124.A5004794@atlas.cz> |
| Lines | 66 |
| X-Complaints-To | abuse@usenet-news.net |
| NNTP-Posting-Date | Thu, 11 May 2017 07:31:32 UTC |
| Organization | usenet-news.net |
| Date | Thu, 11 May 2017 09:31:24 +0200 |
| X-Received-Body-CRC | 769953825 |
| X-Received-Bytes | 5068 |
| X-Original-Bytes | 4893 |
| Xref | csiph.com cz.comp.lang.python:3177 |
Show key headers only | View raw
Modul textwrap je psaný v Pythonu a nemá to ani 300 řádků (i s rozsáhlými docstringy).
Přepište si to po svém, případně přidejte nějaký parametr typu "množina slov, která nemají zůstat na konci".
A pokud to bude šikovné, pošlete to jako námět na vylepšení oficiálního textwrap.
Přeji krásný den,
Petr
______________________________________________________________
> Od: Matěj Cepl <mcepl@cepl.eu>
> Komu: python@py.cz
> Datum: 11.05.2017 01:12
> Předmět: Re: [python] alternativa textwrap.fill(), kter
>
>On 2017-05-10, 22:28 GMT, Vláďa Macek wrote:
>> print textwrap.fill(instr, width=65).replace(u'~',
>> unichr(160))
>
>No, udělal jsem v podstatě to:
>
> diff --git a/reflow.py b/reflow.py
> index 22b08cf..757077c 100644
> --- a/reflow.py
> +++ b/reflow.py
> @@ -133,12 +133,18 @@ class ReflowPluginWindowActivatable(GObject.Object, Gedit.WindowActivatable):
> if isinstance(text, str):
> text = unicode(text, 'utf8')
>
> + # we don't want to break on the non-breaking space
> + # FIXME not sure whether there isn’t better replacement character
> + text = text.replace(unichr(0xA0), '~')
> +
> text = textwrap.fill(text,
> width=self.get_gedit_margin(),
> initial_indent=first_prefix,
> subsequent_indent=prefix,
> break_on_hyphens=False,
> drop_whitespace=True)
> + text = text.replace('~', unichr(0xA0))
> +
> return text
>
> def _get_line(self, index):
>
>Ale nejsem na to hrdej. Navíc přemýšlím, jestli někdy nebudu
>chtít mít ~ znak v textu. Ale snad ne.
>
>Hezký den,
>
>Matěj
>
>--
>https://matej.ceplovi.cz/blog/, Jabber: mcepl@ceplovi.cz
>GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8
>
>Of course I'm respectable. I'm old. Politicians, ugly buildings,
>and whores all get respectable if they last long enough.
> --John Huston in "Chinatown."
>_______________________________________________
>Python mailing list
>python@py.cz
>http://www.py.cz/mailman/listinfo/python
>
>Visit: http://www.py.cz
>
>
Back to cz.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-10 21:35 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Honza Král <honza.kral@gmail.com> - 2017-05-10 23:02 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-10 23:51 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Vláďa Macek <macek@sandbox.cz> - 2017-05-11 00:28 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 01:12 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Petr Přikryl <prikryl@atlas.cz> - 2017-05-11 09:31 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 10:50 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Petr Viktorin <encukou@gmail.com> - 2017-05-11 11:22 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 16:31 +0200
csiph-web