diff --git a/ktt_atgcsv.py b/atgcsv.py similarity index 100% rename from ktt_atgcsv.py rename to atgcsv.py diff --git a/ktt/__init__.py b/att/__init__.py similarity index 100% rename from ktt/__init__.py rename to att/__init__.py diff --git a/ktt/atg.py b/att/atg.py similarity index 71% rename from ktt/atg.py rename to att/atg.py index 6cff6d8..e09f417 100644 --- a/ktt/atg.py +++ b/att/atg.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- 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 @@ -12,7 +12,7 @@ from os import makedirs 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. ''' def __init__(self, data, template): @@ -30,6 +30,16 @@ class ATG(object): else: 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='.'): ''' Write generated files to the given directory. @@ -43,14 +53,14 @@ class ATG(object): newpath = u'' for i in namepath[:-1]: newpath = join(newpath, i) - if not exists(join(unicode(outputDir),newpath)): - makedirs(join(unicode(outputDir),newpath)) - fname = join(unicode(outputDir),name+'.'+extension) + if not exists(join(unicode(outputDir), newpath)): + makedirs(join(unicode(outputDir), newpath)) + fname = self.join_filename(outputDir, name, extension) if fname.endswith('.'): fname = fname[:-1] f = open(fname, 'w') f.write(out[name].encode(encoding)) - self.log(' Saved %s' % (name+'.'+extension)) + self.log(' Saved %s' % fname) f.close() else: name = self.template.bonusPrefix @@ -62,9 +72,10 @@ class ATG(object): newpath = join(newpath, i) if not exists(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)) - self.log(' Saved %s' % (name+'.'+extension)) + self.log(' Saved %s' % fname) f.close() def log(self, text): diff --git a/ktt/atr.py b/att/atr.py similarity index 97% rename from ktt/atr.py rename to att/atr.py index 4911f09..37e5664 100644 --- a/ktt/atr.py +++ b/att/atr.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- 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 @@ -10,7 +10,7 @@ License: GPLv3 import re 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. It can make plain replacements, or use ATG templates to do something more complex. ''' diff --git a/ktt/data.py b/att/data.py similarity index 99% rename from ktt/data.py rename to att/data.py index f868d5d..6dde4f1 100644 --- a/ktt/data.py +++ b/att/data.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- ''' -Data module for a KaiSD Text Tools. +Data module for a Automatic Text Tools. (c) 2013 Ivan "Kai SD" Korystin diff --git a/ktt/template.py b/att/template.py similarity index 99% rename from ktt/template.py rename to att/template.py index 6f81e49..9184d48 100644 --- a/ktt/template.py +++ b/att/template.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- ''' -Template module for a KaiSD Text Tools. +Template module for a Automatic Text Tools. (c) 2013 Ivan "Kai SD" Korystin diff --git a/docs/ktt.atg.html b/docs/ktt.atg.html deleted file mode 100644 index 6394456..0000000 --- a/docs/ktt.atg.html +++ /dev/null @@ -1,60 +0,0 @@ - - -Python: module ktt.atg - - - - -
 
- 
ktt.atg
index
/home/kaisd/Мастерская/projects/KTT/ktt/atg.py
-

Advanced Text Generator module for a KaiSD Text Tools.

-(c) 2013 Ivan "Kai SD" Korystin 

-License: GPLv3

-

- - - - - -
 
-Classes
       
-
__builtin__.object -
-
-
ATG -
-
-
-

- - - - - - - -
 
-class ATG(__builtin__.object)
   Advanced Text Generator is a class, created to generate multiple
-text files from table data.
 
 Methods defined here:
-
__init__(self, data, template)
Constructor.
-data - an instance of the data.Data class (i.e. CSVData)
-template - an instance of the template.Template class (i.e. TemplateV2)
- -
log(self, text)
Print information
- -
write_files(self, outputDir='.')
Write generated files to the given directory.
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- \ No newline at end of file diff --git a/docs/ktt.atr.html b/docs/ktt.atr.html deleted file mode 100644 index 175677b..0000000 --- a/docs/ktt.atr.html +++ /dev/null @@ -1,83 +0,0 @@ - - -Python: module ktt.atr - - - - -
 
- 
ktt.atr
index
/home/kaisd/Мастерская/projects/KTT/ktt/atr.py
-

Advanced Text Replacer module for a KaiSD Text Tools.

-(c) 2013 Ivan "Kai SD" Korystin 

-License: GPLv3

-

- - - - - -
 
-Modules
       
re
-

- - - - - -
 
-Classes
       
-
__builtin__.object -
-
-
ATR -
-
-
-

- - - - - - - -
 
-class ATR(__builtin__.object)
   Advanced 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)
-
-

- \ No newline at end of file diff --git a/docs/ktt.data.html b/docs/ktt.data.html deleted file mode 100644 index 2c241a1..0000000 --- a/docs/ktt.data.html +++ /dev/null @@ -1,170 +0,0 @@ - - -Python: module ktt.data - - - - -
 
- 
ktt.data
index
/home/kaisd/Мастерская/projects/KTT/ktt/data.py
-

Data module for a KaiSD Text Tools.

-(c) 2013 Ivan "Kai SD" Korystin 

-License: GPLv3

-

- - - - - -
 
-Modules
       
cStringIO
-
codecs
-
csv
-

- - - - - -
 
-Classes
       
-
__builtin__.object -
-
-
Data -
-
-
CSVData -
-
-
-
-
-

- - - - - - - -
 
-class CSVData(Data)
   Class for reading CSV files.
 
 
Method resolution order:
-
CSVData
-
Data
-
__builtin__.object
-
-
-Methods defined here:
-
__init__(self, file, encoding='utf-8', delimiter=';', quotechar='"', **kwargs)
Constructor.

-filename - CSV table filename
-encoding - CSV table encoding (default: utf-8)
-delimiter - CSV table delimiter (default: ;)
-quotechar - CSV table quotechar (default: ")
- -
export_csv(self, filename, encoding='utf-8', delimiter=';', quotechar='"', **kwargs)
Saves the data to CSV file

-filename - CSV table filename
-encoding - CSV table encoding (default: utf-8)
-delimiter - CSV table delimiter (default: ;)
-quotechar - CSV table quotechar (default: ")
- -
-Data and other attributes defined here:
-
Reader = <class ktt.data.Reader>
- -
Writer = <class ktt.data.Writer>
- -
-Methods inherited from Data:
-
__getitem__(self, pair)
Returns a value for given key and row.
- -
__repr__(self)
- -
__setitem__(self, pair, value)
Sets a value for given key and row.
- -
__str__(self)
Returns data as string.
- -
add_data(self, other)
Adds rows from another data table to this one.
- -
add_keys(self, *h)
Adds new keys to the data.
- -
add_rows(self, n=1)
Adds some empty rows to the data.
- -
col_by_idx(self, idx)
Returns a column by header's index
- -
col_by_key(self, key)
Returns a column by header's name
- -
del_row(self, idx)
Removes giver row from data
- -
has_key(self, key)
Returns True if given key exists in data
- -
row_by_idx(self, idx)
Returns a row by index.
- -
transpose(self, key_idx=0)
Returns the transposed copy of the data.

-key_idx - index of the column, that contains keywords (default: 0)
- -
-Data descriptors inherited from Data:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class Data(__builtin__.object)
   Empty data class. Can be used for a subclassing or procedural data creation.
 
 Methods defined here:
-
__getitem__(self, pair)
Returns a value for given key and row.
- -
__init__(self, *args, **kwargs)
Constructor
- -
__repr__(self)
- -
__setitem__(self, pair, value)
Sets a value for given key and row.
- -
__str__(self)
Returns data as string.
- -
add_data(self, other)
Adds rows from another data table to this one.
- -
add_keys(self, *h)
Adds new keys to the data.
- -
add_rows(self, n=1)
Adds some empty rows to the data.
- -
col_by_idx(self, idx)
Returns a column by header's index
- -
col_by_key(self, key)
Returns a column by header's name
- -
del_row(self, idx)
Removes giver row from data
- -
has_key(self, key)
Returns True if given key exists in data
- -
row_by_idx(self, idx)
Returns a row by index.
- -
transpose(self, key_idx=0)
Returns the transposed copy of the data.

-key_idx - index of the column, that contains keywords (default: 0)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- \ No newline at end of file diff --git a/docs/ktt.html b/docs/ktt.html deleted file mode 100644 index 5117d93..0000000 --- a/docs/ktt.html +++ /dev/null @@ -1,25 +0,0 @@ - - -Python: package ktt - - - - -
 
- 
ktt
index
/home/kaisd/Мастерская/projects/KTT/ktt/__init__.py
-

-

- - - - - -
 
-Package Contents
       
atg
-
atr
-
data
-
template
-
- \ No newline at end of file diff --git a/docs/ktt.template.html b/docs/ktt.template.html deleted file mode 100644 index db75e9b..0000000 --- a/docs/ktt.template.html +++ /dev/null @@ -1,162 +0,0 @@ - - -Python: module ktt.template - - - - -
 
- 
ktt.template
index
/home/kaisd/Мастерская/projects/KTT/ktt/template.py
-

Template module for a KaiSD Text Tools.

-(c) 2013 Ivan "Kai SD" Korystin 

-License: GPLv3

-

- - - - - -
 
-Modules
       
re
-

- - - - - -
 
-Classes
       
-
__builtin__.object -
-
-
Template -
-
-
TemplateV2 -
-
-
-
-
-

- - - - - - - -
 
-class Template(__builtin__.object)
   Empty template class. Generates empty text.
 
 Methods defined here:
-
log(self, text)
Print information
- -
process(self, data)
Replace this method in subclasses.
- -
warning(self, text)
Prints a warning
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class TemplateV2(Template)
   Class for reading ATGv2 templates.

-ATGv2 template file should be a plain text file, starting with the line
-ATGV2
-followed by the info line:
-[$KeyField$Extension$Prefix$Encoding$]
-where
-KeyField - is a name of a data column, that contains an identifier.
-Extension - is the desired extension for the generated files.
-Prefix - is the desired filename prefix for the generated files
-Encoding - is the desired encoding for the generated files.
-The line may also have some optional keywords before the closing bracket:
-oneFile$ - place all generated text into a single file instead of
-generating a file for each table row.
-After the info line, you can put your text.
-You can use following commands to handle the data:
-* [$Name$], where Name is the column header,
-will be replaced with value from the current row.
-* [$ATGLINDEX$] will be replaced with the number of a current row.
-* [$ATGHEADER$Text$] and [$ATGFOOTER$Text$] will place the given text
-at the begining or at the end of the file. You can't use other
-commands in this text.
-* [$ATGLIST$Name$Text$], where Name is a multi-column header
-(i.e. 'Col' will represent 'Col1', 'Col2', 'Col3' etc)
-will repeat the given text for each non-empty value.
-You can use other commands in Text. Also [$Name$] inside the list
-will be replaced with the value for the current row and column.
-* [$ATGLINDEX$] can be used only inside the ATGLIST text,
-will be replaced with the current column index.
-* [$ATGLISTCUT$Name$Text$] - same as ATGLIST, but the last symbol
-will be removed. Useful for removing unnecessary newlines.
-* [$ATGIF$Name$Value$Text$] will be replaced with the given text
-only if the the given column's value is the same as the given one.
-Will be replaced with the empty text otherwise. You can use other
-commands in Text.
-* [$ATGIFNOT$Name$Value$Text$] - same as ATGIF, but the column's value
-should not be equal to the given one.
-* [$ATGGREATER$Name$Value$Text$] - same as ATGIF, but the value should
-be the number and it should be greater then the given one.
-* [$ATGGREATER$Name$Value$Text$] - same as ATGGREATER, but the value
-should be less then the given one.
-* [$ATGREPLACE$Text1$Text2$] - Will replace Text1 with Text2. Replacements
-will be done after all other commands. You can't use regular expressions or
-other commands in the text.
-* [$ATGPREFIX$Text$] - Will add the given text to the filename prefix.
-You can use other commands in text, but do it carefully.
-* [$ATGSKIP$] - Skip the current row. Use only in combination with the
-ATGIF/ATGIFNOT, or you will generate nothing.
-* [$ATGPREV$Name$], where Name is the column header,
-will be replaced with the with the value of the given header from the
-previous row. ATGSKIP will be used for the first row.
 
 
Method resolution order:
-
TemplateV2
-
Template
-
__builtin__.object
-
-
-Methods defined here:
-
__init__(self, filename=None, encoding='utf-8', text='')
Constructor.

-filename - name of the ATGv2 template file.
-encoding - encoding of the template file.
-text - text to use if no filename has been provided.
- -
process(self, data)
Generate text for the given data.
- -
-Static methods defined here:
-
express(cls, text, **kwargs)
- -
-Methods inherited from Template:
-
log(self, text)
Print information
- -
warning(self, text)
Prints a warning
- -
-Data descriptors inherited from Template:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- \ No newline at end of file diff --git a/scripts/gendoc.cmd b/scripts/gendoc.cmd index cf7d59d..9e81dd9 100644 --- a/scripts/gendoc.cmd +++ b/scripts/gendoc.cmd @@ -4,7 +4,7 @@ set OUTDIR=docs 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 move %%I.html %OUTDIR% )