produce a byte-chunk for a folder of colors

    the structure is very similar to a color's data:
    • Header
        b'\xC0\x01' +
        Big Endian Unsigned Int == len(Bytes in the Header Block)
          note _only_ the header, this doesn't include the length of color data
          • Big Endian Unsigned Short == len(Folder Name + '\0')
              Note that Folder Name is assumed to be utf-16be so this
              will always be an even number
          • Folder Name + '\0', encoded UTF-16BE
    • body
        chunks for each color, see chunk_for_color
    • folder terminator
        b'\xC0\x02' +
        b'\x00\x00\x00\x00'

    Perhaps the four null bytes represent something, but i'm pretty sure
    they're just a terminating string, but there's something nice about
    how the b'\xC0\x02' matches with the folder's header

def chunk_for_folder(obj):
    """produce a byte-chunk for a folder of colors

    the structure is very similar to a color's data:
    • Header
        b'\xC0\x01' +
        Big Endian Unsigned Int == len(Bytes in the Header Block)
          note _only_ the header, this doesn't include the length of color data
          • Big Endian Unsigned Short == len(Folder Name + '\0')
              Note that Folder Name is assumed to be utf-16be so this
              will always be an even number
          • Folder Name + '\0', encoded UTF-16BE
    • body
        chunks for each color, see chunk_for_color
    • folder terminator
        b'\xC0\x02' +
        b'\x00\x00\x00\x00'

    Perhaps the four null bytes represent something, but i'm pretty sure
    they're just a terminating string, but there's something nice about
    how the b'\xC0\x02' matches with the folder's header
    """
    title = obj['name'] + '\0'
    title_length = len(title)
    chunk_body = struct.pack('>H', title_length) # title length
    chunk_body += title.encode('utf-16be') # title

    chunk_head = b'\xC0\x01' # folder header
    chunk_head += struct.pack('>I', len(chunk_body))
    # precede entire chunk by folder header and size of folder
    chunk = chunk_head + chunk_body

    chunk += b''.join([chunk_for_color(c) for c in obj['swatches']])

    chunk += b'\xC0\x02' # folder terminator chunk
    chunk += b'\x00\x00\x00\x00' # folder terminator
    return chunk