r""" Return True if the `location` path is likely a POSIX-like path using POSIX path separators (slash or "/")or has no path separator. Return False if the `location` path is likely a Windows-like path using backslash as path separators (e.g. "\").
(location)
| 140 | |
| 141 | |
| 142 | def is_posixpath(location): |
| 143 | r""" |
| 144 | Return True if the `location` path is likely a POSIX-like path using POSIX path |
| 145 | separators (slash or "/")or has no path separator. |
| 146 | |
| 147 | Return False if the `location` path is likely a Windows-like path using backslash |
| 148 | as path separators (e.g. "\"). |
| 149 | """ |
| 150 | has_slashes = "/" in location |
| 151 | has_backslashes = "\\" in location |
| 152 | # windows paths with drive |
| 153 | if location: |
| 154 | drive, _ = ntpath.splitdrive(location) |
| 155 | if drive: |
| 156 | return False |
| 157 | |
| 158 | # a path is always POSIX unless it contains ONLY backslahes |
| 159 | # which is a rough approximation (it could still be posix) |
| 160 | is_posix = True |
| 161 | if has_backslashes and not has_slashes: |
| 162 | is_posix = False |
| 163 | return is_posix |
| 164 | |
| 165 | |
| 166 | def as_posixpath(location): |
no outgoing calls
no test coverage detected