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
bff5bb3d
Commit
bff5bb3d
authored
Mar 02, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use fnmatch; read ".xxcign" for additional patterns to ignore.
parent
dbd83aa4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
Tools/scripts/xxci.py
Tools/scripts/xxci.py
+39
-13
No files found.
Tools/scripts/xxci.py
View file @
bff5bb3d
...
...
@@ -7,9 +7,11 @@
import
sys
import
posix
import
stat
from
stat
import
*
import
path
import
commands
import
fnmatch
import
string
EXECMAGIC
=
'
\
001
\
140
\
000
\
010
'
...
...
@@ -19,34 +21,57 @@ def getargs():
args
=
sys
.
argv
[
1
:]
if
args
:
return
args
print
'No arguments, checking almost *'
print
'No arguments, checking almost *, in "ls -t" order'
list
=
[]
for
file
in
posix
.
listdir
(
'.'
):
if
not
skipfile
(
file
):
args
.
append
(
file
)
if
not
args
:
list
.
append
((
getmtime
(
file
),
file
))
list
.
sort
()
if
not
list
:
print
'Nothing to do -- exit 1'
sys
.
exit
(
1
)
args
.
sort
()
list
.
sort
()
list
.
reverse
()
for
mtime
,
file
in
list
:
args
.
append
(
file
)
return
args
def
getmtime
(
file
):
try
:
st
=
posix
.
stat
(
file
)
return
st
[
ST_MTIME
]
except
posix
.
error
:
return
-
1
badnames
=
[
'tags'
,
'TAGS'
,
'xyzzy'
,
'nohup.out'
,
'core'
]
badprefixes
=
[
'.'
,
','
,
'@'
,
'#'
,
'o.'
]
badsuffixes
=
\
[
'~'
,
'.a'
,
'.o'
,
'.old'
,
'.bak'
,
'.orig'
,
'.new'
,
'.prev'
,
'.not'
,
\
'.pyc'
,
'.elc'
]
# XXX Should generalize even more to use fnmatch!
def
setup
():
global
ignore
ignore
=
badnames
[:]
for
p
in
badprefixes
:
ignore
.
append
(
p
+
'*'
)
for
p
in
badsuffixes
:
ignore
.
append
(
'*'
+
p
)
try
:
f
=
open
(
'.xxcign'
,
'r'
)
except
IOError
:
return
ignore
=
ignore
+
string
.
split
(
f
.
read
())
def
skipfile
(
file
):
if
file
in
badnames
or
\
badprefix
(
file
)
or
badsuffix
(
file
)
or
\
path
.
islink
(
file
)
or
path
.
isdir
(
file
):
return
1
# Skip huge files -- probably binaries.
for
p
in
ignore
:
if
fnmatch
.
fnmatch
(
file
,
p
):
return
1
try
:
st
=
posix
.
stat
(
file
)
st
=
posix
.
l
stat
(
file
)
except
posix
.
error
:
return
1
# Doesn't exist -- skip it
if
st
[
stat
.
ST_SIZE
]
>=
MAXSIZE
:
return
1
# Skip non-plain files.
if
not
S_ISREG
(
st
[
ST_MODE
]):
return
1
# Skip huge files -- probably binaries.
if
st
[
ST_SIZE
]
>=
MAXSIZE
:
return
1
# Skip executables
try
:
data
=
open
(
file
,
'r'
).
read
(
len
(
EXECMAGIC
))
...
...
@@ -86,4 +111,5 @@ def askyesno(prompt):
s
=
raw_input
(
prompt
)
return
s
in
[
'y'
,
'yes'
]
setup
()
go
(
getargs
())
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