| |
- __builtin__.object
-
- ATR
class ATR(__builtin__.object) |
|
Automatic Text Replacer - is a class, created to make multiple replacements
in the content or names of text file.
It can make plain replacements, or use ATG templates to do something more complex. |
|
Methods defined here:
- __init__(self, files)
- Constructor
- clear_replacements(self)
- Removes all replacements.
- log(self, string)
- Print information
- plain_replace(self, pattern, string, regexp=False)
- Replaces the given pattern with string in files.
- replace_in_names(self)
- Do replacement, but in file names instead of file content. Returns the list of new file names,
you can use it with writeNewFiles() method.
- templated_replace(self, pattern, template, data, keyFormat='filename', regexp=False)
- Replaces the given pattern with data formated by template.
Valid values for keyFormat:
filename - take data rows by filename(path ignored), key value of the data row should store the filename.
fullname - as filename, but with path.
index - take data rows in order, key value of the data row should store the index. Indexes starts with 0.
If filename or index cannot be found in data keys, pattern will not be replaced.
- write_in_place(self)
- Do replacement and save the files
- write_new_files(self, outfiles)
- Do replacement, but save to given files instead of the original ones.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |