Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b5879ca2
Commit
b5879ca2
authored
Jul 01, 1999
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Relocating file to Lib/lib-old.
parent
85b56833
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
218 deletions
+0
-218
Lib/find.py
Lib/find.py
+0
-26
Lib/grep.py
Lib/grep.py
+0
-80
Lib/packmail.py
Lib/packmail.py
+0
-112
No files found.
Lib/find.py
deleted
100644 → 0
View file @
85b56833
import
fnmatch
import
os
_debug
=
0
_prune
=
[
'(*)'
]
def
find
(
pattern
,
dir
=
os
.
curdir
):
list
=
[]
names
=
os
.
listdir
(
dir
)
names
.
sort
()
for
name
in
names
:
if
name
in
(
os
.
curdir
,
os
.
pardir
):
continue
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
fnmatch
.
fnmatch
(
name
,
pattern
):
list
.
append
(
fullname
)
if
os
.
path
.
isdir
(
fullname
)
and
not
os
.
path
.
islink
(
fullname
):
for
p
in
_prune
:
if
fnmatch
.
fnmatch
(
name
,
p
):
if
_debug
:
print
"skip"
,
`fullname`
break
else
:
if
_debug
:
print
"descend into"
,
`fullname`
list
=
list
+
find
(
pattern
,
fullname
)
return
list
Lib/grep.py
deleted
100644 → 0
View file @
85b56833
# 'grep'
import
regex
from
regex_syntax
import
*
import
string
opt_show_where
=
0
opt_show_filename
=
0
opt_show_lineno
=
1
def
grep
(
pat
,
*
files
):
return
ggrep
(
RE_SYNTAX_GREP
,
pat
,
files
)
def
egrep
(
pat
,
*
files
):
return
ggrep
(
RE_SYNTAX_EGREP
,
pat
,
files
)
def
emgrep
(
pat
,
*
files
):
return
ggrep
(
RE_SYNTAX_EMACS
,
pat
,
files
)
def
ggrep
(
syntax
,
pat
,
files
):
if
len
(
files
)
==
1
and
type
(
files
[
0
])
==
type
([]):
files
=
files
[
0
]
global
opt_show_filename
opt_show_filename
=
(
len
(
files
)
!=
1
)
syntax
=
regex
.
set_syntax
(
syntax
)
try
:
prog
=
regex
.
compile
(
pat
)
finally
:
syntax
=
regex
.
set_syntax
(
syntax
)
for
filename
in
files
:
fp
=
open
(
filename
,
'r'
)
lineno
=
0
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
lineno
=
lineno
+
1
if
prog
.
search
(
line
)
>=
0
:
showline
(
filename
,
lineno
,
line
,
prog
)
fp
.
close
()
def
pgrep
(
pat
,
*
files
):
if
len
(
files
)
==
1
and
type
(
files
[
0
])
==
type
([]):
files
=
files
[
0
]
global
opt_show_filename
opt_show_filename
=
(
len
(
files
)
!=
1
)
import
re
prog
=
re
.
compile
(
pat
)
for
filename
in
files
:
fp
=
open
(
filename
,
'r'
)
lineno
=
0
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
lineno
=
lineno
+
1
if
prog
.
search
(
line
):
showline
(
filename
,
lineno
,
line
,
prog
)
fp
.
close
()
def
showline
(
filename
,
lineno
,
line
,
prog
):
if
line
[
-
1
:]
==
'
\
n
'
:
line
=
line
[:
-
1
]
if
opt_show_lineno
:
prefix
=
string
.
rjust
(
`lineno`
,
3
)
+
': '
else
:
prefix
=
''
if
opt_show_filename
:
prefix
=
filename
+
': '
+
prefix
print
prefix
+
line
if
opt_show_where
:
start
,
end
=
prog
.
regs
()[
0
]
line
=
line
[:
start
]
if
'
\
t
'
not
in
line
:
prefix
=
' '
*
(
len
(
prefix
)
+
start
)
else
:
prefix
=
' '
*
len
(
prefix
)
for
c
in
line
:
if
c
<>
'
\
t
'
:
c
=
' '
prefix
=
prefix
+
c
if
start
==
end
:
prefix
=
prefix
+
'
\
\
'
else
:
prefix
=
prefix
+
'^'
*
(
end
-
start
)
print
prefix
Lib/packmail.py
deleted
100644 → 0
View file @
85b56833
# Module 'packmail' -- create a self-unpacking shell archive.
# This module works on UNIX and on the Mac; the archives can unpack
# themselves only on UNIX.
import
os
from
stat
import
ST_MTIME
import
string
# Print help
def
help
():
print
'All fns have a file open for writing as first parameter'
print
'pack(f, fullname, name): pack fullname as name'
print
'packsome(f, directory, namelist): selected files from directory'
print
'packall(f, directory): pack all files from directory'
print
'packnotolder(f, directory, name): pack all files from directory'
print
' that are not older than a file there'
print
'packtree(f, directory): pack entire directory tree'
# Pack one file
def
pack
(
outfp
,
file
,
name
):
fp
=
open
(
file
,
'r'
)
outfp
.
write
(
'echo '
+
name
+
'
\
n
'
)
outfp
.
write
(
'sed "s/^X//" >"'
+
name
+
'" <<"!"
\
n
'
)
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
if
line
[
-
1
:]
<>
'
\
n
'
:
line
=
line
+
'
\
n
'
outfp
.
write
(
'X'
+
line
)
outfp
.
write
(
'!
\
n
'
)
fp
.
close
()
# Pack some files from a directory
def
packsome
(
outfp
,
dirname
,
names
):
for
name
in
names
:
print
name
file
=
os
.
path
.
join
(
dirname
,
name
)
pack
(
outfp
,
file
,
name
)
# Pack all files from a directory
def
packall
(
outfp
,
dirname
):
names
=
os
.
listdir
(
dirname
)
try
:
names
.
remove
(
'.'
)
except
:
pass
try
:
names
.
remove
(
'..'
)
except
:
pass
names
.
sort
()
packsome
(
outfp
,
dirname
,
names
)
# Pack all files from a directory that are not older than a give one
def
packnotolder
(
outfp
,
dirname
,
oldest
):
names
=
os
.
listdir
(
dirname
)
try
:
names
.
remove
(
'.'
)
except
:
pass
try
:
names
.
remove
(
'..'
)
except
:
pass
oldest
=
os
.
path
.
join
(
dirname
,
oldest
)
st
=
os
.
stat
(
oldest
)
mtime
=
st
[
ST_MTIME
]
todo
=
[]
for
name
in
names
:
print
name
,
'...'
,
st
=
os
.
stat
(
os
.
path
.
join
(
dirname
,
name
))
if
st
[
ST_MTIME
]
>=
mtime
:
print
'Yes.'
todo
.
append
(
name
)
else
:
print
'No.'
todo
.
sort
()
packsome
(
outfp
,
dirname
,
todo
)
# Pack a whole tree (no exceptions)
def
packtree
(
outfp
,
dirname
):
print
'packtree'
,
dirname
outfp
.
write
(
'mkdir '
+
unixfix
(
dirname
)
+
'
\
n
'
)
names
=
os
.
listdir
(
dirname
)
try
:
names
.
remove
(
'.'
)
except
:
pass
try
:
names
.
remove
(
'..'
)
except
:
pass
subdirs
=
[]
for
name
in
names
:
fullname
=
os
.
path
.
join
(
dirname
,
name
)
if
os
.
path
.
isdir
(
fullname
):
subdirs
.
append
(
fullname
)
else
:
print
'pack'
,
fullname
pack
(
outfp
,
fullname
,
unixfix
(
fullname
))
for
subdirname
in
subdirs
:
packtree
(
outfp
,
subdirname
)
def
unixfix
(
name
):
comps
=
string
.
splitfields
(
name
,
os
.
sep
)
res
=
''
for
comp
in
comps
:
if
comp
:
if
res
:
res
=
res
+
'/'
res
=
res
+
comp
return
res
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