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
18cb9498
Kaydet (Commit)
18cb9498
authored
Eki 10, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bring old demo up-to-date.
üst
58d2f268
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
32 deletions
+31
-32
pp.py
Demo/scripts/pp.py
+31
-32
No files found.
Demo/scripts/pp.py
Dosyayı görüntüle @
18cb9498
...
...
@@ -22,7 +22,6 @@
# - except for -n/-p, run directly from the file if at all possible
import
sys
import
string
import
getopt
FS
=
''
...
...
@@ -36,7 +35,7 @@ PFLAG = 0
try
:
optlist
,
ARGS
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'acde:F:np'
)
except
getopt
.
error
,
msg
:
sys
.
stderr
.
write
(
sys
.
argv
[
0
]
+
': '
+
msg
+
'
\n
'
)
sys
.
stderr
.
write
(
'
%
s:
%
s
\n
'
%
(
sys
.
argv
[
0
],
msg
)
)
sys
.
exit
(
2
)
for
option
,
optarg
in
optlist
:
...
...
@@ -47,7 +46,7 @@ for option, optarg in optlist:
elif
option
==
'-d'
:
DFLAG
=
1
elif
option
==
'-e'
:
for
line
in
string
.
splitfields
(
optarg
,
'
\n
'
):
for
line
in
optarg
.
split
(
'
\n
'
):
SCRIPT
.
append
(
line
)
elif
option
==
'-F'
:
FS
=
optarg
...
...
@@ -81,31 +80,31 @@ if CFLAG:
elif
NFLAG
:
# Note that it is on purpose that AFLAG and PFLAG are
# tested dynamically each time through the loop
prologue
=
[
\
'LINECOUNT = 0'
,
\
'for FILE in ARGS:'
,
\
'
\t
if FILE ==
\'
-
\'
:'
,
\
'
\t
\t
FP = sys.stdin'
,
\
'
\t
else:'
,
\
'
\t
\t
FP = open(FILE,
\'
r
\'
)'
,
\
'
\t
LINENO = 0'
,
\
'
\t
while 1:'
,
\
'
\t
\t
LINE = FP.readline()'
,
\
'
\t
\t
if not LINE: break'
,
\
'
\t
\t
LINENO = LINENO + 1'
,
\
'
\t
\t
LINECOUNT = LINECOUNT + 1'
,
\
'
\t
\t
L = LINE[:-1]'
,
\
'
\t
\t
aflag = AFLAG'
,
\
'
\t
\t
if aflag:'
,
\
'
\t
\t
\t
if FS: F =
string.splitfields(L, FS)'
,
\
'
\t
\t
\t
else: F =
string.split(L)'
\
prologue
=
[
'LINECOUNT = 0'
,
'for FILE in ARGS:'
,
'
\t
if FILE ==
\'
-
\'
:'
,
'
\t
\t
FP = sys.stdin'
,
'
\t
else:'
,
'
\t
\t
FP = open(FILE,
\'
r
\'
)'
,
'
\t
LINENO = 0'
,
'
\t
while 1:'
,
'
\t
\t
LINE = FP.readline()'
,
'
\t
\t
if not LINE: break'
,
'
\t
\t
LINENO = LINENO + 1'
,
'
\t
\t
LINECOUNT = LINECOUNT + 1'
,
'
\t
\t
L = LINE[:-1]'
,
'
\t
\t
aflag = AFLAG'
,
'
\t
\t
if aflag:'
,
'
\t
\t
\t
if FS: F =
L.split(FS)'
,
'
\t
\t
\t
else: F =
L.split()'
]
epilogue
=
[
\
'
\t
\t
if not PFLAG: continue'
,
\
'
\t
\t
if aflag:'
,
\
'
\t
\t
\t
if FS: print
string.joinfields(F, FS)'
,
\
'
\t
\t
\t
else: print
string.join(F)'
,
\
'
\t
\t
else: print L'
,
\
epilogue
=
[
'
\t
\t
if not PFLAG: continue'
,
'
\t
\t
if aflag:'
,
'
\t
\t
\t
if FS: print
FS.join(F)'
,
'
\t
\t
\t
else: print
\'
\'
.join(F)'
,
'
\t
\t
else: print L'
,
]
else
:
prologue
=
[
'if 1:'
]
...
...
@@ -114,10 +113,10 @@ else:
# Note that we indent using tabs only, so that any indentation style
# used in 'command' will come out right after re-indentation.
program
=
string
.
joinfields
(
prologue
,
'
\n
'
)
+
'
\n
'
program
=
'
\n
'
.
join
(
prologue
)
+
'
\n
'
for
line
in
SCRIPT
:
program
=
program
+
(
'
\t
\t
'
+
line
+
'
\n
'
)
program
=
program
+
(
string
.
joinfields
(
epilogue
,
'
\n
'
)
+
'
\n
'
)
program
+=
'
\t
\t
'
+
line
+
'
\n
'
program
+=
'
\n
'
.
join
(
epilogue
)
+
'
\n
'
import
tempfile
fp
=
tempfile
.
NamedTemporaryFile
()
...
...
@@ -125,6 +124,6 @@ fp.write(program)
fp
.
flush
()
if
DFLAG
:
import
pdb
pdb
.
run
(
'execfile(
%
r)'
%
(
tfn
,))
pdb
.
run
(
'execfile(
%
r)'
%
(
fp
.
name
,))
else
:
execfile
(
tfn
)
execfile
(
fp
.
name
)
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