summaryrefslogtreecommitdiff
path: root/Mac/scripts/findgremlins.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-11-19 14:34:18 +0000
committerJack Jansen <jack.jansen@cwi.nl>2003-11-19 14:34:18 +0000
commit28ecf70db57828db2ca279643bf9aeca7662f35c (patch)
tree09b7767bbc411f85313b58d6fe7e5e67d9392973 /Mac/scripts/findgremlins.py
parent6045b9c93511c767f6cfa2d2fa299c76181acd9b (diff)
downloadcpython-git-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.gz
Getting rid of support for MacOS9 and earlier. This is the first step,
and the biggest in size, but probably the easiest. Hunting through the source code comes next.
Diffstat (limited to 'Mac/scripts/findgremlins.py')
-rw-r--r--Mac/scripts/findgremlins.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/Mac/scripts/findgremlins.py b/Mac/scripts/findgremlins.py
deleted file mode 100644
index 3569c77992..0000000000
--- a/Mac/scripts/findgremlins.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""findgremlins - Search through a folder and subfolders for
-text files that have characters with bit 8 set, and print
-the filename and a bit of context.
-
-By Just, with a little glue by Jack"""
-
-import EasyDialogs
-import MacOS
-import re
-import os
-import string
-import sys
-
-xpat = re.compile(r"[\200-\377]")
-
-def walk(top, recurse=1):
- if os.path.isdir(top):
- if recurse:
- for name in os.listdir(top):
- path = os.path.join(top, name)
- walk(path)
- else:
- cr, tp = MacOS.GetCreatorAndType(top)
- if tp in ('TEXT', '\0\0\0\0') and top[-4:] <> ".hqx":
- data = open(top).read()
- badcount = 0
- for ch in data[:256]:
- if ord(ch) == 0 or ord(ch) >= 0200:
- badcount = badcount + 1
- if badcount > 16:
- print `top`, 'appears to be a binary file'
- return
- pos = 0
- gotone = 0
- while 1:
- m = xpat.search(data, pos)
- if m is None:
- break
- if not gotone:
- print `top`
- gotone = 1
- [(i, j)] = m.regs
- print " ", string.replace(data[i-15:j+15], '\n', ' ')
- pos = j
-
-def main():
- if sys.argv[1:]:
- for pathname in sys.argv[1:]:
- walk(pathname)
- else:
- pathname = EasyDialogs.AskFolder()
- if pathname:
- walk(pathname)
-
-if __name__ == '__main__':
- main()
-