| MECO™ API Reference
    | 
[ CLASS ] - Class to operate on template files. More...
 
  
| Public Member Functions | |
| def | __init__ (self) | 
| Constructor.  More... | |
| def | setFile (self, absFile) | 
| Set template file.  More... | |
| def | write (self, absFile, overwrite=False) | 
| Write replaced content into the output file.  More... | |
| def | replace (self, replaceData) | 
| Replace what needs to be replaced in the template file.  More... | |
| def | replaceByFunction (self, function) | 
| Replace what needs to be replaced in the template file by a custom function.  More... | |
| PROPERTIES | |
| def | replaceData (self) | 
| Replace data.  More... | |
| def | replacedContent (self) | 
| Replaced content.  More... | |
|  Public Member Functions inherited from mFileSystem.fileLib.File | |
| def | __init__ (self, path=None) | 
| Constructor.  More... | |
| def | __str__ (self) | 
| String representation.  More... | |
| def | asStr (self) | 
| Get string representation.  More... | |
| def | asDict (self) | 
| Get file information as dict instance.  More... | |
| def | update (self) | 
| Update information of the file in case it has been altered.  More... | |
| def | exists (self) | 
| Check whether the file exists.  More... | |
| def | rename (self, newName) | 
| Rename the file.  More... | |
| def | remove (self) | 
| Remove the file.  More... | |
| def | create (cls, path, overwrite=False, binary=False) | 
| Create a file and return a mFileSystem.fileLib.File instance for it.  More... | |
| def | file (self) | 
| Absolute path of the file.  More... | |
| def | directory (self) | 
| Directory where the file is located in.  More... | |
| def | fileName (self) | 
| Name of the file with it's extension.  More... | |
| def | baseName (self) | 
| Name of the file without extension, base name.  More... | |
| def | extension (self) | 
| File's extension.  More... | |
| def | size (self) | 
| File size in bytes.  More... | |
| def | sizeStr (self) | 
| File size as human readable string.  More... | |
| def | content (self) | 
| Content of the file.  More... | |
| def | copy (self, destinationFile, overwrite=False) | 
| Copy the file.  More... | |
| def | copyToPath (self, destinationPath, overwrite=False) | 
| Copy the file to given path.  More... | |
| def | writeLines (self, lines, append=True) | 
| Write given lines into the file.  More... | |
| def | read (self) | 
| Read content of the file.  More... | |
| def | readLines (self) | 
| Read lines.  More... | |
| def | lineCount (self) | 
| Get line count of the file.  More... | |
| Additional Inherited Members | |
|  Static Public Member Functions inherited from mFileSystem.fileLib.File | |
| def | fileExists (path) | 
| Check whether the given file exists.  More... | |
| def | getFileSizeAsStr (size, precision=2) | 
| Get given byte size in human readable string.  More... | |
| def | replaceExtension (path, newExtension) | 
| Replace given files extension with given extension.  More... | |
[ CLASS ] - Class to operate on template files.
This class allows you to read a template file and replace its content and write the changed content out into a file.
| def mFileSystem.templateFileLib.TemplateFile.__init__ | ( | self | ) | 
Constructor.
| N/A | 
| def mFileSystem.templateFileLib.TemplateFile.replaceData | ( | self | ) | 
Replace data.
| N/A | 
| def mFileSystem.templateFileLib.TemplateFile.replacedContent | ( | self | ) | 
Replaced content.
| N/A | 
| def mFileSystem.templateFileLib.TemplateFile.setFile | ( | self, | |
| absFile | |||
| ) | 
Set template file.
| absFile | [ str | None | in ] - Absolute path of a template file. | 
| N/A | 
False is the file doesn't exist, True otherwise. Reimplemented from mFileSystem.fileLib.File.
| def mFileSystem.templateFileLib.TemplateFile.write | ( | self, | |
| absFile, | |||
| overwrite = False | |||
| ) | 
Write replaced content into the output file.
| absFile | [ str | None | in ] - Absolute path of the output file. | 
| overwrite | [ bool | False | in ] - Whether existing absFilefile will be overwritten. | 
| IOError | - If absFileexists and overwrite argument provided False. | 
Reimplemented from mFileSystem.fileLib.File.
| def mFileSystem.templateFileLib.TemplateFile.replace | ( | self, | |
| replaceData | |||
| ) | 
Replace what needs to be replaced in the template file.
| replaceData | [ dict | None | in ] - Data, which will be used to replace whats in the template file. | 
| N/A | 
| def mFileSystem.templateFileLib.TemplateFile.replaceByFunction | ( | self, | |
| function | |||
| ) | 
Replace what needs to be replaced in the template file by a custom function.
Function must expect a string argument, which is the content of the template file and return edited content.
| function | [ object | None | in ] - A function object. | 
| RuntimeError | - If provided functionis not a callable. | 
 1.8.18
 1.8.18