d2u
index
/home/reg/LJarticles/eric3/Examples/d2u/d2u.py

Convert dos -> unix text replacing line endings.
 
Usage:  d2u file [ file ... ]
 
NOTE: 
1) This program replaces files IN-PLACE. This 
makes it very dangerous if the process is 
interrupted -- a file can be truncated. 
2) This program checks if the file has already been
converted. If so, it does not do it again.
3) If one or more files can not be read, an error
message is issued and the rest of the files in the 
list are converted.
 
This utility is meant to be used on a list of
files, as is found in a directory. So you can
use this tool to convert some or all files in 
a directory.

 
Modules
       
os
sys

 
Classes
       
__builtin__.object
ProcessFile

 
class ProcessFile(__builtin__.object)
     Methods defined here:
__init__(self, fn)
Open file and read all its lines 
into a cache which will be used later.
needsConverting(self)
Check if any lines need converting. 
    
    A file needs converting if every line ends 
    in '
' else it is already in the right 
    format. This check prevents converting an 
    already converted file.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ProcessFile' objects>
list of weak references to the object (if defined)

 
Functions
       
mymain(args)
Loop thru each file in the command line list, 
trying to convert each file in turn.
usage()
Print usage for this tool.