Logo Search packages:      
Sourcecode: rapid-spring version File versions  Download package

def rapid::rapid::File::__new__ (   cls,
  name,
  md5,
  crc32,
  size 
)
Factory participant of Flyweight pattern used to store huge amounts
    of Files without requiring extraordinate amounts of memory.

Definition at line 580 of file rapid.py.

                                              :
            """ Factory participant of Flyweight pattern used to store huge amounts
                of Files without requiring extraordinate amounts of memory."""
            # Get the physical path to the file in the pool.
            hex = binascii.hexlify(md5)
            pool_path = os.path.join(pool_dir, hex[:2], hex[2:]) + '.gz'

            # pool_path identifies the pool file, but name may differ per package.
            key = (pool_path, name)

            # If we got it already, return flyweight File object.
            if key in File.__files:
                  f = File.__files[key]
                  assert (f.pool_path == pool_path)
                  assert (f.name == name)
                  assert (f.md5 == md5)
                  assert (f.crc32 == crc32)
                  assert (f.size == size)
                  return f

            # Use a local variable to ensure a strong ref exists until return!
            f = object.__new__(cls)
            f.pool_path = pool_path
            f.name = name
            f.md5 = md5
            f.crc32 = crc32
            f.size = size
            File.__files[key] = f
            return f


Generated by  Doxygen 1.6.0   Back to index