(self, name)
| 67 | self.cache = {} |
| 68 | |
| 69 | def resolve(self, name): |
| 70 | if name in self.cache: |
| 71 | return self.cache[name] |
| 72 | |
| 73 | source = name |
| 74 | if not self.preserve_deterministic_prefix and name.startswith(DETERMINISTIC_PREFIX): |
| 75 | source = EMSCRIPTEN_PREFIX + name.removeprefix(DETERMINISTIC_PREFIX) |
| 76 | |
| 77 | provided = False |
| 78 | for p in self.prefixes: |
| 79 | if source.startswith(p['prefix']): |
| 80 | source = p['replacement'] + source.removeprefix(p['prefix']) |
| 81 | provided = True |
| 82 | break |
| 83 | |
| 84 | # If prefixes were provided, we use that; otherwise if base_path is set, we |
| 85 | # emit a relative path. For files with deterministic prefix, we never use |
| 86 | # a relative path, precisely to preserve determinism, and because it would |
| 87 | # still point to the wrong location, so we leave the filepath untouched to |
| 88 | # let users map it to the proper location using prefix options. |
| 89 | if not (source.startswith(DETERMINISTIC_PREFIX) or provided or self.base_path is None): |
| 90 | try: |
| 91 | source = os.path.relpath(source, self.base_path) |
| 92 | except ValueError: |
| 93 | source = os.path.abspath(source) |
| 94 | source = utils.normalize_path(source) |
| 95 | |
| 96 | self.cache[name] = source |
| 97 | return source |
| 98 | |
| 99 | |
| 100 | # SourceMapPrefixes contains resolver for file names that are: |
no outgoing calls