Skip to content

Commit 07c653c

Browse files
authored
Merge pull request #918 from tc-imba/bug/fix-917-python-namespace-package-folders
fix #917: python namespace package folders
2 parents 7e89e84 + ab0c3af commit 07c653c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,18 @@ public void processOpts() {
202202
setPackageUrl((String) additionalProperties.get(PACKAGE_URL));
203203
}
204204

205+
final String packageFolder = packageName.replace('.', File.separatorChar);
206+
205207
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
206208

207209
supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini"));
208210
supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
209211
supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt"));
210212

211-
supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "configuration.py"));
212-
supportingFiles.add(new SupportingFile("__init__package.mustache", packageName, "__init__.py"));
213-
supportingFiles.add(new SupportingFile("__init__model.mustache", packageName + File.separatorChar + modelPackage, "__init__.py"));
214-
supportingFiles.add(new SupportingFile("__init__api.mustache", packageName + File.separatorChar + apiPackage, "__init__.py"));
213+
supportingFiles.add(new SupportingFile("configuration.mustache", packageFolder, "configuration.py"));
214+
supportingFiles.add(new SupportingFile("__init__package.mustache", packageFolder, "__init__.py"));
215+
supportingFiles.add(new SupportingFile("__init__model.mustache", packageFolder + File.separatorChar + modelPackage, "__init__.py"));
216+
supportingFiles.add(new SupportingFile("__init__api.mustache", packageFolder + File.separatorChar + apiPackage, "__init__.py"));
215217

216218
if(Boolean.FALSE.equals(excludeTests)) {
217219
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
@@ -220,16 +222,16 @@ public void processOpts() {
220222
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
221223
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
222224
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
223-
supportingFiles.add(new SupportingFile("api_client.mustache", packageName, "api_client.py"));
225+
supportingFiles.add(new SupportingFile("api_client.mustache", packageFolder, "api_client.py"));
224226

225227
if ("asyncio".equals(getLibrary())) {
226-
supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packageName, "rest.py"));
228+
supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packageFolder, "rest.py"));
227229
additionalProperties.put("asyncio", "true");
228230
} else if ("tornado".equals(getLibrary())) {
229-
supportingFiles.add(new SupportingFile("tornado/rest.mustache", packageName, "rest.py"));
231+
supportingFiles.add(new SupportingFile("tornado/rest.mustache", packageFolder, "rest.py"));
230232
additionalProperties.put("tornado", "true");
231233
} else {
232-
supportingFiles.add(new SupportingFile("rest.mustache", packageName, "rest.py"));
234+
supportingFiles.add(new SupportingFile("rest.mustache", packageFolder, "rest.py"));
233235
}
234236

235237
modelPackage = packageName + "." + modelPackage;

0 commit comments

Comments
 (0)