lib/util/log.py
def strip_common_path_prefix(basepath, relativeto=_SY_LIB_DIR):
    '''
    Strips the common prefix in a file path relative to the supplied path.
    By default, this uses the directory of this script to compare against.
    '''
    assert isinstance(basepath, str), \
        'basepath must be a string: %r' % basepath
    # Unfortunately, `os.path.commonpath` is only available in python 3.5+
    # To be compatible with 3.3, need to use commonprefix and then process it
    common_path_chars = os.path.commonprefix([basepath, relativeto])
    common_path_components = os.path.split(common_path_chars)
    # Don't use the last part (basename) - it is most likely garbage
    common_path_prefix_str = common_path_components[0]
    assert isinstance(common_path_prefix_str, str), \
        '[internal] common_path_prefix_str is not a string: %r' % \
        common_path_prefix_str
    assert basepath.startswith(common_path_prefix_str), \
        '[internal] basepath does not begin with common path prefix, ' \
        'calculation is incorrect: %r' % common_path_prefix_str
    # Since we know it starts with the prefix, just use a slice to get the rest
    common_path_prefix_len = len(common_path_prefix_str)
    tmp_stripped_prefix_path = basepath[common_path_prefix_len:]
    path_strip_characters = (
        os.path.sep if os.path.sep else '' +
        os.path.altsep if os.path.altsep else ''
    )
    cleaned_stripped_prefix_path = \
        tmp_stripped_prefix_path.strip(path_strip_characters)
    return cleaned_stripped_prefix_path

    Strips the common prefix in a file path relative to the supplied path.
    By default, this uses the directory of this script to compare against.
    
Strips the common prefix in a file path relative to the supplied path.
By default, this uses the directory of this script to compare against.
Strips the common prefix in a file path relative to the supplied path . By default this uses the directory of this script to compare against .
def strip_common_path_prefix(basepath, relativeto=_SY_LIB_DIR):
    assert isinstance(basepath, str), \
        'basepath must be a string: %r' % basepath
    common_path_chars = os.path.commonprefix([basepath, relativeto])
    common_path_components = os.path.split(common_path_chars)
    common_path_prefix_str = common_path_components[0]
    assert isinstance(common_path_prefix_str, str), \
        '[internal] common_path_prefix_str is not a string: %r' % \
        common_path_prefix_str
    assert basepath.startswith(common_path_prefix_str), \
        '[internal] basepath does not begin with common path prefix, ' \
        'calculation is incorrect: %r' % common_path_prefix_str
    common_path_prefix_len = len(common_path_prefix_str)
    tmp_stripped_prefix_path = basepath[common_path_prefix_len:]
    path_strip_characters = (
        os.path.sep if os.path.sep else '' +
        os.path.altsep if os.path.altsep else ''
    )
    cleaned_stripped_prefix_path = \
        tmp_stripped_prefix_path.strip(path_strip_characters)
    return cleaned_stripped_prefix_path
def strip_common_path_prefix ( basepath , relativeto = _SY_LIB_DIR ) : assert isinstance ( basepath , str ) , 'basepath must be a string: %r' % basepath common_path_chars = os . path . commonprefix ( [ basepath , relativeto ] ) common_path_components = os . path . split ( common_path_chars ) common_path_prefix_str = common_path_components [ 0 ] assert isinstance ( common_path_prefix_str , str ) , '[internal] common_path_prefix_str is not a string: %r' % common_path_prefix_str assert basepath . startswith ( common_path_prefix_str ) , '[internal] basepath does not begin with common path prefix, ' 'calculation is incorrect: %r' % common_path_prefix_str common_path_prefix_len = len ( common_path_prefix_str ) tmp_stripped_prefix_path = basepath [ common_path_prefix_len : ] path_strip_characters = ( os . path . sep if os . path . sep else '' + os . path . altsep if os . path . altsep else '' ) cleaned_stripped_prefix_path = tmp_stripped_prefix_path . strip ( path_strip_characters ) return cleaned_stripped_prefix_path
Strips the common prefix in a file path relative to the supplied path.
Strips the common prefix in a file path relative to the supplied path .
'''
    Strips the common prefix in a file path relative to the supplied path.
    By default, this uses the directory of this script to compare against.
    ''' # Unfortunately, `os.path.commonpath` is only available in python 3.5+ # To be compatible with 3.3, need to use commonprefix and then process it # Don't use the last part (basename) - it is most likely garbage # Since we know it starts with the prefix, just use a slice to get the rest
basepath
relativeto