`root_name` should NOT start with '/
(fname: os.PathLike, root_name: os.PathLike)
| 484 | #---------------------------------------------------------------------------- |
| 485 | |
| 486 | def remove_root(fname: os.PathLike, root_name: os.PathLike): |
| 487 | """`root_name` should NOT start with '/'""" |
| 488 | if fname == root_name or fname == ('/' + root_name): |
| 489 | return '' |
| 490 | elif fname.startswith(root_name + '/'): |
| 491 | return fname[len(root_name) + 1:] |
| 492 | elif fname.startswith('/' + root_name + '/'): |
| 493 | return fname[len(root_name) + 2:] |
| 494 | else: |
| 495 | return fname |
| 496 | |
| 497 | #---------------------------------------------------------------------------- |