updated
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
'''
|
||||||
Advanced Text Generator module for a KaiSD Text Tools.
|
Automatic Text Generator module for a Automatic Text Tools.
|
||||||
|
|
||||||
(c) 2013 Ivan "Kai SD" Korystin
|
(c) 2013 Ivan "Kai SD" Korystin
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ from os import makedirs
|
|||||||
|
|
||||||
class ATG(object):
|
class ATG(object):
|
||||||
'''
|
'''
|
||||||
Advanced Text Generator is a class, created to generate multiple
|
Automatic Text Generator is a class, created to generate multiple
|
||||||
text files from table data.
|
text files from table data.
|
||||||
'''
|
'''
|
||||||
def __init__(self, data, template):
|
def __init__(self, data, template):
|
||||||
@@ -30,6 +30,16 @@ 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 write_files(self, outputDir='.'):
|
def write_files(self, outputDir='.'):
|
||||||
'''
|
'''
|
||||||
Write generated files to the given directory.
|
Write generated files to the given directory.
|
||||||
@@ -43,14 +53,14 @@ class ATG(object):
|
|||||||
newpath = u''
|
newpath = u''
|
||||||
for i in namepath[:-1]:
|
for i in namepath[:-1]:
|
||||||
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 = join(unicode(outputDir),name+'.'+extension)
|
fname = self.join_filename(outputDir, name, extension)
|
||||||
if fname.endswith('.'):
|
if fname.endswith('.'):
|
||||||
fname = fname[:-1]
|
fname = fname[:-1]
|
||||||
f = open(fname, 'w')
|
f = open(fname, 'w')
|
||||||
f.write(out[name].encode(encoding))
|
f.write(out[name].encode(encoding))
|
||||||
self.log(' Saved %s' % (name+'.'+extension))
|
self.log(' Saved %s' % fname)
|
||||||
f.close()
|
f.close()
|
||||||
else:
|
else:
|
||||||
name = self.template.bonusPrefix
|
name = self.template.bonusPrefix
|
||||||
@@ -62,9 +72,10 @@ 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))
|
||||||
f = open(join(unicode(outputDir),name+'.'+extension), 'w')
|
fname = self.join_filename(outputDir, name, extension)
|
||||||
|
f = open(fname, 'w')
|
||||||
f.write(out.encode(encoding))
|
f.write(out.encode(encoding))
|
||||||
self.log(' Saved %s' % (name+'.'+extension))
|
self.log(' Saved %s' % fname)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def log(self, text):
|
def log(self, text):
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
'''
|
||||||
Advanced Text Replacer module for a KaiSD Text Tools.
|
Automatic Text Replacer module for a Automatic Text Tools.
|
||||||
|
|
||||||
(c) 2013 Ivan "Kai SD" Korystin
|
(c) 2013 Ivan "Kai SD" Korystin
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ License: GPLv3
|
|||||||
import re
|
import re
|
||||||
class ATR(object):
|
class ATR(object):
|
||||||
'''
|
'''
|
||||||
Advanced Text Replacer - is a class, created to make multiple replacements
|
Automatic Text Replacer - is a class, created to make multiple replacements
|
||||||
in the content or names of text file.
|
in the content or names of text file.
|
||||||
It can make plain replacements, or use ATG templates to do something more complex.
|
It can make plain replacements, or use ATG templates to do something more complex.
|
||||||
'''
|
'''
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
'''
|
||||||
Data module for a KaiSD Text Tools.
|
Data module for a Automatic Text Tools.
|
||||||
|
|
||||||
(c) 2013 Ivan "Kai SD" Korystin
|
(c) 2013 Ivan "Kai SD" Korystin
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
'''
|
||||||
Template module for a KaiSD Text Tools.
|
Template module for a Automatic Text Tools.
|
||||||
|
|
||||||
(c) 2013 Ivan "Kai SD" Korystin
|
(c) 2013 Ivan "Kai SD" Korystin
|
||||||
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html><head><title>Python: module ktt.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="ktt.html"><font color="#ffffff">ktt</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:/home/kaisd/Мастерская/projects/KTT/ktt/atg.py">/home/kaisd/Мастерская/projects/KTT/ktt/atg.py</a></font></td></tr></table>
|
|
||||||
<p><tt>Advanced Text Generator module for a KaiSD 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="ktt.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>Advanced 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-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>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html><head><title>Python: module ktt.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="ktt.html"><font color="#ffffff">ktt</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:/home/kaisd/Мастерская/projects/KTT/ktt/atr.py">/home/kaisd/Мастерская/projects/KTT/ktt/atr.py</a></font></td></tr></table>
|
|
||||||
<p><tt>Advanced Text Replacer module for a KaiSD 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="ktt.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>Advanced 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>
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html><head><title>Python: module ktt.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="ktt.html"><font color="#ffffff">ktt</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:/home/kaisd/Мастерская/projects/KTT/ktt/data.py">/home/kaisd/Мастерская/projects/KTT/ktt/data.py</a></font></td></tr></table>
|
|
||||||
<p><tt><a href="#Data">Data</a> module for a KaiSD 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="ktt.data.html#Data">Data</a>
|
|
||||||
</font></dt><dd>
|
|
||||||
<dl>
|
|
||||||
<dt><font face="helvetica, arial"><a href="ktt.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="ktt.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="ktt.data.html#CSVData">CSVData</a></dd>
|
|
||||||
<dd><a href="ktt.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 ktt.data.Reader></dl>
|
|
||||||
|
|
||||||
<dl><dt><strong>Writer</strong> = <class ktt.data.Writer></dl>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
Methods inherited from <a href="ktt.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="ktt.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>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html><head><title>Python: package ktt</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>ktt</strong></big></big></font></td
|
|
||||||
><td align=right valign=bottom
|
|
||||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/kaisd/Мастерская/projects/KTT/ktt/__init__.py">/home/kaisd/Мастерская/projects/KTT/ktt/__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="ktt.atg.html">atg</a><br>
|
|
||||||
</td><td width="25%" valign=top><a href="ktt.atr.html">atr</a><br>
|
|
||||||
</td><td width="25%" valign=top><a href="ktt.data.html">data</a><br>
|
|
||||||
</td><td width="25%" valign=top><a href="ktt.template.html">template</a><br>
|
|
||||||
</td></tr></table></td></tr></table>
|
|
||||||
</body></html>
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html><head><title>Python: module ktt.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="ktt.html"><font color="#ffffff">ktt</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:/home/kaisd/Мастерская/projects/KTT/ktt/template.py">/home/kaisd/Мастерская/projects/KTT/ktt/template.py</a></font></td></tr></table>
|
|
||||||
<p><tt><a href="#Template">Template</a> module for a KaiSD 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="ktt.template.html#Template">Template</a>
|
|
||||||
</font></dt><dd>
|
|
||||||
<dl>
|
|
||||||
<dt><font face="helvetica, arial"><a href="ktt.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="ktt.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="ktt.template.html#TemplateV2">TemplateV2</a></dd>
|
|
||||||
<dd><a href="ktt.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="ktt.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="ktt.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>
|
|
||||||
@@ -4,7 +4,7 @@ set OUTDIR=docs
|
|||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
for %%I in (atg atr data template) do (
|
for %%I in (att, att.atg, att.atr, att.template, att.data) do (
|
||||||
%PYDOC% -w %%I
|
%PYDOC% -w %%I
|
||||||
move %%I.html %OUTDIR%
|
move %%I.html %OUTDIR%
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user