33from pathlib import Path
44import yaml
55
6- config_dir_name = ' drupal_dockerizer'
7- config_file_name = ' config.yml'
6+ config_dir_name = " drupal_dockerizer"
7+ config_file_name = " config.yml"
88user_config_dir = appdirs .user_config_dir ()
99
10- class AppConfig ():
10+
11+ class AppConfig :
1112 data = {}
1213
1314 def __init__ (self ) -> None :
@@ -17,37 +18,46 @@ def __init__(self) -> None:
1718 self .config_file_path = str (config_file_path )
1819
1920 if not os .path .exists (str (config_dir_path )):
20- os .mkdir (str (config_dir_path ))
21+ os .mkdir (str (config_dir_path ))
2122
2223 if not os .path .exists (self .config_file_path ):
23- self .data = {
24- ' is_check_requirements_tools' : False ,
25- ' version' : 0.1 ,
26- 'projects' : {}
27- }
28- self .save ()
24+ self .data = {
25+ " is_check_requirements_tools" : False ,
26+ " version" : "0.0.4" ,
27+ "instances" : {},
28+ }
29+ self .save ()
2930 self .load ()
3031
3132 def save (self ):
32- file_config = open (self .config_file_path , 'w' )
33- yaml .safe_dump (self .data , file_config , sort_keys = True )
34- file_config .close ()
33+ file_config = open (self .config_file_path , "w" )
34+ yaml .safe_dump (self .data , file_config , sort_keys = True )
35+ file_config .close ()
3536
3637 def load (self ):
37- file_config = open (self .config_file_path , 'r' )
38- self .data = dict (yaml .full_load (file_config ))
39- file_config .close ()
40-
41- def addProject (self , project_conf ):
42- self .data ['projects' ][project_conf .data ['compose_project_name' ]] = {
43- 'project' : project_conf .data ['compose_project_name' ],
44- 'root_dir' : project_conf .data ['drupal_root_dir' ],
45- 'domain' : project_conf .data ['domain_name' ] if project_conf .data ['advanced_networking' ] else 'http://localhost' ,
46- 'status' : 'up' ,
38+ file_config = open (self .config_file_path , "r" )
39+ self .data = dict (yaml .full_load (file_config ))
40+ file_config .close ()
41+
42+ def addInstance (self , instance_conf ):
43+ self .data ["instances" ][instance_conf .data ["compose_project_name" ]] = {
44+ "instance" : instance_conf .data ["compose_project_name" ],
45+ "root_dir" : instance_conf .data ["drupal_root_dir" ],
46+ "domain" : instance_conf .data ["domain_name" ]
47+ if instance_conf .data ["advanced_networking" ]
48+ else "http://localhost" ,
49+ "status" : "up" ,
4750 }
4851
49- def stopProject (self , project_conf ):
50- self .data ['projects' ][project_conf .data ['compose_project_name' ]]['status' ] = 'stop'
52+ def stopInstance (self , instance_conf ):
53+ self .data ["instances" ][instance_conf .data ["compose_project_name" ]][
54+ "status"
55+ ] = "stop"
56+
57+ def upInstance (self , instance_conf ):
58+ self .data ["instances" ][instance_conf .data ["compose_project_name" ]][
59+ "status"
60+ ] = "up"
5161
52- def removeProject (self , project_conf ):
53- del self .data ['projects' ][ project_conf .data [' compose_project_name' ]]
62+ def removeInstance (self , instance_conf ):
63+ del self .data ["instances" ][ instance_conf .data [" compose_project_name" ]]
0 commit comments