@@ -12,7 +12,7 @@ License: GPLv3 | |||||
''' | ''' | ||||
from sys import argv | from sys import argv | ||||
from os.path import split | from os.path import split | ||||
from ktt import ATG, CSVData, TemplateV2 | |||||
from att import ATG, CSVData, TemplateV2 | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
if len(argv) == 3: | if len(argv) == 3: | ||||
@@ -30,15 +30,14 @@ class ATG(object): | |||||
else: | else: | ||||
self.multiple = False | self.multiple = False | ||||
def join_filename(self, path, name, extension): | |||||
''' | |||||
Returns a file name for given path, name and extension. | |||||
''' | |||||
if extension: | |||||
return join(unicode(path),name+'.'+extension) | |||||
else: | |||||
return join(unicode(path),name) | |||||
def join_filename(self, path, name, extension): | |||||
''' | |||||
Returns a file name for given path, name and extension. | |||||
''' | |||||
if extension: | |||||
return join(unicode(path),name+'.'+extension) | |||||
else: | |||||
return join(unicode(path),name) | |||||
def write_files(self, outputDir='.'): | def write_files(self, outputDir='.'): | ||||
''' | ''' | ||||
@@ -72,7 +71,7 @@ class ATG(object): | |||||
newpath = join(newpath, i) | newpath = join(newpath, i) | ||||
if not exists(join(unicode(outputDir),newpath)): | if not exists(join(unicode(outputDir),newpath)): | ||||
makedirs(join(unicode(outputDir),newpath)) | makedirs(join(unicode(outputDir),newpath)) | ||||
fname = self.join_filename(outputDir, name, extension) | |||||
fname = self.join_filename(outputDir, name, extension) | |||||
f = open(fname, 'w') | f = open(fname, 'w') | ||||
f.write(out.encode(encoding)) | f.write(out.encode(encoding)) | ||||
self.log(' Saved %s' % fname) | self.log(' Saved %s' % fname) | ||||
@@ -0,0 +1,62 @@ | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |||||
<html><head><title>Python: module att.atg</title> | |||||
</head><body bgcolor="#f0f0f8"> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |||||
<tr bgcolor="#7799ee"> | |||||
<td valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="att.html"><font color="#ffffff">att</font></a>.atg</strong></big></big></font></td | |||||
><td align=right valign=bottom | |||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/workbench/projects/att/att/atg.py">c:\workbench\projects\att\att\atg.py</a></font></td></tr></table> | |||||
<p><tt>Automatic Text Generator module for a Automatic Text Tools.<br> | |||||
<br> | |||||
(c) 2013 Ivan "Kai SD" Korystin <br> | |||||
<br> | |||||
License: GPLv3</tt></p> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ee77aa"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> | |||||
<td width="100%"><dl> | |||||
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.atg.html#ATG">ATG</a> | |||||
</font></dt></dl> | |||||
</dd> | |||||
</dl> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="ATG">class <strong>ATG</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Automatic Text Generator is a class, created to generate multiple<br> | |||||
text files from table data.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%">Methods defined here:<br> | |||||
<dl><dt><a name="ATG-__init__"><strong>__init__</strong></a>(self, data, template)</dt><dd><tt>Constructor.<br> | |||||
data - an instance of the data.Data class (i.e. CSVData)<br> | |||||
template - an instance of the template.Template class (i.e. TemplateV2)</tt></dd></dl> | |||||
<dl><dt><a name="ATG-join_filename"><strong>join_filename</strong></a>(self, path, name, extension)</dt><dd><tt>Returns a file name for given path, name and extension.</tt></dd></dl> | |||||
<dl><dt><a name="ATG-log"><strong>log</strong></a>(self, text)</dt><dd><tt>Print information</tt></dd></dl> | |||||
<dl><dt><a name="ATG-write_files"><strong>write_files</strong></a>(self, outputDir<font color="#909090">='.'</font>)</dt><dd><tt>Write generated files to the given directory.</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors defined here:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table></td></tr></table> | |||||
</body></html> |
@@ -0,0 +1,83 @@ | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |||||
<html><head><title>Python: module att.atr</title> | |||||
</head><body bgcolor="#f0f0f8"> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |||||
<tr bgcolor="#7799ee"> | |||||
<td valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="att.html"><font color="#ffffff">att</font></a>.atr</strong></big></big></font></td | |||||
><td align=right valign=bottom | |||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/workbench/projects/att/att/atr.py">c:\workbench\projects\att\att\atr.py</a></font></td></tr></table> | |||||
<p><tt>Automatic Text Replacer module for a Automatic Text Tools.<br> | |||||
<br> | |||||
(c) 2013 Ivan "Kai SD" Korystin <br> | |||||
<br> | |||||
License: GPLv3</tt></p> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#aa55cc"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> | |||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="re.html">re</a><br> | |||||
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ee77aa"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> | |||||
<td width="100%"><dl> | |||||
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.atr.html#ATR">ATR</a> | |||||
</font></dt></dl> | |||||
</dd> | |||||
</dl> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="ATR">class <strong>ATR</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Automatic Text Replacer - is a class, created to make multiple replacements<br> | |||||
in the content or names of text file.<br> | |||||
It can make plain replacements, or use ATG templates to do something more complex.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%">Methods defined here:<br> | |||||
<dl><dt><a name="ATR-__init__"><strong>__init__</strong></a>(self, files)</dt><dd><tt>Constructor</tt></dd></dl> | |||||
<dl><dt><a name="ATR-clear_replacements"><strong>clear_replacements</strong></a>(self)</dt><dd><tt>Removes all replacements.</tt></dd></dl> | |||||
<dl><dt><a name="ATR-log"><strong>log</strong></a>(self, string)</dt><dd><tt>Print information</tt></dd></dl> | |||||
<dl><dt><a name="ATR-plain_replace"><strong>plain_replace</strong></a>(self, pattern, string, regexp<font color="#909090">=False</font>)</dt><dd><tt>Replaces the given pattern with string in files.</tt></dd></dl> | |||||
<dl><dt><a name="ATR-replace_in_names"><strong>replace_in_names</strong></a>(self)</dt><dd><tt>Do replacement, but in file names instead of file content. Returns the list of new file names,<br> | |||||
you can use it with writeNewFiles() method.</tt></dd></dl> | |||||
<dl><dt><a name="ATR-templated_replace"><strong>templated_replace</strong></a>(self, pattern, template, data, keyFormat<font color="#909090">='filename'</font>, regexp<font color="#909090">=False</font>)</dt><dd><tt>Replaces the given pattern with data formated by template.<br> | |||||
Valid values for keyFormat:<br> | |||||
filename - take data rows by filename(path ignored), key value of the data row should store the filename.<br> | |||||
fullname - as filename, but with path.<br> | |||||
index - take data rows in order, key value of the data row should store the index. Indexes starts with 0.<br> | |||||
If filename or index cannot be found in data keys, pattern will not be replaced.</tt></dd></dl> | |||||
<dl><dt><a name="ATR-write_in_place"><strong>write_in_place</strong></a>(self)</dt><dd><tt>Do replacement and save the files</tt></dd></dl> | |||||
<dl><dt><a name="ATR-write_new_files"><strong>write_new_files</strong></a>(self, outfiles)</dt><dd><tt>Do replacement, but save to given files instead of the original ones.</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors defined here:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table></td></tr></table> | |||||
</body></html> |
@@ -0,0 +1,170 @@ | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |||||
<html><head><title>Python: module att.data</title> | |||||
</head><body bgcolor="#f0f0f8"> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |||||
<tr bgcolor="#7799ee"> | |||||
<td valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="att.html"><font color="#ffffff">att</font></a>.data</strong></big></big></font></td | |||||
><td align=right valign=bottom | |||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/workbench/projects/att/att/data.py">c:\workbench\projects\att\att\data.py</a></font></td></tr></table> | |||||
<p><tt><a href="#Data">Data</a> module for a Automatic Text Tools.<br> | |||||
<br> | |||||
(c) 2013 Ivan "Kai SD" Korystin <br> | |||||
<br> | |||||
License: GPLv3</tt></p> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#aa55cc"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> | |||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="cStringIO.html">cStringIO</a><br> | |||||
</td><td width="25%" valign=top><a href="codecs.html">codecs</a><br> | |||||
</td><td width="25%" valign=top><a href="csv.html">csv</a><br> | |||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ee77aa"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> | |||||
<td width="100%"><dl> | |||||
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.data.html#Data">Data</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.data.html#CSVData">CSVData</a> | |||||
</font></dt></dl> | |||||
</dd> | |||||
</dl> | |||||
</dd> | |||||
</dl> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="CSVData">class <strong>CSVData</strong></a>(<a href="att.data.html#Data">Data</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Class for reading CSV files.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%"><dl><dt>Method resolution order:</dt> | |||||
<dd><a href="att.data.html#CSVData">CSVData</a></dd> | |||||
<dd><a href="att.data.html#Data">Data</a></dd> | |||||
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> | |||||
</dl> | |||||
<hr> | |||||
Methods defined here:<br> | |||||
<dl><dt><a name="CSVData-__init__"><strong>__init__</strong></a>(self, file, encoding<font color="#909090">='utf-8'</font>, delimiter<font color="#909090">=';'</font>, quotechar<font color="#909090">='"'</font>, **kwargs)</dt><dd><tt>Constructor.<br> | |||||
<br> | |||||
filename - CSV table filename<br> | |||||
encoding - CSV table encoding (default: utf-8)<br> | |||||
delimiter - CSV table delimiter (default: ;)<br> | |||||
quotechar - CSV table quotechar (default: ")</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-export_csv"><strong>export_csv</strong></a>(self, filename, encoding<font color="#909090">='utf-8'</font>, delimiter<font color="#909090">=';'</font>, quotechar<font color="#909090">='"'</font>, **kwargs)</dt><dd><tt>Saves the data to CSV file<br> | |||||
<br> | |||||
filename - CSV table filename<br> | |||||
encoding - CSV table encoding (default: utf-8)<br> | |||||
delimiter - CSV table delimiter (default: ;)<br> | |||||
quotechar - CSV table quotechar (default: ")</tt></dd></dl> | |||||
<hr> | |||||
Data and other attributes defined here:<br> | |||||
<dl><dt><strong>Reader</strong> = <class att.data.Reader></dl> | |||||
<dl><dt><strong>Writer</strong> = <class att.data.Writer></dl> | |||||
<hr> | |||||
Methods inherited from <a href="att.data.html#Data">Data</a>:<br> | |||||
<dl><dt><a name="CSVData-__getitem__"><strong>__getitem__</strong></a>(self, pair)</dt><dd><tt>Returns a value for given key and row.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-__repr__"><strong>__repr__</strong></a>(self)</dt></dl> | |||||
<dl><dt><a name="CSVData-__setitem__"><strong>__setitem__</strong></a>(self, pair, value)</dt><dd><tt>Sets a value for given key and row.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Returns data as string.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-add_data"><strong>add_data</strong></a>(self, other)</dt><dd><tt>Adds rows from another data table to this one.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-add_keys"><strong>add_keys</strong></a>(self, *h)</dt><dd><tt>Adds new keys to the data.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-add_rows"><strong>add_rows</strong></a>(self, n<font color="#909090">=1</font>)</dt><dd><tt>Adds some empty rows to the data.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-col_by_idx"><strong>col_by_idx</strong></a>(self, idx)</dt><dd><tt>Returns a column by header's index</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-col_by_key"><strong>col_by_key</strong></a>(self, key)</dt><dd><tt>Returns a column by header's name</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-del_row"><strong>del_row</strong></a>(self, idx)</dt><dd><tt>Removes giver row from data</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-has_key"><strong>has_key</strong></a>(self, key)</dt><dd><tt>Returns True if given key exists in data</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-row_by_idx"><strong>row_by_idx</strong></a>(self, idx)</dt><dd><tt>Returns a row by index.</tt></dd></dl> | |||||
<dl><dt><a name="CSVData-transpose"><strong>transpose</strong></a>(self, key_idx<font color="#909090">=0</font>)</dt><dd><tt>Returns the transposed copy of the data.<br> | |||||
<br> | |||||
key_idx - index of the column, that contains keywords (default: 0)</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors inherited from <a href="att.data.html#Data">Data</a>:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table> <p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="Data">class <strong>Data</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Empty data class. Can be used for a subclassing or procedural data creation.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%">Methods defined here:<br> | |||||
<dl><dt><a name="Data-__getitem__"><strong>__getitem__</strong></a>(self, pair)</dt><dd><tt>Returns a value for given key and row.</tt></dd></dl> | |||||
<dl><dt><a name="Data-__init__"><strong>__init__</strong></a>(self, *args, **kwargs)</dt><dd><tt>Constructor</tt></dd></dl> | |||||
<dl><dt><a name="Data-__repr__"><strong>__repr__</strong></a>(self)</dt></dl> | |||||
<dl><dt><a name="Data-__setitem__"><strong>__setitem__</strong></a>(self, pair, value)</dt><dd><tt>Sets a value for given key and row.</tt></dd></dl> | |||||
<dl><dt><a name="Data-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Returns data as string.</tt></dd></dl> | |||||
<dl><dt><a name="Data-add_data"><strong>add_data</strong></a>(self, other)</dt><dd><tt>Adds rows from another data table to this one.</tt></dd></dl> | |||||
<dl><dt><a name="Data-add_keys"><strong>add_keys</strong></a>(self, *h)</dt><dd><tt>Adds new keys to the data.</tt></dd></dl> | |||||
<dl><dt><a name="Data-add_rows"><strong>add_rows</strong></a>(self, n<font color="#909090">=1</font>)</dt><dd><tt>Adds some empty rows to the data.</tt></dd></dl> | |||||
<dl><dt><a name="Data-col_by_idx"><strong>col_by_idx</strong></a>(self, idx)</dt><dd><tt>Returns a column by header's index</tt></dd></dl> | |||||
<dl><dt><a name="Data-col_by_key"><strong>col_by_key</strong></a>(self, key)</dt><dd><tt>Returns a column by header's name</tt></dd></dl> | |||||
<dl><dt><a name="Data-del_row"><strong>del_row</strong></a>(self, idx)</dt><dd><tt>Removes giver row from data</tt></dd></dl> | |||||
<dl><dt><a name="Data-has_key"><strong>has_key</strong></a>(self, key)</dt><dd><tt>Returns True if given key exists in data</tt></dd></dl> | |||||
<dl><dt><a name="Data-row_by_idx"><strong>row_by_idx</strong></a>(self, idx)</dt><dd><tt>Returns a row by index.</tt></dd></dl> | |||||
<dl><dt><a name="Data-transpose"><strong>transpose</strong></a>(self, key_idx<font color="#909090">=0</font>)</dt><dd><tt>Returns the transposed copy of the data.<br> | |||||
<br> | |||||
key_idx - index of the column, that contains keywords (default: 0)</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors defined here:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table></td></tr></table> | |||||
</body></html> |
@@ -0,0 +1,25 @@ | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |||||
<html><head><title>Python: package att</title> | |||||
</head><body bgcolor="#f0f0f8"> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |||||
<tr bgcolor="#7799ee"> | |||||
<td valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>att</strong></big></big></font></td | |||||
><td align=right valign=bottom | |||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/workbench/projects/att/att/__init__.py">c:\workbench\projects\att\att\__init__.py</a></font></td></tr></table> | |||||
<p></p> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#aa55cc"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> | |||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="att.atg.html">atg</a><br> | |||||
</td><td width="25%" valign=top><a href="att.atr.html">atr</a><br> | |||||
</td><td width="25%" valign=top><a href="att.data.html">data</a><br> | |||||
</td><td width="25%" valign=top><a href="att.template.html">template</a><br> | |||||
</td></tr></table></td></tr></table> | |||||
</body></html> |
@@ -0,0 +1,162 @@ | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |||||
<html><head><title>Python: module att.template</title> | |||||
</head><body bgcolor="#f0f0f8"> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |||||
<tr bgcolor="#7799ee"> | |||||
<td valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="att.html"><font color="#ffffff">att</font></a>.template</strong></big></big></font></td | |||||
><td align=right valign=bottom | |||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/workbench/projects/att/att/template.py">c:\workbench\projects\att\att\template.py</a></font></td></tr></table> | |||||
<p><tt><a href="#Template">Template</a> module for a Automatic Text Tools.<br> | |||||
<br> | |||||
(c) 2013 Ivan "Kai SD" Korystin <br> | |||||
<br> | |||||
License: GPLv3</tt></p> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#aa55cc"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> | |||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="re.html">re</a><br> | |||||
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ee77aa"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | |||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> | |||||
<td width="100%"><dl> | |||||
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.template.html#Template">Template</a> | |||||
</font></dt><dd> | |||||
<dl> | |||||
<dt><font face="helvetica, arial"><a href="att.template.html#TemplateV2">TemplateV2</a> | |||||
</font></dt></dl> | |||||
</dd> | |||||
</dl> | |||||
</dd> | |||||
</dl> | |||||
<p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="Template">class <strong>Template</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Empty template class. Generates empty text.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%">Methods defined here:<br> | |||||
<dl><dt><a name="Template-log"><strong>log</strong></a>(self, text)</dt><dd><tt>Print information</tt></dd></dl> | |||||
<dl><dt><a name="Template-process"><strong>process</strong></a>(self, data)</dt><dd><tt>Replace this method in subclasses.</tt></dd></dl> | |||||
<dl><dt><a name="Template-warning"><strong>warning</strong></a>(self, text)</dt><dd><tt>Prints a warning</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors defined here:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table> <p> | |||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |||||
<tr bgcolor="#ffc8d8"> | |||||
<td colspan=3 valign=bottom> <br> | |||||
<font color="#000000" face="helvetica, arial"><a name="TemplateV2">class <strong>TemplateV2</strong></a>(<a href="att.template.html#Template">Template</a>)</font></td></tr> | |||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> | |||||
<td colspan=2><tt>Class for reading ATGv2 templates.<br> | |||||
<br> | |||||
ATGv2 template file should be a plain text file, starting with the line<br> | |||||
ATGV2<br> | |||||
followed by the info line:<br> | |||||
[$KeyField$Extension$Prefix$Encoding$]<br> | |||||
where<br> | |||||
KeyField - is a name of a data column, that contains an identifier.<br> | |||||
Extension - is the desired extension for the generated files.<br> | |||||
Prefix - is the desired filename prefix for the generated files<br> | |||||
Encoding - is the desired encoding for the generated files.<br> | |||||
The line may also have some optional keywords before the closing bracket:<br> | |||||
oneFile$ - place all generated text into a single file instead of<br> | |||||
generating a file for each table row.<br> | |||||
After the info line, you can put your text.<br> | |||||
You can use following commands to handle the data:<br> | |||||
* [$Name$], where Name is the column header,<br> | |||||
will be replaced with value from the current row.<br> | |||||
* [$ATGLINDEX$] will be replaced with the number of a current row.<br> | |||||
* [$ATGHEADER$Text$] and [$ATGFOOTER$Text$] will place the given text<br> | |||||
at the begining or at the end of the file. You can't use other<br> | |||||
commands in this text.<br> | |||||
* [$ATGLIST$Name$Text$], where Name is a multi-column header<br> | |||||
(i.e. 'Col' will represent 'Col1', 'Col2', 'Col3' etc)<br> | |||||
will repeat the given text for each non-empty value.<br> | |||||
You can use other commands in Text. Also [$Name$] inside the list<br> | |||||
will be replaced with the value for the current row and column.<br> | |||||
* [$ATGLINDEX$] can be used only inside the ATGLIST text,<br> | |||||
will be replaced with the current column index.<br> | |||||
* [$ATGLISTCUT$Name$Text$] - same as ATGLIST, but the last symbol<br> | |||||
will be removed. Useful for removing unnecessary newlines.<br> | |||||
* [$ATGIF$Name$Value$Text$] will be replaced with the given text<br> | |||||
only if the the given column's value is the same as the given one.<br> | |||||
Will be replaced with the empty text otherwise. You can use other<br> | |||||
commands in Text.<br> | |||||
* [$ATGIFNOT$Name$Value$Text$] - same as ATGIF, but the column's value<br> | |||||
should not be equal to the given one.<br> | |||||
* [$ATGGREATER$Name$Value$Text$] - same as ATGIF, but the value should<br> | |||||
be the number and it should be greater then the given one.<br> | |||||
* [$ATGGREATER$Name$Value$Text$] - same as ATGGREATER, but the value<br> | |||||
should be less then the given one.<br> | |||||
* [$ATGREPLACE$Text1$Text2$] - Will replace Text1 with Text2. Replacements<br> | |||||
will be done after all other commands. You can't use regular expressions or<br> | |||||
other commands in the text.<br> | |||||
* [$ATGPREFIX$Text$] - Will add the given text to the filename prefix.<br> | |||||
You can use other commands in text, but do it carefully.<br> | |||||
* [$ATGSKIP$] - Skip the current row. Use only in combination with the<br> | |||||
ATGIF/ATGIFNOT, or you will generate nothing.<br> | |||||
* [$ATGPREV$Name$], where Name is the column header,<br> | |||||
will be replaced with the with the value of the given header from the<br> | |||||
previous row. ATGSKIP will be used for the first row.<br> </tt></td></tr> | |||||
<tr><td> </td> | |||||
<td width="100%"><dl><dt>Method resolution order:</dt> | |||||
<dd><a href="att.template.html#TemplateV2">TemplateV2</a></dd> | |||||
<dd><a href="att.template.html#Template">Template</a></dd> | |||||
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> | |||||
</dl> | |||||
<hr> | |||||
Methods defined here:<br> | |||||
<dl><dt><a name="TemplateV2-__init__"><strong>__init__</strong></a>(self, filename<font color="#909090">=None</font>, encoding<font color="#909090">='utf-8'</font>, text<font color="#909090">=''</font>)</dt><dd><tt>Constructor.<br> | |||||
<br> | |||||
filename - name of the ATGv2 template file.<br> | |||||
encoding - encoding of the template file.<br> | |||||
text - text to use if no filename has been provided.</tt></dd></dl> | |||||
<dl><dt><a name="TemplateV2-process"><strong>process</strong></a>(self, data)</dt><dd><tt>Generate text for the given data.</tt></dd></dl> | |||||
<hr> | |||||
Static methods defined here:<br> | |||||
<dl><dt><a name="TemplateV2-express"><strong>express</strong></a>(cls, text, **kwargs)</dt></dl> | |||||
<hr> | |||||
Methods inherited from <a href="att.template.html#Template">Template</a>:<br> | |||||
<dl><dt><a name="TemplateV2-log"><strong>log</strong></a>(self, text)</dt><dd><tt>Print information</tt></dd></dl> | |||||
<dl><dt><a name="TemplateV2-warning"><strong>warning</strong></a>(self, text)</dt><dd><tt>Prints a warning</tt></dd></dl> | |||||
<hr> | |||||
Data descriptors inherited from <a href="att.template.html#Template">Template</a>:<br> | |||||
<dl><dt><strong>__dict__</strong></dt> | |||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd> | |||||
</dl> | |||||
<dl><dt><strong>__weakref__</strong></dt> | |||||
<dd><tt>list of weak references to the object (if defined)</tt></dd> | |||||
</dl> | |||||
</td></tr></table></td></tr></table> | |||||
</body></html> |