Skip to content

Commit 6c15c36

Browse files
committed
add __init__ generator
1 parent 5860c92 commit 6c15c36

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

generate_schemas.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async function return_json_schema(directoryPath, folder_path, projectName) {
7979
if (folder.name == "schemas") {
8080
const jsonFiles = glob.sync(path.join(folder.path, "**/*.json"));
8181
var schemas = {};
82+
let initContent = "";
8283
jsonFiles.forEach(async (filePath) => {
8384
try {
8485
const fileContent = fs.readFileSync(filePath, "utf8");
@@ -101,6 +102,7 @@ async function return_json_schema(directoryPath, folder_path, projectName) {
101102
})
102103
.join(separator);
103104
schemas[filename] = jsonData;
105+
initContent += "from ." + filename + " import *\n";
104106
const { lines: jsonTypes } = await quicktypeJSONSchema(
105107
filename,
106108
fileContent
@@ -113,7 +115,9 @@ async function return_json_schema(directoryPath, folder_path, projectName) {
113115
"@dataclass\nclass $1(DataClassJsonMixin):"
114116
);
115117
const pythonFile = path.join(folder.path, filename + ".py");
118+
const initFile = path.join(folder.path, "__init__.py");
116119
fs.writeFileSync(pythonFile, pythonContent);
120+
fs.writeFileSync(initFile, initContent);
117121
} catch (error) {
118122
console.error(
119123
`Erreur lors de la lecture du fichier ${filePath}:`,

0 commit comments

Comments
 (0)