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
b53e6783
Kaydet (Commit)
b53e6783
authored
Ock 24, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Initial revision
üst
177dd807
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
cmd.py
Lib/cmd.py
+65
-0
No files found.
Lib/cmd.py
0 → 100644
Dosyayı görüntüle @
b53e6783
# A generic class to build line-oriented command interpreters
import
string
import
sys
import
linecache
PROMPT
=
'(Cmd) '
IDENTCHARS
=
string
.
letters
+
string
.
digits
+
'_'
class
Cmd
:
def
init
(
self
):
self
.
prompt
=
PROMPT
self
.
identchars
=
IDENTCHARS
self
.
lastcmd
=
''
return
self
def
cmdloop
(
self
):
stop
=
None
while
not
stop
:
try
:
line
=
raw_input
(
self
.
prompt
)
except
EOFError
:
line
=
'EOF'
stop
=
self
.
onecmd
(
line
)
def
onecmd
(
self
,
line
):
line
=
string
.
strip
(
line
)
if
not
line
:
line
=
self
.
lastcmd
print
line
else
:
self
.
lastcmd
=
line
i
,
n
=
0
,
len
(
line
)
while
i
<
n
and
line
[
i
]
in
self
.
identchars
:
i
=
i
+
1
cmd
,
arg
=
line
[:
i
],
string
.
strip
(
line
[
i
:])
if
cmd
==
''
:
return
self
.
default
(
line
)
else
:
try
:
func
=
eval
(
'self.do_'
+
cmd
)
except
AttributeError
:
return
self
.
default
(
line
)
return
func
(
arg
)
def
default
(
self
,
line
):
print
'*** Unknown syntax:'
,
line
def
do_help
(
self
,
arg
):
if
arg
:
# XXX check arg syntax
try
:
func
=
eval
(
'self.help_'
+
arg
)
except
:
print
'*** No help on'
,
`arg`
return
func
()
else
:
import
getattr
names
=
getattr
.
dir
(
self
)
cmds
=
[]
for
name
in
names
:
if
name
[:
3
]
==
'do_'
:
cmds
.
append
(
name
[
3
:])
print
cmds
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