def process(self): """I process the project generation """ if self.noask is False: print( 'Welcome to the mamba application generator v{}\n' 'You are going to genearate a new Mamba application on {} ' 'with the following options:\n'.format( version.short(), filepath.abspath(filepath.os.getcwd()) ) ) for key, value in self.__dict__.iteritems(): if not key.startswith('_'): print('{key}: {value}'.format( key=blue(key.ljust(12)), value='{}{}'.format(reset(), str(value)), )) if Interaction.userquery( 'Would you like to generate this application?') == 'No': print('\nQuitting.') sys.exit(0) return self.generate_application()
def _generate_application_directory(self): """Generates the application directory in the current path """ try: # create project directory directory = filepath.FilePath( '{}/{}'.format(filepath.os.getcwd(), self.app_dir)) if directory.exists() and self.noask is False: print( 'Seems like an application named {} already exists in ' 'your current path.'.format(directory.basename()) ) query = 'Would you like to rename it? (Ctrl+c to abort)' if Interaction.userquery(query) == 'Yes': rnd = str(filepath.random.randrange(1, 10000)) filepath.os.rename( directory.path, '{}{}'.format(directory.path, rnd) ) print('The old directory has been saved as {}'.format( brown('{}{}'.format(directory.path, rnd)) )) else: query = 'The {} directory is going to be {}, Are you sure?' query = query.format( directory.basename(), darkred('deleted') ) if Interaction.userquery(query) == 'Yes': print('Deleting {}...'.format(directory.basename())) directory.remove() else: print('Quitting.') sys.exit(0) elif directory.exists() and self.noask is True: directory.remove() print('Creating {} directory...'.format( directory.basename()).ljust(73), end='' ) directory.createDirectory() except OSError as error: print(darkred(error)) sys.exit(-1)