Browse Source

[#101] The makefile is now creating the templates of an instance of Lodel2, extending the basis templates

Roland Haroutiounian 8 years ago
parent
commit
ba725a5cdb
2 changed files with 24 additions and 1 deletions
  1. 1
    1
      install/Makefile
  2. 23
    0
      install/utils.py

+ 1
- 1
install/Makefile View File

@@ -7,7 +7,7 @@ dbinit:
7 7
 	python -c "import utils; utils.db_init()"
8 8
 
9 9
 dirinit:
10
-	@mkdir templates
10
+	python -c "import utils; utils.dir_init()"
11 11
 
12 12
 emgraph:
13 13
 	python -c "import utils; utils.em_graph()"

+ 23
- 0
install/utils.py View File

@@ -3,6 +3,7 @@
3 3
 from loader import *
4 4
 import warnings
5 5
 
6
+
6 7
 def refreshdyn():
7 8
     import sys
8 9
     from EditorialModel.model import Model
@@ -18,6 +19,7 @@ def refreshdyn():
18 19
     # Create the python file
19 20
     fact.create_pyfile(em, LeDataSourceSQL, {})
20 21
 
22
+
21 23
 def db_init():
22 24
     from EditorialModel.backend.json_backend import EmBackendJson
23 25
     from EditorialModel.model import Model
@@ -25,6 +27,7 @@ def db_init():
25 27
     em = Model(EmBackendJson(Settings.em_file))
26 28
     em.migrate_handler(mh)
27 29
 
30
+
28 31
 def em_graph(output_file = None, image_format = None):
29 32
     from EditorialModel.model import Model
30 33
     from EditorialModel.backend.json_backend import EmBackendJson
@@ -63,3 +66,23 @@ def em_graph(output_file = None, image_format = None):
63 66
     os.unlink(dot_file)
64 67
     print("Output image written in file : '%s'" % output_file)
65 68
 
69
+
70
+def dir_init():
71
+    import os
72
+
73
+    # Templates
74
+    print("Creating Base Templates ...")
75
+    templates = {
76
+        'base': {'file': 'base.html', 'content': '{% extends "templates/base.html" %}'},
77
+        'base_backend': {'file': 'base_backend.html', 'content': '{% extends "templates/base_backend.html" %}'}
78
+    }
79
+
80
+    current_directory = os.path.dirname(os.path.abspath(__file__))
81
+    templates_directory = os.path.join(current_directory,'templates')
82
+    os.makedirs(templates_directory)
83
+
84
+    for template in templates:
85
+        my_file_path = os.path.join(templates_directory, template['file'])
86
+        with open(my_file_path) as my_file:
87
+            my_file.write(template['content'])
88
+        print("Created %s" % my_file_path)

Loading…
Cancel
Save