Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6186410d
Kaydet (Commit)
6186410d
authored
Haz 03, 2004
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #965425: fix so hyphenated words surrounded by punctuation are
wrapped correctly.
üst
29eb8c31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
test_textwrap.py
Lib/test/test_textwrap.py
+18
-1
textwrap.py
Lib/textwrap.py
+3
-3
No files found.
Lib/test/test_textwrap.py
Dosyayı görüntüle @
6186410d
#
#
# Test s
cript
for the textwrap module.
# Test s
uite
for the textwrap module.
#
#
# Original tests written by Greg Ward <gward@python.net>.
# Original tests written by Greg Ward <gward@python.net>.
# Converted to PyUnit by Peter Hansen <peter@engcorp.com>.
# Converted to PyUnit by Peter Hansen <peter@engcorp.com>.
...
@@ -271,6 +271,23 @@ What a mess!
...
@@ -271,6 +271,23 @@ What a mess!
self
.
check_split
(
"foo --option-opt bar"
,
self
.
check_split
(
"foo --option-opt bar"
,
[
"foo"
,
" "
,
"--option-"
,
"opt"
,
" "
,
"bar"
])
[
"foo"
,
" "
,
"--option-"
,
"opt"
,
" "
,
"bar"
])
def
test_punct_hyphens
(
self
):
# Oh bother, SF #965425 found another problem with hyphens --
# hyphenated words in single quotes weren't handled correctly.
# In fact, the bug is that *any* punctuation around a hyphenated
# word was handled incorrectly, except for a leading "--", which
# was special-cased for Optik and Docutils. So test a variety
# of styles of punctuation around a hyphenated word.
# (Actually this is based on an Optik bug report, #813077).
self
.
check_split
(
"the 'wibble-wobble' widget"
,
[
'the'
,
' '
,
"'wibble-"
,
"wobble'"
,
' '
,
'widget'
])
self
.
check_split
(
'the "wibble-wobble" widget'
,
[
'the'
,
' '
,
'"wibble-'
,
'wobble"'
,
' '
,
'widget'
])
self
.
check_split
(
"the (wibble-wobble) widget"
,
[
'the'
,
' '
,
"(wibble-"
,
"wobble)"
,
' '
,
'widget'
])
self
.
check_split
(
"the ['wibble-wobble'] widget"
,
[
'the'
,
' '
,
"['wibble-"
,
"wobble']"
,
' '
,
'widget'
])
def
test_funky_parens
(
self
):
def
test_funky_parens
(
self
):
# Second part of SF bug #596434: long option strings inside
# Second part of SF bug #596434: long option strings inside
# parentheses.
# parentheses.
...
...
Lib/textwrap.py
Dosyayı görüntüle @
6186410d
...
@@ -79,11 +79,11 @@ class TextWrapper:
...
@@ -79,11 +79,11 @@ class TextWrapper:
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
# (after stripping out empty strings).
# (after stripping out empty strings).
wordsep_re
=
re
.
compile
(
r'(\s+|'
# any whitespace
wordsep_re
=
re
.
compile
(
r'(\s+|'
# any whitespace
r'
-*\w{2,}-(?=\w{2,})|'
# hyphenated words
r'
[^\s\w]*\w{2,}-(?=\w{2,})|'
# hyphenated words
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))'
)
# em-dash
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))'
)
# em-dash
# XXX
will there be a locale-or-charset-aware version of
# XXX
this is not locale- or charset-aware -- string.lowercase
#
string.lowercase in 2.3?
#
is US-ASCII only (and therefore English-only)
sentence_end_re
=
re
.
compile
(
r'[
%
s]'
# lowercase letter
sentence_end_re
=
re
.
compile
(
r'[
%
s]'
# lowercase letter
r'[\.\!\?]'
# sentence-ending punct.
r'[\.\!\?]'
# sentence-ending punct.
r'[\"\']?'
# optional end-of-quote
r'[\"\']?'
# optional end-of-quote
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment