|
12 | 12 | from time import sleep |
13 | 13 | from threading import Thread, active_count, Lock |
14 | 14 | from sys import argv |
| 15 | +from os import system |
15 | 16 |
|
16 | 17 | __author__ = "help@castellanidavide.it" |
17 | | -__version__ = "7.9 2021-04-04" |
| 18 | +__version__ = "08.01 2021-04-15" |
18 | 19 |
|
19 | 20 | class createstructure: |
20 | | - def __init__ (self, token=None, souces=['CastellaniDavide'], organization_name="", IGNORE=[], verbose=False, template=False, answers=None): |
| 21 | + def __init__ (self, token=None, organization_name="", IGNORE=[], verbose=False, template=False, answers=None): |
21 | 22 | """Main function |
22 | 23 | """ |
23 | 24 | # Set main variabiles |
@@ -51,6 +52,9 @@ def __init__ (self, token=None, souces=['CastellaniDavide'], organization_name=" |
51 | 52 | # Make all |
52 | 53 | self.scan_and_elaborate() |
53 | 54 |
|
| 55 | + # Eventually download |
| 56 | + self.download() |
| 57 | + |
54 | 58 | def initial_inputs(self): |
55 | 59 | """Initial input read |
56 | 60 | """ |
@@ -88,15 +92,13 @@ def initial_inputs(self): |
88 | 92 | documentation = ["usage createstructure", |
89 | 93 | "\t[--ignore= | -i=]", |
90 | 94 | "\t[--organization= | -o=]", |
91 | | - "\t[--sources= | -s=]", |
92 | 95 | "\t[--template | -temp]" |
93 | 96 | "\t[--token= | -t=]", |
94 | 97 | "\t[--verbose | -v]", |
95 | 98 | "", |
96 | 99 | "These are the createstructure arguments:", |
97 | 100 | "\t--ignore= or -i= (optional) The folders to be ignored", |
98 | 101 | "\t--organization= or -o= (optional) The organization name, leave empty if you want to create repos in your personal account", |
99 | | - "\t--sources= or -s= (optional) The array with your favourite sources, for eg. ['CastellaniDavide']", |
100 | 102 | "\t--token= or -t= The GitHub tocken with repo and organization permission", |
101 | 103 | "\t--template= or -temp= Create a template", |
102 | 104 | "\t--verbose or -v Verbose option, you will see the main variabiles and lots more" |
@@ -125,6 +127,7 @@ def asks(self): |
125 | 127 | ["prefix", "Insert a prefix for the repository (or don't insert anything): "], |
126 | 128 | ["team", "Do you want insert this repo into a team? [y/N]: "], |
127 | 129 | ["private", "Is that private? [y/N]: "], |
| 130 | + ["download", "Want you download the repo? [Y/n]: "], |
128 | 131 | ] |
129 | 132 | self.ANSWERS = {} |
130 | 133 |
|
@@ -296,10 +299,18 @@ def create_file(self, path, file): |
296 | 299 | except: |
297 | 300 | print(f"There was an error to this file: {path}") |
298 | 301 |
|
299 | | - def is_positive(answer): |
| 302 | + def download(self): |
| 303 | + """If requested download repo |
| 304 | + """ |
| 305 | + if createstructure.is_positive(self.ANSWERS["download"], empty=True): |
| 306 | + while active_count() != 1: pass # Wait creation is ultimated |
| 307 | + _ = system(f"git clone {self.repo.clone_url} --quiet") |
| 308 | + print(f"{self.get_emoji('ok')}Downloaded repo") |
| 309 | + |
| 310 | + def is_positive(answer, empty=False): |
300 | 311 | """Returns true is the answer is affermative |
301 | 312 | """ |
302 | | - return answer in ["y", "Y", "yes", "Yes"] |
| 313 | + return answer in ["y", "Y", "yes", "Yes"] or empty and answer == "" |
303 | 314 |
|
304 | 315 | def get_emoji(self, emoji): |
305 | 316 | """Returns the selected emoji |
|
0 commit comments