dabo Commit
Revision 2576
Date: 2006-12-21 13:34:36 -0800 (Thu, 21 Dec 2006)
Author: Ed
Changed:
U branches/stable/dabo/lib/untabify.py
Log:
Added the 'saveBackup' parameter to the process method.
Diff:
Modified: branches/stable/dabo/lib/untabify.py
===================================================================
--- branches/stable/dabo/lib/untabify.py 2006-12-21 21:31:39 UTC (rev
2575)
+++ branches/stable/dabo/lib/untabify.py 2006-12-21 21:34:36 UTC (rev
2576)
@@ -23,7 +23,7 @@
for filename in args:
process(filename, tabsize)
-def process(filename, tabsize):
+def process(filename, tabsize, saveBackup=True):
try:
f = open(filename)
text = f.read()
@@ -34,19 +34,20 @@
newtext = text.expandtabs(tabsize)
if newtext == text:
return
- backup = filename + "~"
- try:
- os.unlink(backup)
- except os.error:
- pass
- try:
- os.rename(filename, backup)
- except os.error:
- pass
+ if saveBackup:
+ backup = filename + "~"
+ try:
+ os.unlink(backup)
+ except os.error:
+ pass
+ try:
+ os.rename(filename, backup)
+ except os.error:
+ pass
f = open(filename, "w")
f.write(newtext)
f.close()
- print filename
+# print filename
if __name__ == '__main__':
main()
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev