cf.pathjoin

cf.pathjoin(path1, path2)[source]

Join two file path components intelligently.

If either of the paths is a URL then a URL will be returned

Parameters
path1: str

The first component of the path.

path2: str

The second component of the path.

Returns
str

The joined paths.

Examples:

>>> cf.pathjoin('/data/archive', '../archive/file.nc')
'/data/archive/../archive/file.nc'
>>> cf.pathjoin('/data/archive', '../archive/file.nc')
'/data/archive/../archive/file.nc'
>>> cf.abspath(cf.pathjoin('/data/', 'archive/'))
'/data/archive'
>>> cf.pathjoin('http://data', 'archive/file.nc')
'http://data/archive/file.nc'