Changeset 102:81fa8517d4b8
- Timestamp:
- 2007-07-11 15:27:08
(1 year ago)
- Author:
- Stefan Schwarzer <sschwarzer@sschwarzer.net>
- branch:
- default
- Message:
Renamed module `path` to `urlpath`.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r100 |
r102 |
|
| 31 | 31 | import coding |
|---|
| 32 | 32 | import config |
|---|
| 33 | | import path |
|---|
| | 33 | import urlpath |
|---|
| 34 | 34 | |
|---|
| 35 | 35 | |
|---|
| r101 |
r102 |
|
| 25 | 25 | |
|---|
| 26 | 26 | |
|---|
| 27 | | URLSEP = "/" |
|---|
| | 27 | sep = "/" |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | class NotUnderRoot(Exception): |
|---|
| … | … | |
| 60 | 60 | |
|---|
| 61 | 61 | >>> path.to_url("/the/root/", "/not/in/root/somedir/somefile/") |
|---|
| | 62 | ... #doctest: +ELLIPSIS |
|---|
| 62 | 63 | Traceback (most recent call last): |
|---|
| 63 | 64 | ... |
|---|
| 64 | | NotUnderRoot: path "/not/in/root/somedir/somefile" isn't under root directory "/the/root" |
|---|
| | 65 | NotUnderRoot: path "..." isn't under root directory "..." |
|---|
| 65 | 66 | """ |
|---|
| 66 | 67 | # convert path separators |
|---|
| 67 | | root = root.replace(os.sep, URLSEP) |
|---|
| 68 | | path = path.replace(os.sep, URLSEP) |
|---|
| | 68 | root = root.replace(os.sep, sep) |
|---|
| | 69 | path = path.replace(os.sep, sep) |
|---|
| 69 | 70 | # remove trailing slashes |
|---|
| 70 | | root = root.rstrip(URLSEP) |
|---|
| 71 | | path = path.rstrip(URLSEP) |
|---|
| | 71 | root = root.rstrip(sep) |
|---|
| | 72 | path = path.rstrip(sep) |
|---|
| 72 | 73 | # convert |
|---|
| 73 | 74 | if not path.startswith(root): |
|---|