(filename, func, isabs, normalize_case, os_path_exists=os_path_exists, join=join)
| 485 | |
| 486 | |
| 487 | def _apply_func_and_normalize_case(filename, func, isabs, normalize_case, os_path_exists=os_path_exists, join=join): |
| 488 | if filename.startswith("<"): |
| 489 | # Not really a file, rather a synthetic name like <string> or <ipython-...>; |
| 490 | # shouldn't be normalized. |
| 491 | return filename |
| 492 | |
| 493 | r = func(filename) |
| 494 | |
| 495 | if not isabs: |
| 496 | if not os_path_exists(r): |
| 497 | r = _get_relative_filename_abs_path(filename, func) |
| 498 | |
| 499 | ind = r.find(".zip") |
| 500 | if ind == -1: |
| 501 | ind = r.find(".egg") |
| 502 | if ind != -1: |
| 503 | ind += 4 |
| 504 | zip_path = r[:ind] |
| 505 | inner_path = r[ind:] |
| 506 | if inner_path.startswith("!"): |
| 507 | # Note (fabioz): although I can replicate this by creating a file ending as |
| 508 | # .zip! or .egg!, I don't really know what's the real-world case for this |
| 509 | # (still kept as it was added by @jetbrains, but it should probably be reviewed |
| 510 | # later on). |
| 511 | # Note 2: it goes hand-in-hand with 'exists'. |
| 512 | inner_path = inner_path[1:] |
| 513 | zip_path = zip_path + "!" |
| 514 | |
| 515 | if inner_path.startswith("/") or inner_path.startswith("\\"): |
| 516 | inner_path = inner_path[1:] |
| 517 | if inner_path: |
| 518 | if normalize_case: |
| 519 | r = join(normcase(zip_path), inner_path) |
| 520 | else: |
| 521 | r = join(zip_path, inner_path) |
| 522 | return r |
| 523 | |
| 524 | if normalize_case: |
| 525 | r = normcase(r) |
| 526 | return r |
| 527 | |
| 528 | |
| 529 | _ZIP_SEARCH_CACHE = {} |
no test coverage detected