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
eda5583b
Kaydet (Commit)
eda5583b
authored
Mar 20, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Mark getopt error messages as localizable (fixes #11371).
Patch by Filip Gruszczyński.
üst
16e6f4c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
getopt.py
Lib/getopt.py
+8
-7
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/getopt.py
Dosyayı görüntüle @
eda5583b
...
...
@@ -19,7 +19,7 @@ option involved with the exception.
# Gerrit Holl <gerrit@nl.linux.org> moved the string-based exceptions
# to class-based exceptions.
#
# Peter
Ã
strand <astrand@lysator.liu.se> added gnu_getopt().
# Peter
Å
strand <astrand@lysator.liu.se> added gnu_getopt().
#
# TODO for gnu_getopt():
#
...
...
@@ -34,6 +34,7 @@ option involved with the exception.
__all__
=
[
"GetoptError"
,
"error"
,
"getopt"
,
"gnu_getopt"
]
import
os
from
gettext
import
gettext
as
_
class
GetoptError
(
Exception
):
opt
=
''
...
...
@@ -153,10 +154,10 @@ def do_longs(opts, opt, longopts, args):
if
has_arg
:
if
optarg
is
None
:
if
not
args
:
raise
GetoptError
(
'option --
%
s requires argument'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --
%
s requires argument'
)
%
opt
,
opt
)
optarg
,
args
=
args
[
0
],
args
[
1
:]
elif
optarg
is
not
None
:
raise
GetoptError
(
'option --
%
s must not have an argument'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --
%
s must not have an argument'
)
%
opt
,
opt
)
opts
.
append
((
'--'
+
opt
,
optarg
or
''
))
return
opts
,
args
...
...
@@ -166,7 +167,7 @@ def do_longs(opts, opt, longopts, args):
def
long_has_args
(
opt
,
longopts
):
possibilities
=
[
o
for
o
in
longopts
if
o
.
startswith
(
opt
)]
if
not
possibilities
:
raise
GetoptError
(
'option --
%
s not recognized'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --
%
s not recognized'
)
%
opt
,
opt
)
# Is there an exact match?
if
opt
in
possibilities
:
return
False
,
opt
...
...
@@ -176,7 +177,7 @@ def long_has_args(opt, longopts):
if
len
(
possibilities
)
>
1
:
# XXX since possibilities contains all valid continuations, might be
# nice to work them into the error msg
raise
GetoptError
(
'option --
%
s not a unique prefix'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --
%
s not a unique prefix'
)
%
opt
,
opt
)
assert
len
(
possibilities
)
==
1
unique_match
=
possibilities
[
0
]
has_arg
=
unique_match
.
endswith
(
'='
)
...
...
@@ -190,7 +191,7 @@ def do_shorts(opts, optstring, shortopts, args):
if
short_has_arg
(
opt
,
shortopts
):
if
optstring
==
''
:
if
not
args
:
raise
GetoptError
(
'option -
%
s requires argument'
%
opt
,
raise
GetoptError
(
_
(
'option -
%
s requires argument'
)
%
opt
,
opt
)
optstring
,
args
=
args
[
0
],
args
[
1
:]
optarg
,
optstring
=
optstring
,
''
...
...
@@ -203,7 +204,7 @@ def short_has_arg(opt, shortopts):
for
i
in
range
(
len
(
shortopts
)):
if
opt
==
shortopts
[
i
]
!=
':'
:
return
shortopts
.
startswith
(
':'
,
i
+
1
)
raise
GetoptError
(
'option -
%
s not recognized'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option -
%
s not recognized'
)
%
opt
,
opt
)
if
__name__
==
'__main__'
:
import
sys
...
...
Misc/NEWS
Dosyayı görüntüle @
eda5583b
...
...
@@ -75,6 +75,9 @@ Core and Builtins
Library
-------
-
Issue
#
11371
:
Mark
getopt
error
messages
as
localizable
.
Patch
by
Filip
Gruszczy
ń
ski
.
-
Issue
#
4391
:
Use
proper
gettext
plural
forms
in
optparse
.
-
Issue
#
11563
:
Connection
:
close
header
is
sent
by
requests
using
URLOpener
...
...
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