Back to index

enigmail  1.4.3
Classes | Functions | Variables
unitMozZipFile Namespace Reference

Classes

class  TestExtensiveStored
class  TestExtensiveDeflated

Functions

def givenlength
def prod
def getid
def getContent
def createWriter
def createTester

Variables

list __file__ = sys.argv[0]
tuple leafs
tuple _lengths = map(lambda n: n * 64, [16, 64, 80])
int lengths = 3
int writes = 5
tuple atomics = list(prod(xrange(len(leafs)), xrange(lengths)))
list nonatomics
tuple suffix = getid(descs)
list dicts = [dict(leaf=leaf, length=length) for leaf, length in descs]
list files = [list(prod([i], xrange(lengths))) for i in xrange(len(leafs))]
tuple allfiles
string testbasename = 'test%s_'
list test = [None, '_write' + getid(first), None]

Function Documentation

def unitMozZipFile.createTester (   name,
  writes 
)
Helper method to fill in tests, calls into a list of write
helper methods.

Definition at line 128 of file unitMozZipFile.py.

00128 
00129 def createTester(name, *writes):
00130   '''Helper method to fill in tests, calls into a list of write
00131   helper methods.
00132   '''
00133   _writes = copy.copy(writes)
00134   def tester(self):
00135     for w in _writes:
00136       getattr(self, w)()
00137     self._verifyZip()
00138     pass
00139   # unit tests get confused if the method name isn't test...
00140   tester.__name__ = name
00141   return tester

def unitMozZipFile.createWriter (   sizer,
  items 
)

Definition at line 112 of file unitMozZipFile.py.

00112 
00113 def createWriter(sizer, *items):
00114   'Helper method to fill in tests, one set of writes, one for each item'
00115   locitems = copy.deepcopy(items)
00116   for item in locitems:
00117     item['length'] = sizer(item.pop('length', 0))
00118   def helper(self):
00119     mode  = 'w'
00120     if os.path.isfile(self.f):
00121       mode = 'a'
00122     zf = ZipFile(self.f, mode, self.compression)
00123     for item in locitems:
00124       self._write(zf, **item)
00125     zf = None
00126     pass
00127   return helper

def unitMozZipFile.getContent (   length)

Definition at line 104 of file unitMozZipFile.py.

00104 
00105 def getContent(length):
00106   'Get pseudo random content of given length.'
00107   rv = [None] * length
00108   for i in xrange(length):
00109     rv[i] = random.choice(letters)
00110   return ''.join(rv)
00111 

Here is the caller graph for this function:

def unitMozZipFile.getid (   descs)

Definition at line 99 of file unitMozZipFile.py.

00099 
00100 def getid(descs):
00101   'Convert a list of ints to a string.'
00102   return reduce(lambda x,y: x+'%d%d'%tuple(y), descs,'')
00103 

Return a length given in the _lengths array to allow manual
tuning of which lengths of zip entries to use.

Definition at line 78 of file unitMozZipFile.py.

00078 
00079 def givenlength(i):
00080   '''Return a length given in the _lengths array to allow manual
00081   tuning of which lengths of zip entries to use.
00082   '''
00083   return _lengths[i]
00084 

def unitMozZipFile.prod (   iterables)
'Tensor product of a list of iterables.

This generator returns lists of items, one of each given
iterable. It iterates over all possible combinations.

Definition at line 85 of file unitMozZipFile.py.

00085 
00086 def prod(*iterables):
00087   ''''Tensor product of a list of iterables.
00088 
00089   This generator returns lists of items, one of each given
00090   iterable. It iterates over all possible combinations.
00091   '''
00092   for item in iterables[0]:
00093     if len(iterables) == 1:
00094       yield [item]
00095     else:
00096       for others in prod(*iterables[1:]):
00097         yield [item] + others
00098 


Variable Documentation

list unitMozZipFile.__file__ = sys.argv[0]

Definition at line 64 of file unitMozZipFile.py.

tuple unitMozZipFile._lengths = map(lambda n: n * 64, [16, 64, 80])

Definition at line 74 of file unitMozZipFile.py.

Initial value:
00001 reduce(lambda l,r:l+r,
00002                   [list(prod(*files[:(i+1)])) for i in xrange(len(leafs))])

Definition at line 218 of file unitMozZipFile.py.

tuple unitMozZipFile.atomics = list(prod(xrange(len(leafs)), xrange(lengths)))

Definition at line 194 of file unitMozZipFile.py.

list unitMozZipFile.dicts = [dict(leaf=leaf, length=length) for leaf, length in descs]

Definition at line 206 of file unitMozZipFile.py.

list unitMozZipFile.files = [list(prod([i], xrange(lengths))) for i in xrange(len(leafs))]

Definition at line 217 of file unitMozZipFile.py.

Initial value:
00001 (
00002   'firstdir/oneleaf',
00003   'seconddir/twoleaf',
00004   'thirddir/with/sub/threeleaf')

Definition at line 70 of file unitMozZipFile.py.

Definition at line 75 of file unitMozZipFile.py.

Initial value:
00001 [list(prod(range(min(i,len(leafs))), xrange(lengths)))
00002                 for i in xrange(1, w+1)]

Definition at line 202 of file unitMozZipFile.py.

tuple unitMozZipFile.suffix = getid(descs)

Definition at line 205 of file unitMozZipFile.py.

list unitMozZipFile.test = [None, '_write' + getid(first), None]

Definition at line 223 of file unitMozZipFile.py.

Definition at line 222 of file unitMozZipFile.py.

Definition at line 76 of file unitMozZipFile.py.