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
48aa84b2
Kaydet (Commit)
48aa84b2
authored
Eki 27, 2004
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update optparse module and test suite to Optik 1.5a2.
üst
99b55482
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
18 deletions
+23
-18
optparse.py
Lib/optparse.py
+23
-18
test_optparse.py
Lib/test/test_optparse.py
+0
-0
No files found.
Lib/optparse.py
Dosyayı görüntüle @
48aa84b2
...
...
@@ -16,7 +16,7 @@ For support, use the optik-users@lists.sourceforge.net mailing list
# Python developers: please do not make changes to this file, since
# it is automatically generated from the Optik source code.
__version__
=
"1.5a
1
"
__version__
=
"1.5a
2
"
__all__
=
[
'Option'
,
'SUPPRESS_HELP'
,
...
...
@@ -76,10 +76,10 @@ def _repr(self):
# This file was generated from:
# Id: option_parser.py
,v 1.67 2004/07/24 23:21:21 gward Exp
# Id: option.py
,v 1.33 2004/07/24 23:21:21 gward Exp
# Id: help.py
,v 1.15 2004/07/24 23:21:21 gward Exp
# Id: errors.py
,v 1.9 2004/07/24 23:21:21 gward Exp
# Id: option_parser.py
421 2004-10-26 00:45:16Z greg
# Id: option.py
422 2004-10-26 00:53:47Z greg
# Id: help.py
367 2004-07-24 23:21:21Z gward
# Id: errors.py
367 2004-07-24 23:21:21Z gward
class
OptParseError
(
Exception
):
def
__init__
(
self
,
msg
):
...
...
@@ -436,11 +436,16 @@ class Option:
"count"
)
# The set of actions for which it makes sense to supply a value
# type, ie. wh
ere we expect an argument to this option
.
# type, ie. wh
ich may consume an argument from the command line
.
TYPED_ACTIONS
=
(
"store"
,
"append"
,
"callback"
)
# The set of actions which *require* a value type, ie. that
# always consume an argument from the command line.
ALWAYS_TYPED_ACTIONS
=
(
"store"
,
"append"
)
# The set of known types for option parsers. Again, listed here for
# constructor argument validation.
TYPES
=
(
"string"
,
"int"
,
"long"
,
"float"
,
"complex"
,
"choice"
)
...
...
@@ -557,9 +562,7 @@ class Option:
def
_check_type
(
self
):
if
self
.
type
is
None
:
# XXX should factor out another class attr here: list of
# actions that *require* a type
if
self
.
action
in
(
"store"
,
"append"
):
if
self
.
action
in
self
.
ALWAYS_TYPED_ACTIONS
:
if
self
.
choices
is
not
None
:
# The "choices" attribute implies "choice" type.
self
.
type
=
"choice"
...
...
@@ -723,10 +726,10 @@ class Option:
self
.
callback
(
self
,
opt
,
value
,
parser
,
*
args
,
**
kwargs
)
elif
action
==
"help"
:
parser
.
print_help
()
sys
.
exit
(
0
)
parser
.
exit
(
)
elif
action
==
"version"
:
parser
.
print_version
()
sys
.
exit
(
0
)
parser
.
exit
(
)
else
:
raise
RuntimeError
,
"unknown action
%
r"
%
self
.
action
...
...
@@ -877,7 +880,7 @@ class OptionContainer:
self
.
defaults
=
parser
.
defaults
def
set_conflict_handler
(
self
,
handler
):
if
handler
not
in
(
"
ignore"
,
"
error"
,
"resolve"
):
if
handler
not
in
(
"error"
,
"resolve"
):
raise
ValueError
,
"invalid conflict_resolution value
%
r"
%
handler
self
.
conflict_handler
=
handler
...
...
@@ -901,14 +904,12 @@ class OptionContainer:
if
conflict_opts
:
handler
=
self
.
conflict_handler
if
handler
==
"ignore"
:
# behaviour for Optik 1.0, 1.1
pass
elif
handler
==
"error"
:
# new in 1.2
if
handler
==
"error"
:
raise
OptionConflictError
(
"conflicting option string(s):
%
s"
%
", "
.
join
([
co
[
0
]
for
co
in
conflict_opts
]),
option
)
elif
handler
==
"resolve"
:
# new in 1.2
elif
handler
==
"resolve"
:
for
(
opt
,
c_option
)
in
conflict_opts
:
if
opt
.
startswith
(
"--"
):
c_option
.
_long_opts
.
remove
(
opt
)
...
...
@@ -1442,6 +1443,11 @@ class OptionParser (OptionContainer):
def
get_description
(
self
):
return
self
.
expand_prog_name
(
self
.
description
)
def
exit
(
self
,
status
=
0
,
msg
=
None
):
if
msg
:
sys
.
stderr
.
write
(
msg
)
sys
.
exit
(
status
)
def
error
(
self
,
msg
):
"""error(msg : string)
...
...
@@ -1450,8 +1456,7 @@ class OptionParser (OptionContainer):
should either exit or raise an exception.
"""
self
.
print_usage
(
sys
.
stderr
)
sys
.
stderr
.
write
(
"
%
s: error:
%
s
\n
"
%
(
self
.
get_prog_name
(),
msg
))
sys
.
exit
(
2
)
# command-line usage error
self
.
exit
(
2
,
"
%
s: error:
%
s
\n
"
%
(
self
.
get_prog_name
(),
msg
))
def
get_usage
(
self
):
if
self
.
usage
:
...
...
Lib/test/test_optparse.py
Dosyayı görüntüle @
48aa84b2
This diff is collapsed.
Click to expand it.
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