1- """This is the magic "robottino" by Castellani Davide
1+ """This is the magic bot by Castellani Davide
22With this programm you can easly create a repository on GitHub with a basic template, personalized for your use.
33
44If there was any type of problem you can contact me on my help email: help@castellanidavide.it
1313from sys import argv
1414
1515__author__ = "help@castellanidavide.it"
16- __version__ = "5.5 2020-12-13 "
16+ __version__ = "6.0 2020-12-16 "
1717
1818class create_structure :
19- def __init__ (self , TOKEN , SOUCES_OF_TEMPLATES , ORGANIZATION_NAME , IGNORE_FOLDERS ):
19+ def __init__ (self ):
2020 """Main function
2121 """
22- self .TOKEN = TOKEN
23- self .SOUCES_OF_TEMPLATES = SOUCES_OF_TEMPLATES
24- self .ORGANIZATION_NAME = ORGANIZATION_NAME
25- self .IGNORE_FOLDERS = IGNORE_FOLDERS
26-
27- self .login () # Login
22+ # Initial inputs
23+ self .initial_inputs ()
24+
25+ if self .CONTINUE :
26+ self .login () # Login
27+
28+ # Make questions
29+ self .asks ()
2830
29- # Make questions
30- self .asks ()
31+ # Make repo
32+ Thread ( target = self .create_repo ()). start ()
3133
32- # Make repo
33- Thread ( target = self .create_repo ()). start ()
34+ # Get template
35+ self .choose_template ()
3436
35- # Get template
36- self .choose_template ()
37+ # Get changes
38+ self .change_map ()
39+
40+ # Make all
41+ Thread (target = self .scan_and_elaborate ()).start ()
3742
38- # Get changes
39- self .change_map ()
43+ def initial_inputs (self ):
44+ """Initial input read
45+ """
46+ # Default
47+ self .CONTINUE = True
48+ self .TOKEN = None
49+ self .SOUCES_OF_TEMPLATES = ['CastellaniDavide' ]
50+ self .ORGANIZATION_NAME = ""
51+ self .IGNORE_FOLDERS = []
52+
53+ # Check if there were all argv
54+ try :
55+ # Go to documentation if requested
56+ assert (not ("-h" in argv or "--help" in argv ))
57+
58+ # Read arguments
59+ for arg in argv :
60+ # find tocken
61+ if "--token=" in arg or "-t=" in arg :
62+ self .TOKEN = arg .replace ("--token=" , "" ).replace ("-t=" , "" )
63+ # find souces
64+ if "--sources=" in arg or "-s=" in arg :
65+ self .SOUCES_OF_TEMPLATES = [i for i in arg .replace ("--sources=" , "" ).replace ("-s=" , "" ).replace ("'" , "" ).replace ('"' , "" )[1 :- 1 ].split ("," )]
66+ # find tocken
67+ if "--organization=" in arg or "-o=" in arg :
68+ self .ORGANIZATION_NAME = arg .replace ("--organization=" , "" ).replace ("-o=" , "" )
69+ # find tocken
70+ if "--ignore=" in arg or "-i=" in arg :
71+ self .IGNORE_FOLDERS = [i for i in arg .replace ("--ignore=" , "" ).replace ("-i=" , "" ).replace ("'" , "" ).replace ('"' , "" )[1 :- 1 ].split ("," )]
4072
41- # Make all
42- Thread (target = self .scan_and_elaborate ()).start ()
73+ # Check all data
74+ assert (self .TOKEN != "TODO" and self .TOKEN != None and self .TOKEN != "***" )
75+
76+ except :
77+ self .CONTINUE = False
78+ documentation = ["usage create_structure" ,
79+ "\t [--token= | -t=]" ,
80+ "\t [--sources= | -s=]" ,
81+ "\t [--organization= | -o=]" ,
82+ "\t [--ignore= | -i=]" ,
83+ "" ,
84+ "These are the create_structure arguments:" ,
85+ "\t --token= or -t= The GitHub tocken with repo and organization permission" ,
86+ "\t --sources= or -s= (optional) The array with your favourite sources, for eg. ['CastellaniDavide']" ,
87+ "\t --organization= or -o= (optional) The organization name, leave empty if you want to create repos in your personal account" ,
88+ "\t --ignore= or -i= (optional) The folders to be ignored" ,
89+ "" ,
90+ "Extra situation(s):" ,
91+ "\t --help or -h To see the documentation" ,
92+ "" ,
93+ "Made with ❤ by Castellani Davide (@DavideC03)" ,
94+ "" ]
95+
96+ for line in documentation :
97+ print (line )
4398
4499 def login (self ):
45100 """Made the login in GitHub
@@ -184,60 +239,5 @@ def create_file (self, path, file):
184239 """ Read the argv, and sometimes writes the documentation
185240 """
186241
187- # Default
188- TOKEN = None
189- SOUCES_OF_TEMPLATES = ['CastellaniDavide' ]
190- ORGANIZATION_NAME = ""
191- IGNORE_FOLDERS = []
192-
193- # Check if there were all argv
194- try :
195- # Go to documentation if requested
196- assert (not ("-h" in argv or "--help" in argv ))
197-
198- # Read arguments
199- for arg in argv :
200- # find tocken
201- if "--token=" in arg or "-t=" in arg :
202- TOKEN = arg .replace ("--token=" , "" ).replace ("-t=" , "" )
203- # find souces
204- if "--sources=" in arg or "-s=" in arg :
205- SOUCES_OF_TEMPLATES = [i for i in arg .replace ("--sources=" , "" ).replace ("-s=" , "" ).replace ("'" , "" ).replace ('"' , "" )[1 :- 1 ].split ("," )]
206- # find tocken
207- if "--organization=" in arg or "-o=" in arg :
208- ORGANIZATION_NAME = arg .replace ("--organization=" , "" ).replace ("-o=" , "" )
209- # find tocken
210- if "--ignore=" in arg or "-i=" in arg :
211- IGNORE_FOLDERS = [i for i in arg .replace ("--ignore=" , "" ).replace ("-i=" , "" ).replace ("'" , "" ).replace ('"' , "" )[1 :- 1 ].split ("," )]
212242
213- # Check all data
214- assert (TOKEN != None and TOKEN != "***" )
215-
216- # Start with code
217- try :
218- create_structure (TOKEN , SOUCES_OF_TEMPLATES , ORGANIZATION_NAME , IGNORE_FOLDERS )
219- except :
220- print ("There is an error, try to check if the repo name is already used." )
221-
222- except :
223- documentation = ["usage create_structure" ,
224- "\t [--token= | -t=]" ,
225- "\t [--sources= | -s=]" ,
226- "\t [--organization= | -o=]" ,
227- "\t [--ignore= | -i=]" ,
228- "" ,
229- "These are the create_structure arguments:" ,
230- "\t --token= or -t= The GitHub tocken with repo and organization permission" ,
231- "\t --sources= or -s= (optional) The array with your favourite sources, for eg. ['CastellaniDavide']" ,
232- "\t --organization= or -o= (optional) The organization name, leave empty if you want to create repos in your personal account" ,
233- "\t --ignore= or -i= (optional) The folders to be ignored" ,
234- "" ,
235- "Extra situation(s):" ,
236- "\t --help or -h To see the documentation" ,
237- "" ,
238- "Made with ❤ by Castellani Davide (@DavideC03)" ,
239- "" ]
240-
241- for line in documentation :
242- print (line )
243243
0 commit comments