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: =?utf-8?q?Petr_P=C5=99ikryl?= 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] =?utf-8?q?alternativa_textwrap=2Efill=28=29=2C_kter?= =?utf-8?b?w6EgYnkgemFyb3Zuw6F2YWxhIHBvIMSNZXNrdT8=?= X-BeenThere: python@py.cz X-Mailman-Version: 2.1.23 Precedence: list List-Id: Konference PyCZ List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: cz.comp.lang.python Message-ID: X-Mailman-Original-Message-ID: <20170511093124.A5004794@atlas.cz> X-Mailman-Original-References: , , , , <17124f05-2e0e-bddf-6b84-81efa2df2616@sandbox.cz>, 000500000b090006a0ac0241a92c References: , , , , <17124f05-2e0e-bddf-6b84-81efa2df2616@sandbox.cz>, 000500000b090006a0ac0241a92c <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 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 > 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 > >