@@ -81,7 +81,7 @@ def initial_inputs(self):
8181 # Check all data
8282 assert (self .TOKEN != "TODO" and self .TOKEN != None and self .TOKEN != "***" )
8383
84- if self .VERBOSE : print (f"{ self .get_emoji ('i' )} self.CONTINUE\t \t \t { self .CONTINUE } \n { self .get_emoji ('i' )} self.TOKEN\t \t \t { self .TOKEN } \n { self .get_emoji ('i' )} self.SOURCES_OF_TEMPLATES \t { self . SOURCES_OF_TEMPLATES } \n { self . get_emoji ( 'i' ) } self. ORGANIZATION_NAME\t { self .ORGANIZATION_NAME } \n { self .get_emoji ('i' )} self.IGNORE\t \t \t { self .IGNORE } \n { self .get_emoji ('i' )} self.VERBOSE\t \t \t { self .VERBOSE } " )
84+ if self .VERBOSE : print (f"{ self .get_emoji ('i' )} self.CONTINUE\t \t \t { self .CONTINUE } \n { self .get_emoji ('i' )} self.TOKEN\t \t \t { self .TOKEN } \n { self .get_emoji ('i' )} self.ORGANIZATION_NAME\t { self .ORGANIZATION_NAME } \n { self .get_emoji ('i' )} self.IGNORE\t \t \t { self .IGNORE } \n { self .get_emoji ('i' )} self.VERBOSE\t \t \t { self .VERBOSE } " )
8585
8686 except :
8787 self .CONTINUE = False
@@ -208,7 +208,7 @@ def choose_template(self):
208208 if "/" in self .ANSWERS ['template' ]: # If it's yours
209209 try :
210210 self .template_name = self .g .get_repo (f"{ self .ANSWERS ['template' ]} " ).full_name
211- assert (self .template .private == True )
211+ assert (self .g . get_repo ( self . template_name ) .private == True )
212212 except :
213213 print (f"{ self .get_emoji ('i' )} { self .ANSWERS ['template' ]} not founded, now I want to use the default repo" )
214214 self .template_name = "createstructure/default-template"
@@ -226,7 +226,7 @@ def scan_and_elaborate(self, loc=""):
226226 """Scan all files in the repository and push it in the new directory (cahanging the necessary)
227227 """
228228 if self .TEMPLATE and loc == "" :
229- self .create_file (".createstructure/change.json" , str ( wget ( f'https://raw.githubusercontent.com/ createstructure/default-template/master/. createstructure/change.json' ). text ))
229+ self .create_file (".createstructure/change.json" , self . g . get_repo ( " createstructure/default-template" ). get_contents ( ". createstructure/change.json" ). decoded_content . decode ( ))
230230
231231 contents = self .template .get_contents (f"{ loc } " )
232232 for content_file in sorted (contents , reverse = True , key = createstructure .name_of_path ): # Put .folders at the end
@@ -236,7 +236,10 @@ def scan_and_elaborate(self, loc=""):
236236 while (active_count () != 2 and dt .now ().timestamp () - start_waiting < 60 ): pass # Wait the end of processes or 60 seconds (a minute)
237237
238238 if content_file .type == "file" :
239- Thread (target = self .create_file , args = (self .change (content_file .path ), f"{ self .change (wget (f'https://raw.githubusercontent.com/{ self .template_name } /master/{ content_file .path } ' ).text )} " )).start ()
239+ try :
240+ Thread (target = self .create_file , args = (self .change (content_file .path ), self .change (self .g .get_repo (self .template_name ).get_contents (content_file .path ).decoded_content .decode ()))).start ()
241+ except : # If it's not a text file (eg. is an image)
242+ Thread (target = self .create_file , args = (self .change (content_file .path ), self .g .get_repo (self .template_name ).get_contents (content_file .path ).decoded_content )).start ()
240243 else :
241244 Thread (target = self .scan_and_elaborate , args = (content_file .path , )).start ()
242245
@@ -255,8 +258,11 @@ def change_map(self):
255258 change_map = {}
256259 change_map_special = {}
257260
261+ # escape value
262+ change_map ["solsol" ] = "sol"
263+
258264 # repo changes
259- change_map = eval (wget ( f"https://raw.githubusercontent.com/ { self .template_name } /master/. createstructure/change.json" ).text )
265+ change_map = eval (self . g . get_repo ( self .template_name ). get_contents ( ". createstructure/change.json" ).decoded_content . decode () )
260266
261267 # answer changes
262268 for key , value in self .ANSWERS .items ():
@@ -276,7 +282,7 @@ def change(self, text):
276282 """
277283 return compile ("|" .join (self .change_map_special .keys ())).sub (lambda m : self .change_map_special [escape (m .group (0 ))], compile ("|" .join (self .change_map .keys ())).sub (lambda m : self .change_map [escape (m .group (0 ))], text ))
278284
279- def create_file (self , path , file ):
285+ def create_file (self , path , file ):
280286 """Create the file into the repo
281287 """
282288 try :
0 commit comments