(self, directory)
Create one or more directory entries, esssentially mkdir -p.

    Some zip readers do not create needed folders for arbitrary file paths.
    When we encounter a new path for the first time, we make sure the tree
    exists.

    Args:
      directory: (str) a directory name.
Create one or more directory entries, esssentially mkdir -p.
Create one or more directory entries esssentially mkdir - p .
def CreateDirectory(self, directory):
    """Create one or more directory entries, esssentially mkdir -p.

    Some zip readers do not create needed folders for arbitrary file paths.
    When we encounter a new path for the first time, we make sure the tree
    exists.

    Args:
      directory: (str) a directory name.
    """
    # Build list of dirs to build. This will be from bottom up.
    to_create = []
    while directory:
      if directory in self._created_dirs:
        break
      to_create.append(directory)
      self._created_dirs.append(directory)
      directory = os.path.dirname(directory)
    to_create.reverse()  # have to build from top down
    for directory in to_create:
      # Create the directory entry.  File and directory names must be
      # ascii.
      info = zipfile.ZipInfo((directory + '/').encode('ascii'),
                             date_time=self.ZipTimestamp())
      # Notes from the web and zipfile sources:
      # external_attr is 32 in size, with the unix permissions in the
      # high order 16 bit, and the MS-DOS FAT attributes in the lower 16.
      # man 2 stat tells us that 040755 should be a drwxr-xr-x style file,
      # and word of mouth tells me that bit 4 marks directories in FAT.
      info.external_attr = (0o40755 << 16) | 0x10
      self._zip.writestr(info, '')
def CreateDirectory ( self , directory ) : # Build list of dirs to build. This will be from bottom up. to_create = [ ] while directory : if directory in self . _created_dirs : break to_create . append ( directory ) self . _created_dirs . append ( directory ) directory = os . path . dirname ( directory ) to_create . reverse ( ) # have to build from top down for directory in to_create : # Create the directory entry.  File and directory names must be # ascii. info = zipfile . ZipInfo ( ( directory + '/' ) . encode ( 'ascii' ) , date_time = self . ZipTimestamp ( ) ) # Notes from the web and zipfile sources: # external_attr is 32 in size, with the unix permissions in the # high order 16 bit, and the MS-DOS FAT attributes in the lower 16. # man 2 stat tells us that 040755 should be a drwxr-xr-x style file, # and word of mouth tells me that bit 4 marks directories in FAT. info . external_attr = ( 0o40755 << 16 ) | 0x10 self . _zip . writestr ( info , '' )