mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-03 01:39:23 +01:00
Moved to tools/, since that's what they are.
This commit is contained in:
parent
01ee1169f0
commit
84ccdc2a8c
@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os, os.path
|
|
||||||
|
|
||||||
def removeFiles(_, dirname, names):
|
|
||||||
for name in names:
|
|
||||||
if name[-4:] in ('.pyc', 'pyo'):
|
|
||||||
os.remove(os.path.join(dirname, name))
|
|
||||||
elif name[-1] == '~':
|
|
||||||
os.remove(os.path.join(dirname, name))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
for name in os.listdir('logs'):
|
|
||||||
filename = os.path.join('logs', name)
|
|
||||||
if os.path.isfile(filename):
|
|
||||||
os.remove(filename)
|
|
||||||
os.path.walk(os.curdir, removeFiles, None)
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
|
@ -1,35 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
class MutableX:
|
|
||||||
def __init__(self):
|
|
||||||
self.x = None
|
|
||||||
|
|
||||||
def visit(bytesRemoved, dirname, names):
|
|
||||||
filenames = [os.path.join(dirname, s) for s in names if s.endswith('.py')]
|
|
||||||
for filename in filenames:
|
|
||||||
tmpname = filename + '.tmp'
|
|
||||||
tmpfd = file(tmpname, 'w')
|
|
||||||
fd = file(filename, 'r')
|
|
||||||
for line in fd:
|
|
||||||
stripped = line.rstrip()
|
|
||||||
bytesRemoved.x += len(line) - len(stripped)
|
|
||||||
tmpfd.write(stripped)
|
|
||||||
tmpfd.write('\n')
|
|
||||||
fd.close()
|
|
||||||
tmpfd.close()
|
|
||||||
os.rename(tmpname, filename)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import sys
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
dir = '.'
|
|
||||||
else:
|
|
||||||
dir = sys.argv[1]
|
|
||||||
x = MutableX()
|
|
||||||
x.x = 0
|
|
||||||
os.path.walk(dir, visit, x)
|
|
||||||
print '%s bytes removed.' % x.x
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
|
Loading…
Reference in New Issue
Block a user