Ejemplo n.º 1
0
    def __enter__(self):
        """
        ...
        :return:
        :rtype: ConfigurableContextDecorator
        """

        if not jpyzCommon.isNullOrEmpty(self._enterTag):
            jpyzCommon.trace(tag=self._enterTag)

        return self
Ejemplo n.º 2
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        """
        ...
        :param exc_type:
        :param exc_val:
        :param exc_tb:
        :return:
        """

        if not jpyzCommon.isNullOrEmpty(self._exitTag):
            jpyzCommon.trace(tag=self._exitTag)
Ejemplo n.º 3
0
def _create_01(basePath, profileDirName, targetDirName, removeOnly=False):
    """
    ...
    :param basePath:
    :type basePath: str
    :param profileDirName:
    :type profileDirName: str
    :param targetDirName:
    :type targetDirName: str
    :param removeOnly:
    :type removeOnly: bool
    :return:
    """

    baseOSPath = Constant.EMPTY
    targetOSName = Constant.EMPTY
    targetOSPath = os.path.join(baseOSPath, targetOSName)
    linkOSName = Constant.EMPTY
    linkOSPath = os.path.join(baseOSPath, linkOSName)
    # todo: extract computer-name from ???
    computerName = Constant.EMPTY
    computerPath = computerName
    targetProfilePath = Constant.EMPTY

    delimiter = os.sep
    list = os.path.join(basePath, targetDirName).strip(delimiter).split(delimiter)

    delimiter = list[0].upper()

    if os.path.splitdrive(basePath)[0].upper() == delimiter:
        list[0] = "[{drive} Drive]".format(drive=delimiter.strip(Constant.COLON))

    list.reverse()

    delimiter = Constant.PLUS_SIGN
    linkProfilePath = delimiter.join(list)
    linkPath = os.path.join(os.path.expanduser(Default.USER_PROFILE_DIR_EXP), profileDirName, linkProfilePath)
    tds = "{} ".format(Constant.COLON)

    if os.path.lexists(linkPath):
        common.trace("Remove", value=linkPath, tds=tds)

        os.remove(linkPath)
    elif removeOnly:
        common.trace\
            (
                "Path"
                ,
                descriptor=common.formatTraceString(linkPath)
                ,
                value="does not exist (cannot remove)!"
                ,
                tds=" "
            )

    if removeOnly:
        return

    baseTargetPath = os.path.join(basePath, targetOSPath, computerPath)
    targetPath = os.path.join(baseTargetPath, targetProfilePath, targetDirName)

    common.trace\
        (
            "Symlink"
            ,
            descriptor=common.formatTraceString(targetPath)
            ,
            value=common.formatTraceString(linkPath)
            ,
            tds=tds
            ,
            dvs=" <-- "
        )

    os.symlink(targetPath, linkPath)