r""" Return a POSIX path string (using "/" separators) of ``location`` relative to ``root_location`. Both locations are absolute native locations. The returned path has no leading and trailing slashes. The first segment of this path is always the last segment of the
(cls, root_location, location)
| 1269 | |
| 1270 | @classmethod |
| 1271 | def build_path(cls, root_location, location): |
| 1272 | r""" |
| 1273 | Return a POSIX path string (using "/" separators) of ``location`` relative |
| 1274 | to ``root_location`. Both locations are absolute native locations. |
| 1275 | The returned path has no leading and trailing slashes. The first segment |
| 1276 | of this path is always the last segment of the ``root_location``. |
| 1277 | For example: |
| 1278 | >>> result = Resource.build_path(r'D:\\foo\\bar', r'D:\\foo\\bar\\baz') |
| 1279 | >>> assert result == 'bar/baz', repr(result) |
| 1280 | >>> result = Resource.build_path('/foo/bar/', '/foo/bar/baz') |
| 1281 | >>> assert result == 'bar/baz', result |
| 1282 | >>> result = Resource.build_path('/foo/bar/', '/foo/bar') |
| 1283 | >>> assert result == 'bar', result |
| 1284 | """ |
| 1285 | root_loc = clean_path(root_location) |
| 1286 | loc = clean_path(location) |
| 1287 | assert loc.startswith(root_loc) |
| 1288 | |
| 1289 | # keep the root directory name by default |
| 1290 | root_loc = posixpath_parent(root_loc).strip("/") |
| 1291 | path = loc.replace(root_loc, "", 1).strip("/") |
| 1292 | if TRACE: |
| 1293 | logger_debug("build_path:", root_loc, loc, path) |
| 1294 | return path |
| 1295 | |
| 1296 | def get_path(self, full_root=False, strip_root=False): |
| 1297 | """ |