def update_version_in_project_file(new_version, template_name): """Update version in .quickly file""" configurationhandler.loadConfig() if configurationhandler.project_config['template'] == template_name: configurationhandler.project_config['version'] = new_version else: configurationhandler.project_config['version_%s' % template_name] = new_version configurationhandler.saveConfig()
def upgrade(): # change .quickly file before getting template access return_code = configurationhandler.loadConfig(can_stop=False) if return_code == 0: # rename ubuntu-project in ubuntu-application if configurationhandler.project_config['template'] == "ubuntu-project": configurationhandler.project_config['template'] = "ubuntu-application" configurationhandler.saveConfig()
def upgrade(): # change .quickly file before getting template access return_code = configurationhandler.loadConfig(can_stop=False) if return_code == 0: # rename ubuntu-project in ubuntu-application if configurationhandler.project_config['template'] == "ubuntu-project": configurationhandler.project_config[ 'template'] = "ubuntu-application" configurationhandler.saveConfig()
def get_project_and_template_versions(template_name): """Return project and template version""" # take template version. Default is current Quickly version template_version = quicklyconfig.__version__ template_path = tools.get_template_directory(template_name) file_command_parameters = file( os.path.join(template_path, 'commandsconfig'), 'rb') for line in file_command_parameters: fields = line.split( '#' )[0] # Suppress commentary after the value in configuration file and in full line fields = fields.split('=') # Separate variable from value # normally, we have two fields in "fields" if len(fields) == 2: targeted_property = fields[0].strip() value = fields[1].strip() if targeted_property == 'TEMPLATE_VERSION': template_version = value break # get current project version for this template. Default is no migration (ie take current version) configurationhandler.loadConfig() # if this project corresponding natively to this template if configurationhandler.project_config['template'] == template_name: try: project_version = configurationhandler.project_config['version'] except KeyError: # it was called format in quickly 0.2.x project_version = configurationhandler.project_config['format'] configurationhandler.project_config['version'] = project_version del configurationhandler.project_config['format'] configurationhandler.saveConfig() else: try: project_version = configurationhandler.project_config[ 'version_%s' % template_name] except KeyError: # initialize with an empty project version to force first upgrade project_version = '' return (project_version, template_version)
def get_project_and_template_versions(template_name): """Return project and template version""" # take template version. Default is current Quickly version template_version = quicklyconfig.__version__ template_path = tools.get_template_directory(template_name) file_command_parameters = file(os.path.join(template_path, 'commandsconfig'), 'rb') for line in file_command_parameters: fields = line.split('#')[0] # Suppress commentary after the value in configuration file and in full line fields = fields.split('=') # Separate variable from value # normally, we have two fields in "fields" if len(fields) == 2: targeted_property = fields[0].strip() value = fields[1].strip() if targeted_property == 'TEMPLATE_VERSION': template_version = value break # get current project version for this template. Default is no migration (ie take current version) configurationhandler.loadConfig() # if this project corresponding natively to this template if configurationhandler.project_config['template'] == template_name: try: project_version = configurationhandler.project_config['version'] except KeyError: # it was called format in quickly 0.2.x project_version = configurationhandler.project_config['format'] configurationhandler.project_config['version'] = project_version del configurationhandler.project_config['format'] configurationhandler.saveConfig() else: try: project_version = configurationhandler.project_config['version_%s' % template_name] except KeyError: # initialize with an empty project version to force first upgrade project_version = '' return (project_version, template_version)
return(4) #bail if the name if taken if os.path.exists(project_name): print _("There is already a file or directory named %s") % project_name return(1) #create directory and template file print _("Creating project directory %s" % project_name) os.mkdir(project_name) # creating quickly file configurationhandler.project_config['version'] = quicklyconfig.__version__ configurationhandler.project_config['project'] = project_name configurationhandler.project_config['template'] = project_template configurationhandler.saveConfig(config_file_path=project_name) os.chdir(project_name) return 0 help_commands = _("List all commands ordered by templates") def commands(project_template, project_dir, command_args, shell_completion=False): """List all commands ordered by templates""" # We have nothing for this if shell_completion: return("") all_commands = commands_module.get_all_commands() for template_available in all_commands: