Browse Source

[#101] Fixed the template creation process

Roland Haroutiounian 8 years ago
parent
commit
aadf063a10
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      install/utils.py

+ 6
- 3
install/utils.py View File

@@ -79,10 +79,13 @@ def dir_init():
79 79
 
80 80
     current_directory = os.path.dirname(os.path.abspath(__file__))
81 81
     templates_directory = os.path.join(current_directory,'templates')
82
-    os.makedirs(templates_directory)
82
+    if not os.path.exists(templates_directory):
83
+        os.makedirs(templates_directory)
83 84
 
84
-    for template in templates:
85
+    for _, template in templates.items():
85 86
         my_file_path = os.path.join(templates_directory, template['file'])
86
-        with open(my_file_path) as my_file:
87
+        if os.path.exists(my_file_path):
88
+            os.unlink(my_file_path)
89
+        with open(my_file_path, 'w') as my_file:
87 90
             my_file.write(template['content'])
88 91
         print("Created %s" % my_file_path)

Loading…
Cancel
Save