1313 DefStorage ,
1414 DefSupIm ,
1515 DefDemand ,
16+ DefProject ,
17+ DefProjectLoaded ,
1618)
1719
1820
@@ -31,8 +33,8 @@ def handle(self, *args, **options):
3133 demands = {}
3234
3335 for filename in os .listdir (folder_path ):
34- if filename . endswith ( ".json" ):
35- file_path = os .path .join ( folder_path , filename )
36+ file_path = os . path . join ( folder_path , filename )
37+ if os .path .isfile ( file_path ) and filename . endswith ( ".json" ):
3638 try :
3739 with open (file_path , "r" ) as file :
3840 print (f"Loading { filename } ... " , end = "" )
@@ -218,6 +220,53 @@ def handle(self, *args, **options):
218220 def_demand .save ()
219221 print ("\033 [92mOK\033 [0m" )
220222
223+ DefProject .objects .all ().delete ()
224+ for filename in os .listdir (os .path .join (folder_path , "defaultProjects" )):
225+ file_path = os .path .join (folder_path , "defaultProjects" , filename )
226+ if os .path .isfile (file_path ) and filename .endswith (".urbs" ):
227+ try :
228+ with open (file_path , "r" ) as file :
229+ name = "." .join (filename .split ("." )[:- 1 ])
230+ print (f"Loading default project { name } ... " , end = "" )
231+ data = json .load (file )
232+
233+ preset = DefProject ()
234+ preset .name = name
235+ preset .config = data
236+ preset .save ()
237+
238+ print ("\033 [92mOK\033 [0m" )
239+ except Exception as e :
240+ self .stdout .write (
241+ self .style .ERROR (f"Error processing file { filename } : { e } " )
242+ )
243+ exit (1 )
244+
245+ for filename in os .listdir (os .path .join (folder_path , "defaultProjectsLoaded" )):
246+ file_path = os .path .join (folder_path , "defaultProjectsLoaded" , filename )
247+ if os .path .isfile (file_path ) and filename .endswith (".urbs" ):
248+ try :
249+ with open (file_path , "r" ) as file :
250+ name = "." .join (filename .split ("." )[:- 1 ])
251+ print (f"Loading default project (loaded) { name } ... " , end = "" )
252+ data = json .load (file )
253+
254+ preset = DefProject ()
255+ preset .name = name
256+ preset .config = data
257+ preset .save ()
258+
259+ default = DefProjectLoaded ()
260+ default .preset = preset
261+ default .save ()
262+
263+ print ("\033 [92mOK\033 [0m" )
264+ except Exception as e :
265+ self .stdout .write (
266+ self .style .ERROR (f"Error processing file { filename } : { e } " )
267+ )
268+ exit (1 )
269+
221270
222271def getDefault (dict , key , default ):
223272 if key in dict :
0 commit comments