Skip to content

Commit fd718dc

Browse files
committed
Allow for custom file path mapping
1 parent e56590d commit fd718dc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/unasync/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ def _unasync_file(self, filepath):
7171
tokens = tokenize_rt.src_to_tokens(f.read())
7272
tokens = self._unasync_tokens(tokens)
7373
result = tokenize_rt.tokens_to_src(tokens)
74-
outfilepath = filepath.replace(self.fromdir, self.todir)
74+
outfilepath = self.map_in_to_out_file_path(filepath)
7575
os.makedirs(os.path.dirname(outfilepath), exist_ok=True)
7676
with open(outfilepath, "wb") as f:
7777
f.write(result.encode(encoding))
7878

79+
def map_in_to_out_file_path(self, in_file_path):
80+
return in_file_path.replace(self.fromdir, self.todir)
81+
7982
def _unasync_tokens(self, tokens):
8083
skip_next = False
8184
for i, token in enumerate(tokens):

0 commit comments

Comments
 (0)