(path)
| 6 | |
| 7 | |
| 8 | def getParentAndBase(path): |
| 9 | match = PREFIX.match(path) |
| 10 | if match is None: |
| 11 | if path.endswith('/'): |
| 12 | stripped_path = path[:-1] |
| 13 | else: |
| 14 | stripped_path = path |
| 15 | base = FNAME_MATCH.search(stripped_path) |
| 16 | if base is None: |
| 17 | raise ValueError('Invalid path') |
| 18 | parent = FNAME_MATCH.sub('', stripped_path) |
| 19 | return parent, base.group(1) |
| 20 | else: |
| 21 | prefix, leading_slash, uri = match.groups() |
| 22 | parts = uri.split('/') |
| 23 | parent_path = '/'.join(parts[:-1]) |
| 24 | |
| 25 | if leading_slash is not None: |
| 26 | parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1])) |
| 27 | else: |
| 28 | parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1])) |
| 29 | return parent_path, parts[-1] |
| 30 | |
| 31 | |
| 32 | def pathJoin(parent, base): |
no outgoing calls