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
c1d3096a
Kaydet (Commit)
c1d3096a
authored
Mar 05, 2005
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines.
üst
dce2f360
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
test_textwrap.py
Lib/test/test_textwrap.py
+18
-0
textwrap.py
Lib/textwrap.py
+4
-3
No files found.
Lib/test/test_textwrap.py
Dosyayı görüntüle @
c1d3096a
...
@@ -165,6 +165,24 @@ What a mess!
...
@@ -165,6 +165,24 @@ What a mess!
[
"this-is-a-useful-feature-for-reformatting-"
,
[
"this-is-a-useful-feature-for-reformatting-"
,
"posts-from-tim-peters'ly"
])
"posts-from-tim-peters'ly"
])
def
test_hyphenated_numbers
(
self
):
# Test that hyphenated numbers (eg. dates) are not broken like words.
text
=
(
"Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was
\n
"
"released on 1994-02-15."
)
self
.
check_wrap
(
text
,
30
,
[
'Python 1.0.0 was released on'
,
'1994-01-26. Python 1.0.1 was'
,
'released on 1994-02-15.'
])
self
.
check_wrap
(
text
,
40
,
[
'Python 1.0.0 was released on 1994-01-26.'
,
'Python 1.0.1 was released on 1994-02-15.'
])
text
=
"I do all my shopping at 7-11."
self
.
check_wrap
(
text
,
25
,
[
"I do all my shopping at"
,
"7-11."
])
self
.
check_wrap
(
text
,
27
,
[
"I do all my shopping at"
,
"7-11."
])
self
.
check_wrap
(
text
,
29
,
[
"I do all my shopping at 7-11."
])
def
test_em_dash
(
self
):
def
test_em_dash
(
self
):
# Test text with em-dashes
# Test text with em-dashes
text
=
"Em-dashes should be written -- thus."
text
=
"Em-dashes should be written -- thus."
...
...
Lib/textwrap.py
Dosyayı görüntüle @
c1d3096a
...
@@ -78,9 +78,10 @@ class TextWrapper:
...
@@ -78,9 +78,10 @@ class TextWrapper:
# splits into
# splits into
# 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\w]*\w{2,}-(?=\w{2,})|'
# hyphenated words
r'(\s+|'
# any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))'
)
# em-dash
r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|'
# hyphenated words
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))'
)
# em-dash
# XXX this is not locale- or charset-aware -- string.lowercase
# XXX this is not locale- or charset-aware -- string.lowercase
# is US-ASCII only (and therefore English-only)
# is US-ASCII only (and therefore English-only)
...
...
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