Skip to content

Commit

Permalink
fix: added path normalization of ImportRemapping.name to match with o…
Browse files Browse the repository at this point in the history
…s.path.sep in splitting suffix, moved key normalization to ImportRemapping.key method (#97)
  • Loading branch information
vzotova authored Apr 19, 2023
1 parent 6f52e59 commit 6b1add1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ape_solidity/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def validate_entry(cls, value):
def _parts(self) -> List[str]:
return self.entry.split("=")

# path normalization needed in case delimiter in remapping key/value
# and system path delimiter are different (Windows as an example)
@property
def key(self) -> str:
return self._parts[0]
return os.path.normpath(self._parts[0])

@property
def name(self) -> str:
suffix_str = self._parts[1]
suffix_str = os.path.normpath(self._parts[1])
return suffix_str.split(os.path.sep)[0]

@property
Expand Down Expand Up @@ -91,9 +93,7 @@ def add_entry(self, remapping: ImportRemapping):
if not str(path).startswith(f".cache{os.path.sep}"):
path = Path(".cache") / path

# path normalization needed in case delimiter in remapping key and
# system path delimiter are different (Windows as an example)
self.import_map[os.path.normpath(remapping.key)] = str(path)
self.import_map[remapping.key] = str(path)


def get_import_lines(source_paths: Set[Path]) -> Dict[Path, List[str]]:
Expand Down

0 comments on commit 6b1add1

Please sign in to comment.