resourcepackage.defaultgenerators
index
p:\resourcepackage\defaultgenerators.py

Objects for doing generic data-as-code encoding

 
Modules
            
cStringIO
os
resourcepackage
string
types
zlib
 
Classes
            
SimpleGenerator
CompressedGenerator
 
class CompressedGenerator(SimpleGenerator)
      Adds Zlib compression and decompression to generator
 
   Methods defined here:
getData(self, source, package=None)
Get the data to be encoded in the package
getDataRepr(self, source, destination, package=None)
data as Python code assigning a value to variable "data"
getHeader(self, source, destination, package=None)
Get the header, written before the data variable

Data and non-method functions defined here:
__doc__ = 'Adds Zlib compression and decompression to generator'
__module__ = 'resourcepackage.defaultgenerators'

Methods inherited from SimpleGenerator:
__call__(self, source, destination, package=None)
Encode source in destination for package
__repr__(self)
getFooter(self, source, destination, package=None)
Get the footer, written after the data variable
 
class SimpleGenerator
      Simplistic generator
 
   Methods defined here:
__call__(self, source, destination, package=None)
Encode source in destination for package
__repr__(self)
getData(self, source, package=None)
Get the data to be encoded in the package
getDataRepr(self, source, destination, package=None)
data as Python code assigning a value to variable "data"
getFooter(self, source, destination, package=None)
Get the footer, written after the data variable
getHeader(self, source, destination, package=None)
Get the header, written before the data variable

Data and non-method functions defined here:
__doc__ = 'Simplistic generator'
__module__ = 'resourcepackage.defaultgenerators'
 
Functions
            
crunch_data(source, chunkSize=60, charMap={'\x00': r'\000', '\x01': r'\001', '\x02': r'\002', '\x03': r'\003', '\x04': r'\004', '\x05': r'\005', '\x06': r'\006', '\x07': r'\007', '\x08': r'\010', '\t': r'\011', ...})
Try to get a minimal representation of a binary as Python code
 
This is a re-implementation that tries to
minimise the size of the data by embedding extended
characters in the source code.
 
Data
             COMPRESSED = CompressedGenerator (singleton)
HEADER = '# -*- coding: ISO-8859-1 -*-\n"""Resource %(modul...gev)r\nsource = %(source)r\npackage = %(packagen)r\n'
SIMPLE = SimpleGenerator (singleton)
_char_map = {'\x00': r'\000', '\x01': r'\001', '\x02': r'\002', '\x03': r'\003', '\x04': r'\004', '\x05': r'\005', '\x06': r'\006', '\x07': r'\007', '\x08': r'\010', '\t': r'\011', ...}
c = 31
generators = {'': SimpleGenerator (singleton), '.htm': CompressedGenerator (singleton), '.html': CompressedGenerator (singleton), '.pdf': CompressedGenerator (singleton), '.txt': CompressedGenerator (singleton)}