Resolve `..` and '.' from path.
(path)
| 230 | return mathlibs |
| 231 | |
| 232 | def minrelpath(path): |
| 233 | """Resolve `..` and '.' from path. |
| 234 | """ |
| 235 | if not is_string(path): |
| 236 | return path |
| 237 | if '.' not in path: |
| 238 | return path |
| 239 | l = path.split(os.sep) |
| 240 | while l: |
| 241 | try: |
| 242 | i = l.index('.', 1) |
| 243 | except ValueError: |
| 244 | break |
| 245 | del l[i] |
| 246 | j = 1 |
| 247 | while l: |
| 248 | try: |
| 249 | i = l.index('..', j) |
| 250 | except ValueError: |
| 251 | break |
| 252 | if l[i-1]=='..': |
| 253 | j += 1 |
| 254 | else: |
| 255 | del l[i], l[i-1] |
| 256 | j = 1 |
| 257 | if not l: |
| 258 | return '' |
| 259 | return os.sep.join(l) |
| 260 | |
| 261 | def sorted_glob(fileglob): |
| 262 | """sorts output of python glob for https://bugs.python.org/issue30461 |