From 577f118fcb4a1c90638ab6ac7437cc510a2578bc Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Tue, 24 Jun 2014 14:49:39 +0400 Subject: [PATCH] Use regexp for transforming module name into package name (PY-13336) str.strip() strips all the characters contained in its arguments in no particular order. --- .../helpers/pycharm_generator_utils/module_redeclarator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/helpers/pycharm_generator_utils/module_redeclarator.py b/python/helpers/pycharm_generator_utils/module_redeclarator.py index 0e96b9c2c720..3af1961a0e09 100644 --- a/python/helpers/pycharm_generator_utils/module_redeclarator.py +++ b/python/helpers/pycharm_generator_utils/module_redeclarator.py @@ -120,7 +120,7 @@ class ModuleRedeclarator(object): init = None try: if self.split_modules: - mod_path = self.outfile.strip(".py") + mod_path = module_to_package_name(self.outfile) fname = build_output_name(mod_path, "__init__") init = fopen(fname, "w") @@ -1093,3 +1093,7 @@ class ModuleRedeclarator(object): for mod_name in sorted_no_case(self.hidden_imports.keys()): out(0, 'import ', mod_name, ' as ', self.hidden_imports[mod_name]) out(0, "") # empty line after group + + +def module_to_package_name(module_name): + return re.sub(r"(.*)\.py$", r"\1", module_name)