This is from pythons documentation of the path module.
Basically the “…/” that is added signals the normpath function to go up 4 steps in the path.
os.path.normpath(path )
Normalize a pathname by collapsing redundant separators and up-level references so thatA//B
,A/B/
,A/./B
andA/foo/../B
all becomeA/B
. This string manipulation may change the meaning of a path that contains symbolic links. On Windows, it converts forward slashes to backward slashes. To normalize case, usenormcase()
.>
Also os.path.join is similar to just adding the strings with +, but it leaves the joining to the path module which supports multiple platforms.
Edit:
I was looking through the source code, and saw this. This is how pyrevit gets it’s root directory which is another reference. It uses os.path.dirname instead which may be more intuitive.
# -----------------------------------------------------------------------------
# config environment paths
# -----------------------------------------------------------------------------
# main pyrevit repo folder
try:
# 3 steps back for <home>/Lib/pyrevit
HOME_DIR = op.dirname(op.dirname(op.dirname(__file__)))
except NameError:
raise Exception('Critical Error. Can not find home directory.')
# BIN directory
BIN_DIR = op.join(HOME_DIR, 'bin')
# main pyrevit lib folders
MAIN_LIB_DIR = op.join(HOME_DIR, 'pyrevitlib')
MISC_LIB_DIR = op.join(HOME_DIR, 'site-packages')
# path to pyrevit module
MODULE_DIR = op.join(MAIN_LIB_DIR, 'pyrevit')
# loader directory
LOADER_DIR = op.join(MODULE_DIR, 'loader')
# runtime directory
RUNTIME_DIR = op.join(MODULE_DIR, 'runtime')
# addin directory
ADDIN_DIR = op.join(LOADER_DIR, 'addin')