File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ from json_compiler .Compiler import Compiler as json_compiler
2
+ import sys
1
3
COMPILERS = {
2
4
"django-postgres" : "under development" ,
3
5
"flask-mongo" : "under development" ,
4
6
"nodejs-mongo" : "under development" ,
5
- }
7
+ "json" : json_compiler
8
+ }
9
+ def compile (compiler_name , project_name ):
10
+ compiler = COMPILERS [compiler_name ](project_name )
11
+ compiler .compile ()
12
+ OPTIONS = {
13
+ "compile" : compile ,
14
+ "c" : compile
15
+ }
16
+ def main ():
17
+ OPTIONS [sys .argv [1 ]](sys .argv [2 ], sys .argv [3 ])
18
+ return
19
+
20
+ main ()
21
+ #python .\compiler.py c json ../blueprints/examples/facebook/main.app.json
Original file line number Diff line number Diff line change
1
+ import json
2
+ from searcher import search_json
3
+ MODELS_FIELD = "models"
4
+ EXTENDS_FIELD = "__extends"
5
+
6
+ class Compiler :
7
+ blueprint :dict = {}
8
+ def __init__ (self , main_file ) -> None :
9
+ self .main_file = main_file
10
+ with open (main_file , "r" ) as f :
11
+ self .blueprint = json .load (f )
12
+ def compile_models (self ):
13
+ if MODELS_FIELD not in self .blueprint and EXTENDS_FIELD not in self .blueprint :
14
+ raise NameError ("models is not defined" )
15
+ for model in self .blueprint ["models" ]:
16
+ print (model )
17
+ if type (model ) == str :
18
+ search_json (model , self .main_file )
19
+ def compile (self ):
20
+ self .compile_models ()
Original file line number Diff line number Diff line change
1
+ import os
2
+ def search_json (route , base_file ):
3
+ splited = route .split ("." )
4
+
5
+ print (os .listdir (os .path .dirname (base_file )))
6
+ #for step in splited:
7
+ # os.listdir()
You can’t perform that action at this time.
0 commit comments