# Path: third_party/xiuminglib/xiuminglib/log.py
# def get_logger(level=None):
#     """Creates a logger for functions in the library.
# 
#     Args:
#         level (str, optional): Logging level. Defaults to ``logging.INFO``.
# 
#     Returns:
#         logging.Logger: Logger created.
#     """
#     logging.basicConfig(level=logging.INFO)
#     logger = logging.getLogger()
#     return logger
# 
# Path: third_party/xiuminglib/xiuminglib/imprt.py
# def preset_import(name):
#     """A unified importer for both regular and ``google3`` modules, according
#     to specified presets/profiles (e.g., ignoring ``ModuleNotFoundError``).
#     """
#     if name in ('cv2', 'opencv'):
#         try:
#             # BUILD dep:
#             # "//third_party/py/cvx2",
#             from cvx2 import latest as mod
#             # Or
#             # BUILD dep:
#             # "//third_party/OpenCVX:cvx2",
#             # from google3.third_party.OpenCVX import cvx2 as cv2
#         except ModuleNotFoundError:
#             mod = import_module_404ok('cv2')
#         # TODO: Below is cleaner, but doesn't work
#         # mod = import_module_404ok('cvx2.latest')
#         # if mod is None:
#         #    mod = import_module_404ok('cv2')
#         return mod
# 
#     if name in ('tf', 'tensorflow'):
#         mod = import_module_404ok('tensorflow')
#         return mod
# 
#     if name == 'gfile':
#         # BUILD deps:
#         # "//pyglib:gfile",
#         # "//file/colossus/cns",
#         mod = import_module_404ok('google3.pyglib.gfile')
#         return mod
# 
#     if name in ('bpy', 'bmesh', 'OpenEXR', 'Imath'):
#         # BUILD deps:
#         # "//third_party/py/Imath",
#         # "//third_party/py/OpenEXR",
#         mod = import_module_404ok(name)
#         return mod
# 
#     if name in ('Vector', 'Matrix', 'Quaternion'):
#         mod = import_module_404ok('mathutils')
#         cls = _get_module_class(mod, name)
#         return cls
# 
#     if name == 'BVHTree':
#         mod = import_module_404ok('mathutils.bvhtree')
#         cls = _get_module_class(mod, name)
#         return cls
# 
#     raise NotImplementedError(name)
# 
# Path: third_party/xiuminglib/xiuminglib/interact.py
# def format_print(msg, fmt):
#     """Prints a message with format.
# 
#     Args:
#         msg (str): Message to print.
#         fmt (str): Format; try your luck with any value -- don't worry; if
#             it's illegal, you will be prompted with all legal values.
# 
#     Raises:
#         ValueError: If the input format is illegal.
#     """
#     fmt_strs = {
#         'header': '\033[95m',
#         'okblue': '\033[94m',
#         'okgreen': '\033[92m',
#         'warn': '\033[93m',
#         'fail': '\033[91m',
#         'bold': '\033[1m',
#         'underline': '\033[4m',
#     }
#     if fmt in fmt_strs.keys():
#         start_str = fmt_strs[fmt]
#         end_str = '\033[0m'
#     elif len(fmt) == 1:
#         start_str = "\n<" + "".join([fmt] * 78) + '\n\n' # as per PEP8
#         end_str = '\n' + start_str[2:-2] + ">\n"
#     else:
#         raise ValueError(
#             ("Legal values for fmt: %s, plus any single character "
#              "(which will be repeated into the line separator), "
#              "but input is '%s'") % (list(fmt_strs.keys()), fmt))
#     print(start_str + msg + end_str)


import os
from os.path import join, exists, isdir, dirname
from shutil import rmtree, copy2, copytree
from glob import glob
from .log import get_logger
from .imprt import preset_import
from .interact import format_print
    from collections import OrderedDict
    from json import dump
    from shlex import split
    from subprocess import Popen, DEVNULL
    from subprocess import Popen, PIPE
        if _is_cnspath(dst):
            cmd += ' --gfs_user %s' % _select_gfs_user(dst)
        _ = _call_assert_success(cmd)

    else:
        with gfile.AsUser(_select_gfs_user(dst)):
            if srcisdir:
                gfile.RecursivelyCopyDir(src, dst, overwrite=True)
            else:
                gfile.Copy(src, dst, overwrite=True)


def rm(path):
    """Removes a file or recursively a directory, with Google Colossus
    compatibility.

    Args:
        path (str)
    """
    if not _is_cnspath(path):
        # Quickly do the job and return
        if exists(path):
            if isdir(path):
                rmtree(path)
            else:
                os.remove(path)
        return

    # OK, a CNS path
    # Use gfile if available

