From fd718dca97716a59de9784fe0ba01c5060bb6d8c Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Mon, 29 Sep 2025 17:33:28 +0200 Subject: [PATCH 1/2] Allow for custom file path mapping --- src/unasync/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unasync/__init__.py b/src/unasync/__init__.py index e669b9a..9cf329a 100644 --- a/src/unasync/__init__.py +++ b/src/unasync/__init__.py @@ -71,11 +71,14 @@ def _unasync_file(self, filepath): tokens = tokenize_rt.src_to_tokens(f.read()) tokens = self._unasync_tokens(tokens) result = tokenize_rt.tokens_to_src(tokens) - outfilepath = filepath.replace(self.fromdir, self.todir) + outfilepath = self.map_in_to_out_file_path(filepath) os.makedirs(os.path.dirname(outfilepath), exist_ok=True) with open(outfilepath, "wb") as f: f.write(result.encode(encoding)) + def map_in_to_out_file_path(self, in_file_path): + return in_file_path.replace(self.fromdir, self.todir) + def _unasync_tokens(self, tokens): skip_next = False for i, token in enumerate(tokens): From 9a6928523644647466756673af0ba9b76a44621d Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Mon, 29 Sep 2025 17:44:26 +0200 Subject: [PATCH 2/2] Add changelog entry --- newsfragments/85.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/85.feature.rst diff --git a/newsfragments/85.feature.rst b/newsfragments/85.feature.rst new file mode 100644 index 0000000..5378344 --- /dev/null +++ b/newsfragments/85.feature.rst @@ -0,0 +1 @@ +Add public method ``map_in_to_out_file_path`` to ``Rule`` to allow for easier customization via inheritance.