def get_linked(self, val): ''' Returns subproject for linked repo. ''' if not is_repo_link(val): return None project, subproject = val[10:].split('/', 1) return self.get(slug=subproject, project__slug=project)
def get_linked(self, val): """ Returns subproject for linked repo. """ if not is_repo_link(val): return None project, subproject = val[10:].split("/", 1) return self.get(slug=subproject, project__slug=project)
def is_repo_link(self): ''' Checks whether repository is just a link for other one. ''' return is_repo_link(self.repo)
def handle(self, *args, **options): ''' Automatic import of project. ''' if len(args) != 4: raise CommandError('Not enough parameters!') # Read params prjname, repo, branch, filemask = args # Try to get project try: project = Project.objects.get(slug=prjname) except Project.DoesNotExist: raise CommandError( 'Project %s does not exist, you need to create it first!' % prjname ) # Do we have correct mask? if not '**' in filemask: raise CommandError( 'You need to specify double wildcard ' 'for subproject part of the match!' ) if is_repo_link(repo): sharedrepo = repo master_sub_project = repo.rsplit('/', 1)[-1] try: sub_project = SubProject.objects.get( project=project, slug=master_sub_project ) except SubProject.DoesNotExist: raise CommandError( 'SubProject %s does not exist, ' 'you need to create it first!' % repo ) matches = self.get_matching_subprojects( sub_project.get_path(), filemask ) else: matches, sharedrepo = self.import_initial( project, repo, branch, filemask, options['name_template'] ) # Create remaining subprojects sharing git repository for match in matches: name = options['name_template'] % match slug = slugify(name) subprojects = SubProject.objects.filter( Q(name=name) | Q(slug=slug), project=project ) if subprojects.exists(): logger.warn('Subproject %s already exists, skipping', name) continue logger.info('Creating subproject %s', name) SubProject.objects.create( name=name, slug=slug, project=project, repo=sharedrepo, branch=branch, filemask=filemask.replace('**', match) )
def handle(self, *args, **options): ''' Automatic import of project. ''' if len(args) != 4: raise CommandError('Invalid number of parameters!') if options['file_format'] not in FILE_FORMATS: raise CommandError( 'Invalid file format: %s' % options['file_format'] ) # Read params, pylint: disable=W0632 prjname, repo, branch, filemask = args # Try to get project try: project = Project.objects.get(slug=prjname) except Project.DoesNotExist: raise CommandError( 'Project %s does not exist, you need to create it first!' % prjname ) # Do we have correct mask? if not '**' in filemask: raise CommandError( 'You need to specify double wildcard ' 'for subproject part of the match!' ) if is_repo_link(repo): sharedrepo = repo try: sub_project = SubProject.objects.get( project=project, slug=repo.rsplit('/', 1)[-1] ) except SubProject.DoesNotExist: raise CommandError( 'SubProject %s does not exist, ' 'you need to create it first!' % repo ) matches = self.get_matching_subprojects( sub_project.get_path(), filemask ) else: matches, sharedrepo = self.import_initial( project, repo, branch, filemask, options['name_template'], options['file_format'], options['base_file_template'] ) # Create remaining subprojects sharing git repository for match in matches: name = self.format_string(options['name_template'], match) template = self.format_string(options['base_file_template'], match) slug = slugify(name) subprojects = SubProject.objects.filter( Q(name=name) | Q(slug=slug), project=project ) if subprojects.exists(): weblate.logger.warn( 'Subproject %s already exists, skipping', name ) continue weblate.logger.info('Creating subproject %s', name) SubProject.objects.create( name=name, slug=slug, project=project, repo=sharedrepo, branch=branch, template=template, file_format=options['file_format'], filemask=filemask.replace('**', match) )
def handle(self, *args, **options): ''' Automatic import of project. ''' if len(args) != 4: raise CommandError('Not enough parameters!') # Read params prjname, repo, branch, filemask = args # Try to get project try: project = Project.objects.get(slug=prjname) except Project.DoesNotExist: raise CommandError( 'Project %s does not exist, you need to create it first!' % prjname ) # Do we have correct mask? if not '**' in filemask: raise CommandError( 'You need to specify double wildcard ' 'for subproject part of the match!' ) if is_repo_link(repo): sharedrepo = repo try: sub_project = SubProject.objects.get( project=project, slug=repo.rsplit('/', 1)[-1] ) except SubProject.DoesNotExist: raise CommandError( 'SubProject %s does not exist, ' 'you need to create it first!' % repo ) matches = self.get_matching_subprojects( sub_project.get_path(), filemask ) else: matches, sharedrepo = self.import_initial( project, repo, branch, filemask, options['name_template'] ) # Create remaining subprojects sharing git repository for match in matches: name = options['name_template'] % match slug = slugify(name) subprojects = SubProject.objects.filter( Q(name=name) | Q(slug=slug), project=project ) if subprojects.exists(): weblate.logger.warn( 'Subproject %s already exists, skipping', name ) continue weblate.logger.info('Creating subproject %s', name) SubProject.objects.create( name=name, slug=slug, project=project, repo=sharedrepo, branch=branch, filemask=filemask.replace('**', match) )
def is_repo_link(self): ''' Checks whethere repository is just a link for other one. ''' return is_repo_link(self.repo)