# Path: third_party/xiuminglib/xiuminglib/log.py
# def get_logger(level=None):
#     """Creates a logger for functions in the library.
# 
#     Args:
#         level (str, optional): Logging level. Defaults to ``logging.INFO``.
# 
#     Returns:
#         logging.Logger: Logger created.
#     """
#     logging.basicConfig(level=logging.INFO)
#     logger = logging.getLogger()
#     return logger
# 
# Path: third_party/xiuminglib/xiuminglib/imprt.py
# def preset_import(name):
#     """A unified importer for both regular and ``google3`` modules, according
#     to specified presets/profiles (e.g., ignoring ``ModuleNotFoundError``).
#     """
#     if name in ('cv2', 'opencv'):
#         try:
#             # BUILD dep:
#             # "//third_party/py/cvx2",
#             from cvx2 import latest as mod
#             # Or
#             # BUILD dep:
#             # "//third_party/OpenCVX:cvx2",
#             # from google3.third_party.OpenCVX import cvx2 as cv2
#         except ModuleNotFoundError:
#             mod = import_module_404ok('cv2')
#         # TODO: Below is cleaner, but doesn't work
#         # mod = import_module_404ok('cvx2.latest')
#         # if mod is None:
#         #    mod = import_module_404ok('cv2')
#         return mod
# 
#     if name in ('tf', 'tensorflow'):
#         mod = import_module_404ok('tensorflow')
#         return mod
# 
#     if name == 'gfile':
#         # BUILD deps:
#         # "//pyglib:gfile",
#         # "//file/colossus/cns",
#         mod = import_module_404ok('google3.pyglib.gfile')
#         return mod
# 
#     if name in ('bpy', 'bmesh', 'OpenEXR', 'Imath'):
#         # BUILD deps:
#         # "//third_party/py/Imath",
#         # "//third_party/py/OpenEXR",
#         mod = import_module_404ok(name)
#         return mod
# 
#     if name in ('Vector', 'Matrix', 'Quaternion'):
#         mod = import_module_404ok('mathutils')
#         cls = _get_module_class(mod, name)
#         return cls
# 
#     if name == 'BVHTree':
#         mod = import_module_404ok('mathutils.bvhtree')
#         cls = _get_module_class(mod, name)
#         return cls
# 
#     raise NotImplementedError(name)
# 
# Path: third_party/xiuminglib/xiuminglib/interact.py
# def format_print(msg, fmt):
#     """Prints a message with format.
# 
#     Args:
#         msg (str): Message to print.
#         fmt (str): Format; try your luck with any value -- don't worry; if
#             it's illegal, you will be prompted with all legal values.
# 
#     Raises:
#         ValueError: If the input format is illegal.
#     """
#     fmt_strs = {
#         'header': '\033[95m',
#         'okblue': '\033[94m',
#         'okgreen': '\033[92m',
#         'warn': '\033[93m',
#         'fail': '\033[91m',
#         'bold': '\033[1m',
#         'underline': '\033[4m',
#     }
#     if fmt in fmt_strs.keys():
#         start_str = fmt_strs[fmt]
#         end_str = '\033[0m'
#     elif len(fmt) == 1:
#         start_str = "\n<" + "".join([fmt] * 78) + '\n\n' # as per PEP8
#         end_str = '\n' + start_str[2:-2] + ">\n"
#     else:
#         raise ValueError(
#             ("Legal values for fmt: %s, plus any single character "
#              "(which will be repeated into the line separator), "
#              "but input is '%s'") % (list(fmt_strs.keys()), fmt))
#     print(start_str + msg + end_str)


# Path: third_party/xiuminglib/xiuminglib/os.py
import os
from os.path import join, exists, isdir, dirname
from shutil import rmtree, copy2, copytree
from glob import glob
from .log import get_logger
from .imprt import preset_import
from .interact import format_print
    from collections import OrderedDict
    from json import dump
    from shlex import split
    from subprocess import Popen, DEVNULL
    from subprocess import Popen, PIPE

        if _is_cnspath(dst):
            cmd += ' --gfs_user %s' % _select_gfs_user(dst)
        _ = _call_assert_success(cmd)

    else:
        with gfile.AsUser(_select_gfs_user(dst)):
            if srcisdir:
                gfile.RecursivelyCopyDir(src, dst, overwrite=True)
            else:
                gfile.Copy(src, dst, overwrite=True)


def rm(path):
    """Removes a file or recursively a directory, with Google Colossus
    compatibility.

    Args:
        path (str)
    """
    if not _is_cnspath(path):
        # Quickly do the job and return
        if exists(path):
            if isdir(path):
                rmtree(path)
            else:
                os.remove(path)
        return

    # OK, a CNS path
    # Use gfile if available

    gfile = preset_import('gfile')