def _get_package(self, normalized_name, name, version, msg=None): sc = self.context existing_projects = list(get_projects_by_distutils_ids(sc, [name])) if existing_projects == []: # checking if the project already exists if normalized_name in sc.objectIds(): project = sc[normalized_name] existing_projects = [normalized_name] # empty distutils id ? let's take it ! if project.getDistutilsMainId() == '': project.setDistutilsMainId(normalized_name) else: # main id is taken, let's add it # as a secondary id secondids = project.getDistutilsSecondaryIds() secondids = secondids + (normalized_name,) project.setDistutilsSecondaryIds(secondids) if existing_projects == []: # let's create the project if msg is not None: msg.append('Created Project: %s' % name) sc.invokeFactory('PSCProject', normalized_name) project = sc._getOb(normalized_name) project.setTitle(name) project.setDistutilsMainId(name) else: project_id = existing_projects[0] project = sc[project_id] self._edit_project(project, msg=msg, distutils_name=name) versions = project.getVersionsVocab() releases = project.getReleaseFolder() if releases is None: # let's create the release folder root_id = cid = 'releases' i = 1 while cid in project.objectIds(): i += 1 cid = '%s-%d' (root_id, i) releases = project.injectFolder('PSCReleaseFolder', id=cid) is_secondary = name != project.distutilsMainId if is_secondary: version = '%s-%s' % (normalized_name, version) if not version in versions: # we need to create it releases.invokeFactory('PSCRelease', id=version) try: IAnnotations(releases[version])['title_hint'] = name except TypeError, KeyError: pass if msg is not None: msg.append('Created Release %s in Project %s' % \ (version, name))
def _distUtilsNameAvailable(self, ids): current_id = self.getId() sc = self.getParentNode() existing_projects = get_projects_by_distutils_ids(sc, ids) # make sure the names are not in another project already for project_id in existing_projects: if project_id != current_id: return False return True
def _get_projects(self, name): return get_projects_by_distutils_ids(self.context, [name])