# Path: third_party/xiuminglib/xiuminglib/os.py
# def makedirs(directory, rm_if_exists=False):
#     """Wraps :func:`os.makedirs` to support removing the directory if it
#     alread exists.
# 
#     Google Colossus-compatible: it tries to use ``gfile`` first for speed. This
#     will fail if Blaze is not used, in which case it then falls back to using
#     ``fileutil`` CLI as external process calls.
# 
#     Args:
#         directory (str)
#         rm_if_exists (bool, optional): Whether to remove the directory (and
#             its contents) if it already exists.
#     """
#     def exists_cns_cli(directory):
#         cmd = 'fileutil test -d %s' % directory
#         retcode, _, _ = call(cmd, quiet=True)
#         if retcode == 0:
#             return True
#         if retcode == 1:
#             return False
#         raise ValueError(retcode)
# 
#     def mkdir_cns_cli(directory):
#         cmd = 'fileutil mkdir -p %s' % directory
#         _call_assert_success(cmd, quiet=True)
# 
#     if _is_cnspath(directory):
#         # Is a CNS path
#         gfile = preset_import('gfile')
#         if gfile is None:
#             exists_func = exists_cns_cli
#             mkdir_func = mkdir_cns_cli
#         else:
#             exists_func = gfile.Exists
#             mkdir_func = gfile.MakeDirs
#     else:
#         # Is just a regular local path
#         exists_func = exists
#         mkdir_func = os.makedirs
# 
#     # Do the job
#     if exists_func(directory):
#         if rm_if_exists:
#             rm(directory)
#             mkdir_func(directory)
#             logger.info("Removed and then remade:\n\t%s", directory)
#     else:
#         mkdir_func(directory)


from os.path import dirname
from ..os import makedirs
        Returns:
            str: The generated table as a string.
        """
        return self.head + self.body + self.tail

    def add_row(self, media, types, captions=None, media_width=256):
        """Adds a row to the table.

        Args:
            media (list(str)): Paths to media, or the text to display itself.
            types (list(str)): Types for all the media: ``'image'`` or
                ``'text'``.
            captions (list(str), optional): Media captions to appear below
                the media.
            media_width (int, optional): Media width in pixels.
        """
        if captions is None:
            captions = [None] * len(media)
        row_str = '''
        <tr>
'''
        for x, xtype, xcap in zip(media, types, captions):
            xtype = xtype.lower()
            # Image
            if xtype == 'image':
                row_str += '''
            {td}<img src="{img}" alt="{img}" width="{media_width}">'''.format(
                td=self.td, img=x, media_width=media_width)
            # Text
            elif xtype == 'text':

# Path: third_party/xiuminglib/xiuminglib/os.py
# def makedirs(directory, rm_if_exists=False):
#     """Wraps :func:`os.makedirs` to support removing the directory if it
#     alread exists.
# 
#     Google Colossus-compatible: it tries to use ``gfile`` first for speed. This
#     will fail if Blaze is not used, in which case it then falls back to using
#     ``fileutil`` CLI as external process calls.
# 
#     Args:
#         directory (str)
#         rm_if_exists (bool, optional): Whether to remove the directory (and
#             its contents) if it already exists.
#     """
#     def exists_cns_cli(directory):
#         cmd = 'fileutil test -d %s' % directory
#         retcode, _, _ = call(cmd, quiet=True)
#         if retcode == 0:
#             return True
#         if retcode == 1:
#             return False
#         raise ValueError(retcode)
# 
#     def mkdir_cns_cli(directory):
#         cmd = 'fileutil mkdir -p %s' % directory
#         _call_assert_success(cmd, quiet=True)
# 
#     if _is_cnspath(directory):
#         # Is a CNS path
#         gfile = preset_import('gfile')
#         if gfile is None:
#             exists_func = exists_cns_cli
#             mkdir_func = mkdir_cns_cli
#         else:
#             exists_func = gfile.Exists
#             mkdir_func = gfile.MakeDirs
#     else:
#         # Is just a regular local path
#         exists_func = exists
#         mkdir_func = os.makedirs
# 
#     # Do the job
#     if exists_func(directory):
#         if rm_if_exists:
#             rm(directory)
#             mkdir_func(directory)
#             logger.info("Removed and then remade:\n\t%s", directory)
#     else:
#         mkdir_func(directory)


# Path: third_party/xiuminglib/xiuminglib/vis/html.py
from os.path import dirname
from ..os import makedirs

        Returns:
            str: The generated table as a string.
        """
        return self.head + self.body + self.tail

    def add_row(self, media, types, captions=None, media_width=256):
        """Adds a row to the table.

        Args:
            media (list(str)): Paths to media, or the text to display itself.
            types (list(str)): Types for all the media: ``'image'`` or
                ``'text'``.
            captions (list(str), optional): Media captions to appear below
                the media.
            media_width (int, optional): Media width in pixels.
        """
        if captions is None:
            captions = [None] * len(media)
        row_str = '''
        <tr>
'''
        for x, xtype, xcap in zip(media, types, captions):
            xtype = xtype.lower()
            # Image
            if xtype == 'image':
                row_str += '''
            {td}<img src="{img}" alt="{img}" width="{media_width}">'''.format(
                td=self.td, img=x, media_width=media_width)
            # Text
            elif xtype == 'text':

                row_str += '''